Skip to content

Commit 83007ca

Browse files
committed
added negative position/motion and updated jar
1 parent c7ea1ee commit 83007ca

4 files changed

Lines changed: 113 additions & 3 deletions

File tree

EndersPositionLibrary.jar

1.1 KB
Binary file not shown.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.endercrypt.library.position;
2+
3+
import java.io.Serializable;
4+
5+
public class DownsideMotion extends Motion
6+
{
7+
private static final long serialVersionUID = -1510348838797560540L;
8+
9+
/**
10+
* this class basically just reverses all Y positions
11+
*/
12+
13+
public DownsideMotion()
14+
{
15+
super();
16+
// TODO Auto-generated constructor stub
17+
}
18+
19+
public DownsideMotion(double x, double y)
20+
{
21+
super(x, y);
22+
// TODO Auto-generated constructor stub
23+
}
24+
25+
public DownsideMotion(Motion motion)
26+
{
27+
super(motion);
28+
// TODO Auto-generated constructor stub
29+
}
30+
31+
@Override
32+
public void setMotion(double direction, double length)
33+
{
34+
double x = Math.cos(direction) * length;
35+
double y = -Math.sin(direction) * length;
36+
set(x, y);
37+
}
38+
39+
@Override
40+
public void addMotion(double direction, double length)
41+
{
42+
double x = Math.cos(direction) * length;
43+
double y = -Math.sin(direction) * length;
44+
add(x, y);
45+
}
46+
47+
@Override
48+
public double getDirection()
49+
{
50+
return Math.atan2(-y, x);
51+
}
52+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.endercrypt.library.position;
2+
3+
import java.awt.Point;
4+
import java.awt.geom.Point2D;
5+
import java.awt.geom.Point2D.Double;
6+
import java.io.Serializable;
7+
8+
public class DownsidePosition extends Position
9+
{
10+
private static final long serialVersionUID = 1448197238813213458L;
11+
12+
/**
13+
*
14+
*/
15+
16+
public DownsidePosition()
17+
{
18+
super();
19+
// TODO Auto-generated constructor stub
20+
}
21+
22+
public DownsidePosition(double x, double y)
23+
{
24+
super(x, y);
25+
// TODO Auto-generated constructor stub
26+
}
27+
28+
public DownsidePosition(Double point)
29+
{
30+
super(point);
31+
// TODO Auto-generated constructor stub
32+
}
33+
34+
public DownsidePosition(Point point)
35+
{
36+
super(point);
37+
// TODO Auto-generated constructor stub
38+
}
39+
40+
public DownsidePosition(Position position)
41+
{
42+
super(position);
43+
// TODO Auto-generated constructor stub
44+
}
45+
46+
@Override
47+
public double direction(double x, double y)
48+
{
49+
return Math.atan2((y - this.y), (x - this.x));
50+
}
51+
52+
@Override
53+
public void add(double direction, double length)
54+
{
55+
x += Math.cos(direction) * length;
56+
y += -Math.sin(direction) * length;
57+
}
58+
}

src/com/endercrypt/library/position/Position.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ public double direction(double x, double y)
7676
return Math.atan2((y - this.y), (x - this.x));
7777
}
7878

79-
public void add(Motion vector)
79+
public void add(Motion motion)
8080
{
81-
x += vector.x;
82-
y += vector.y;
81+
x += motion.x;
82+
y += motion.y;
8383
}
8484

8585
public void add(double direction, double length)

0 commit comments

Comments
 (0)