PowerMiner/src/CursorPoint.java

44 lines
1.3 KiB
Java

import java.awt.Point;
public class CursorPoint {
public int x;
public int y;
public int delay;
public CursorPoint(int x, int y, int delay) {
this.x = x;
this.y = y;
this.delay = delay;
}
public double getDistanceFromOrigin() {
return Math.hypot(this.x, this.y);
}
public double getThetaFromOrigin() {
return Math.atan2(this.x, this.y);
}
public CursorPoint getCursorPointTranslatedBy(CursorPoint startingCursorPoint) {
return new CursorPoint(x - startingCursorPoint.x, y - startingCursorPoint.y, delay - startingCursorPoint.delay);
}
public CursorPoint getCursorPointScaledBy(double scaleFactor) {
return (new CursorPoint((int) (this.x * scaleFactor), (int) (this.y * scaleFactor), (int) (delay * scaleFactor)));
}
public CursorPoint getCursorPointRotatedBy(double angleOfRotation) {
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);
return (new CursorPoint(rotatedX, rotatedY, delay));
}
public CursorPoint getCursorPointWithNewDelay(int delay) {
return (new CursorPoint(this.x, this.y, delay));
}
public void display() {
System.out.println("Point: (" + x + "," + y + "), delay: " + delay);
}
}