Began work on generating parabola for randomization

This commit is contained in:
davpapp 2018-02-19 16:25:11 -05:00
parent f2d9d52711
commit 19aa168a3c
9 changed files with 29 additions and 10 deletions

View File

@ -67,7 +67,6 @@ public class Cursor {
this.cursorPathsByDistance.get(cursorPath.getCursorPathDistance()).add(cursorPath);
}
// TODO: make sure these are reasonable
private int getRandomClickLength() {
return randomizer.nextGaussianWithinRange(MINIMUM_CLICK_LENGTH, MAXIMUM_CLICK_LENGTH);
@ -76,7 +75,7 @@ public class Cursor {
private int getRandomClickReleaseLength() {
return randomizer.nextGaussianWithinRange(MINIMUM_CLICK_LENGTH + 5, MAXIMUM_CLICK_LENGTH + 10);
}
// END
public void leftClickCursor() throws InterruptedException {
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);

View File

@ -3,6 +3,7 @@
*/
import java.util.ArrayList;
import java.util.Random;
public class CursorPath {
@ -10,6 +11,7 @@ public class CursorPath {
private double theta;
private int distance;
private int timespan;
Randomizer randomizer;
public CursorPath(ArrayList<CursorPoint> cursorPoints)
{
@ -17,8 +19,10 @@ public class CursorPath {
this.distance = calculateCursorPathDistance();
this.theta = calculateCursorPathTheta();
this.timespan = calculateCursorPathTimespan();
this.randomizer = new Randomizer();
}
// TODO: refactor
public CursorPath(ArrayList<CursorPoint> cursorPoints, boolean setInitializiationOff)
{
this.cursorPoints = cursorPoints;
@ -54,20 +58,30 @@ public class CursorPath {
}
public CursorPath getScaledCopyOfCursorPath(double factorToScaleBy) {
ArrayList<CursorPoint> scaledCursorPath = new ArrayList<CursorPoint>();
ArrayList<CursorPoint> scaledCursorPoints= new ArrayList<CursorPoint>();
for (CursorPoint cursorPoint : this.cursorPoints) {
scaledCursorPath.add(cursorPoint.getCursorPointScaledBy(factorToScaleBy));
scaledCursorPoints.add(cursorPoint.getCursorPointScaledBy(factorToScaleBy));
}
return new CursorPath(scaledCursorPath, true);
return new CursorPath(scaledCursorPoints, true);
}
public CursorPath getRotatedCopyOfCursorPath(double angleToRotateTo) {
ArrayList<CursorPoint> rotatedCursorPath = new ArrayList<CursorPoint>();
ArrayList<CursorPoint> rotatedCursorPoints = new ArrayList<CursorPoint>();
double angleToRotateBy = this.theta - angleToRotateTo;
for (CursorPoint cursorPoint : this.cursorPoints) {
rotatedCursorPath.add(cursorPoint.getCursorPointRotatedBy(angleToRotateBy));
rotatedCursorPoints.add(cursorPoint.getCursorPointRotatedBy(angleToRotateBy));
}
return new CursorPath(rotatedCursorPath, true);
return new CursorPath(rotatedCursorPoints, true);
}
public CursorPath getCopyOfCursorPathTransformedByParabola() {
double[] parabolaEquation = randomizer.generateParabolaEquation(this.getCursorPathDistance());
ArrayList<CursorPoint> transformedCursorPoints = new ArrayList<CursorPoint>();
for (CursorPoint cursorPoint : this.cursorPoints) {
transformedCursorPoints.add(cursorPoint.getCursorPointTransformedBy(parabolaEquation);)
}
return new CursorPath(transformedCursorPoints, true);
}
private int calculateCursorPathTimespan() {

View File

@ -34,6 +34,12 @@ public class CursorPoint {
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));
}

View File

@ -21,7 +21,6 @@ public class Randomizer {
}
return (int) result;
}
public Point generatePeakForTransformationParabola(int pathDistance) {
double maxTransformationScale = 0.2;
int peakX = nextGaussianWithinRange(0, pathDistance);
@ -29,7 +28,8 @@ public class Randomizer {
return new Point(peakX, peakY);
}
public double[] generateParabolaEquation(int pathDistance, Point peakPoint) {
public double[] generateParabolaEquation(int pathDistance) {
Point peakPoint = generatePeakForTransformationParabola(pathDistance);
double[][] lhsMatrix = {{0, 0, 1}, {peakPoint.x * peakPoint.x, peakPoint.x, 1}, {pathDistance * pathDistance, pathDistance, 1}};
double[][] rhsMatrix = {{0, peakPoint.y, 0}};

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.