mirror of
https://github.com/davpapp/PowerMiner
synced 2024-11-14 21:45:14 -05:00
50 lines
1.5 KiB
Java
50 lines
1.5 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 getCursorPointTransformedBy(double[] parabolaEquation) {
|
|
int rotatedX = (int) 5;
|
|
int rotatedY = (int) 5;
|
|
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);
|
|
}
|
|
} |