Class Vector


  • public class Vector
    extends Object
    A set of utility functions for basic 2D vector functions.
    Author:
    Karel Maesen, Geovise BVBA creation-date: 4/7/12
    • Constructor Summary

      Constructors 
      Constructor Description
      Vector()  
    • Constructor Detail

      • Vector

        public Vector()
    • Method Detail

      • positionToSegment2D

        public static <P extends C2D> double[] positionToSegment2D​(P p0,
                                                                   P p1,
                                                                   P y)
        Returns the squared distance and projectionfactor of the position y on the linesegment defined by positions p0 and p1

        The projection factor is the value for t that determines the projection of y on the line p0 + t*(p1-p0).

        Parameters:
        p0 - the start position of the line segment
        p1 - the end position of the line segment
        y - the position to project onto the linesegment
        Returns:
        an array of length 2, with first element being the squared distance of Position y to the linesegment, and second element the projection factor
      • dot

        public static <P extends C2D> double dot​(P p0,
                                                 P p1)
        Returns the dot-product of the specified Positions
        Parameters:
        p0 - first operand
        p1 - second operand
        Returns:
        the dot-product of p0 and p1.
      • add

        public static <P extends C2D> P add​(P p0,
                                            P p1)
        Adds two Positions.

        If any of the parameters are 2D, the operation is performed in 2D.

        Parameters:
        p0 - first operand
        p1 - second operand
        Returns:
        the sum of p0 and p1.
      • substract

        public static <P extends C2D> P substract​(P p0,
                                                  P p1)
        Subtracts two Positions.

        If any of the parameters are 2D, the operation is performed in 2D.

        Parameters:
        p0 - first operand
        p1 - second operand
        Returns:
        the Position x = p0 - p1.
      • perp

        public static <P extends C2D> P perp​(P p)
        Hill's "perp" operator.

        The application of this operator on a vector P returns the vector perpendicular at 90 deg. counterclockwise from P in the 2D (X/Y) plane.

        Parameters:
        p - a vector represented by a Position.
        Returns:
        the vector perpendicular to p in the 2D-plane, at 90 deg. counterclockwise.
      • perpDot

        public static <P extends C2D> double perpDot​(P p0,
                                                     P p1)
        Applies the perp dot-operation on the specified Positions

        The perp dot operation on vectors P, Q is defined as dot(perp(P),Q).

        This operation will be performed in 2D only.

        Parameters:
        p0 - first operand
        p1 - second operand
        Returns:
        the Perp dot of p0 and p1.