// Projects a Point onto a Line. Afterwards rounds the Line onto a rounding factor (unless the rounding factor is 0) public Point2D projectPointToLine(Point2D point, Point2D directionalVector, Point2D supportVector, double roundingFactor) { directionalVector = directionalVector.normalize(); double lamda = round(directionalVector.point(supportVector), roundingFactor); return(new Point2D(Point2D.add(Point2D.multiplyBy(directionalVector, lamda), supportVector))); }
//rotates a point around a center and an angle public static Point2D rotate(Point2D point, Point2D center, double angle) { double length = Point2D.sub(point, center).length(); double oldAngle = angleToPoint(point, center); return(new Point2D( Point2D.add( Point2D.multiplyBy( new Point2D(Math.Cos(oldAngle + angle), Math.Sin(oldAngle + angle)), length), center))); }
public override Point2D position(double d) { double angle = drivesInReverse() != drivesRight() ? startAngle() + d / radius() : startAngle() - d / radius(); //while (angle < -Math.PI) // angle += 2 * Math.PI; //while (angle > Math.PI) // angle -= 2 * Math.PI; return(Point2D.add(Point2D.multiplyBy(new Point2D(angle), radius()), center())); }
public override Point2D position(double d) { return(Point2D.add(m_startpoint, Point2D.multiplyBy((Point2D.sub(m_endpoint, m_startpoint).normalize()), d))); }