Пример #1
0
        //############################################################################
        //						VECTOR MATH OPERATIONS
        //############################################################################

        public Vector unitVector()
        {
            if (x + y != 0)
            {
                Point2D origin   = new Point2D.Double(0, 0);
                Point2D endpoint = new Point2D.Double(x, y);
                double  unitX    = x / origin.distance(endpoint);
                double  unitY    = y / origin.distance(endpoint);
                return(new Vector(unitX, unitY));
            }
            else
            {
                return(new Vector(0, 0));
            }
        }