2018-02-04 15:34:27 -05:00
|
|
|
import java.awt.Point;
|
|
|
|
|
2018-01-30 04:14:17 -05:00
|
|
|
public class CursorPoint {
|
|
|
|
|
|
|
|
public int x;
|
|
|
|
public int y;
|
2018-02-04 15:34:27 -05:00
|
|
|
public int delay;
|
2018-01-30 04:14:17 -05:00
|
|
|
|
2018-02-04 15:34:27 -05:00
|
|
|
public CursorPoint(int x, int y, int delay) {
|
2018-01-30 04:14:17 -05:00
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
2018-02-04 15:34:27 -05:00
|
|
|
this.delay = delay;
|
2018-01-31 00:04:07 -05:00
|
|
|
}
|
|
|
|
|
2018-02-15 06:27:12 -05:00
|
|
|
public double getDistanceFromOrigin() {
|
|
|
|
return Math.hypot(this.x, this.y);
|
2018-02-04 15:34:27 -05:00
|
|
|
}
|
|
|
|
|
2018-02-15 06:27:12 -05:00
|
|
|
public double getThetaFromOrigin() {
|
|
|
|
return Math.atan2(this.x, this.y);
|
2018-02-04 15:34:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public CursorPoint getCursorPointTranslatedBy(CursorPoint startingCursorPoint) {
|
2018-02-15 06:27:12 -05:00
|
|
|
return new CursorPoint(x - startingCursorPoint.x, y - startingCursorPoint.y, delay - startingCursorPoint.delay);
|
2018-02-04 15:34:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public CursorPoint getCursorPointScaledBy(double scaleFactor) {
|
2018-02-15 06:27:12 -05:00
|
|
|
return (new CursorPoint((int) (this.x * scaleFactor), (int) (this.y * scaleFactor), (int) (delay * scaleFactor)));
|
2018-02-04 15:34:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public CursorPoint getCursorPointRotatedBy(double angleOfRotation) {
|
2018-02-12 19:40:09 -05:00
|
|
|
int rotatedX = (int) (Math.cos(angleOfRotation) * this.x - Math.sin(angleOfRotation) * this.y);
|
|
|
|
int rotatedY = (int) (Math.sin(angleOfRotation) * this.x + Math.cos(angleOfRotation) * this.y);
|
2018-02-15 06:27:12 -05:00
|
|
|
return (new CursorPoint(rotatedX, rotatedY, delay));
|
2018-02-04 15:34:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public CursorPoint getCursorPointWithNewDelay(int delay) {
|
|
|
|
return (new CursorPoint(this.x, this.y, delay));
|
2018-01-31 00:04:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public void display() {
|
2018-02-04 15:34:27 -05:00
|
|
|
System.out.println("Point: (" + x + "," + y + "), delay: " + delay);
|
2018-01-30 04:14:17 -05:00
|
|
|
}
|
|
|
|
}
|