use of me.wobblyyyy.pathfinder2.geometry.Line in project Pathfinder2 by Wobblyyyy.
the class PathOptimizer method determineLength.
/**
* Determine the length of a set of points/path.
*
* @param path the path to determine the total length of.
* @return the total length of the path.
*/
public static double determineLength(List<PointXY> path) {
List<Line> lines = new ArrayList<>(path.size() * 2);
for (int i = 0; i < path.size() - 1; i++) {
PointXY current = path.get(i);
PointXY next = path.get(i + 1);
Line line = new Line(current, next);
lines.add(line);
}
double length = 0;
for (Line line : lines) {
length += Math.abs(line.length());
}
return length;
}
use of me.wobblyyyy.pathfinder2.geometry.Line in project Pathfinder2 by Wobblyyyy.
the class LinearTrajectoryBuilder method rotateLine.
/**
* Move in a line and rotate to a specified heading.
*
* @param distance the distance from the current point that the new
* point should be drawn at.
* @param targetAngle the angle the trajectory should attempt to turn to.
* @param angle the angle at which the line should be drawn.
*/
public LinearTrajectoryBuilder rotateLine(double distance, Angle targetAngle, Angle angle) {
PointXYZ next = last.inDirection(distance, angle);
trajectories.add(new LinearTrajectory(next.withHeading(targetAngle), speed, tolerance, angleTolerance));
last = next;
return this;
}
Aggregations