mirror of
https://github.com/davpapp/PowerMiner
synced 2024-08-13 17:03:53 -04:00
Began work on generating parabola for randomization
This commit is contained in:
parent
f2d9d52711
commit
19aa168a3c
@ -67,7 +67,6 @@ public class Cursor {
|
|||||||
this.cursorPathsByDistance.get(cursorPath.getCursorPathDistance()).add(cursorPath);
|
this.cursorPathsByDistance.get(cursorPath.getCursorPathDistance()).add(cursorPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: make sure these are reasonable
|
// TODO: make sure these are reasonable
|
||||||
private int getRandomClickLength() {
|
private int getRandomClickLength() {
|
||||||
return randomizer.nextGaussianWithinRange(MINIMUM_CLICK_LENGTH, MAXIMUM_CLICK_LENGTH);
|
return randomizer.nextGaussianWithinRange(MINIMUM_CLICK_LENGTH, MAXIMUM_CLICK_LENGTH);
|
||||||
@ -76,7 +75,7 @@ public class Cursor {
|
|||||||
private int getRandomClickReleaseLength() {
|
private int getRandomClickReleaseLength() {
|
||||||
return randomizer.nextGaussianWithinRange(MINIMUM_CLICK_LENGTH + 5, MAXIMUM_CLICK_LENGTH + 10);
|
return randomizer.nextGaussianWithinRange(MINIMUM_CLICK_LENGTH + 5, MAXIMUM_CLICK_LENGTH + 10);
|
||||||
}
|
}
|
||||||
|
// END
|
||||||
|
|
||||||
public void leftClickCursor() throws InterruptedException {
|
public void leftClickCursor() throws InterruptedException {
|
||||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class CursorPath {
|
public class CursorPath {
|
||||||
|
|
||||||
@ -10,6 +11,7 @@ public class CursorPath {
|
|||||||
private double theta;
|
private double theta;
|
||||||
private int distance;
|
private int distance;
|
||||||
private int timespan;
|
private int timespan;
|
||||||
|
Randomizer randomizer;
|
||||||
|
|
||||||
public CursorPath(ArrayList<CursorPoint> cursorPoints)
|
public CursorPath(ArrayList<CursorPoint> cursorPoints)
|
||||||
{
|
{
|
||||||
@ -17,8 +19,10 @@ public class CursorPath {
|
|||||||
this.distance = calculateCursorPathDistance();
|
this.distance = calculateCursorPathDistance();
|
||||||
this.theta = calculateCursorPathTheta();
|
this.theta = calculateCursorPathTheta();
|
||||||
this.timespan = calculateCursorPathTimespan();
|
this.timespan = calculateCursorPathTimespan();
|
||||||
|
this.randomizer = new Randomizer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: refactor
|
||||||
public CursorPath(ArrayList<CursorPoint> cursorPoints, boolean setInitializiationOff)
|
public CursorPath(ArrayList<CursorPoint> cursorPoints, boolean setInitializiationOff)
|
||||||
{
|
{
|
||||||
this.cursorPoints = cursorPoints;
|
this.cursorPoints = cursorPoints;
|
||||||
@ -54,20 +58,30 @@ public class CursorPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CursorPath getScaledCopyOfCursorPath(double factorToScaleBy) {
|
public CursorPath getScaledCopyOfCursorPath(double factorToScaleBy) {
|
||||||
ArrayList<CursorPoint> scaledCursorPath = new ArrayList<CursorPoint>();
|
ArrayList<CursorPoint> scaledCursorPoints= new ArrayList<CursorPoint>();
|
||||||
for (CursorPoint cursorPoint : this.cursorPoints) {
|
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) {
|
public CursorPath getRotatedCopyOfCursorPath(double angleToRotateTo) {
|
||||||
ArrayList<CursorPoint> rotatedCursorPath = new ArrayList<CursorPoint>();
|
ArrayList<CursorPoint> rotatedCursorPoints = new ArrayList<CursorPoint>();
|
||||||
double angleToRotateBy = this.theta - angleToRotateTo;
|
double angleToRotateBy = this.theta - angleToRotateTo;
|
||||||
for (CursorPoint cursorPoint : this.cursorPoints) {
|
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() {
|
private int calculateCursorPathTimespan() {
|
||||||
|
@ -34,6 +34,12 @@ public class CursorPoint {
|
|||||||
return (new CursorPoint(rotatedX, rotatedY, delay));
|
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) {
|
public CursorPoint getCursorPointWithNewDelay(int delay) {
|
||||||
return (new CursorPoint(this.x, this.y, delay));
|
return (new CursorPoint(this.x, this.y, delay));
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ public class Randomizer {
|
|||||||
}
|
}
|
||||||
return (int) result;
|
return (int) result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point generatePeakForTransformationParabola(int pathDistance) {
|
public Point generatePeakForTransformationParabola(int pathDistance) {
|
||||||
double maxTransformationScale = 0.2;
|
double maxTransformationScale = 0.2;
|
||||||
int peakX = nextGaussianWithinRange(0, pathDistance);
|
int peakX = nextGaussianWithinRange(0, pathDistance);
|
||||||
@ -29,7 +28,8 @@ public class Randomizer {
|
|||||||
return new Point(peakX, peakY);
|
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[][] lhsMatrix = {{0, 0, 1}, {peakPoint.x * peakPoint.x, peakPoint.x, 1}, {pathDistance * pathDistance, pathDistance, 1}};
|
||||||
double[][] rhsMatrix = {{0, peakPoint.y, 0}};
|
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.
Loading…
Reference in New Issue
Block a user