Beispiel #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)));
        }
Beispiel #2
0
 public AngleWrapper(Point2D vector)
 {
     //setRadian(Math.Atan2(vector.y, vector.x));
     vector = vector.normalize();
     if (vector.y < 0)
     {
         setRadian(2 * Math.PI - Math.Acos(vector.x));
     }
     else
     {
         setRadian(Math.Acos(vector.x));
     }
 }
Beispiel #3
0
        // Calculates the angle of a vektor
        public static double angleToPoint(Point2D point, Point2D centerPoint)
        {
            Point2D p1 = new Point2D(1, 0);
            Point2D p2 = new Point2D(centerPoint.normalize());

            if (point.y < centerPoint.y)
            {
                return(2 * Math.PI - Math.Acos(p1.point(p2)));
            }
            else
            {
                return(Math.Acos(p1.point(p2)));
            }
        }