Exemplo n.º 1
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)));
            }
        }
Exemplo n.º 2
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)));
        }