Exemple #1
0
        // 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)));
        }
Exemple #2
0
        //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)));
        }
Exemple #3
0
        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()));
        }
Exemple #4
0
 public override Point2D position(double d)
 {
     return(Point2D.add(m_startpoint, Point2D.multiplyBy((Point2D.sub(m_endpoint, m_startpoint).normalize()), d)));
 }
Exemple #5
0
 public virtual bool move(Point2D difference)
 {
     m_startpoint = Point2D.add(m_startpoint, difference);
     m_endpoint   = Point2D.add(m_endpoint, difference);
     return(true);
 }
Exemple #6
0
 public override bool move(Point2D difference)
 {
     base.move(difference);
     m_center = Point2D.add(m_center, difference);
     return(true);
 }