Class CGAlgorithmsDD


  • public class CGAlgorithmsDD
    extends java.lang.Object
    Implements basic computational geometry algorithms using DD arithmetic.
    Author:
    Martin Davis
    • Method Detail

      • orientationIndex

        public static int orientationIndex​(Coordinate p1,
                                           Coordinate p2,
                                           Coordinate q)
        Returns the index of the direction of the point q relative to a vector specified by p1-p2.
        Parameters:
        p1 - the origin point of the vector
        p2 - the final point of the vector
        q - the point to compute the direction to
        Returns:
        1 if q is counter-clockwise (left) from p1-p2
      • signOfDet2x2

        public static int signOfDet2x2​(DD x1,
                                       DD y1,
                                       DD x2,
                                       DD y2)
        Computes the sign of the determinant of the 2x2 matrix with the given entries.
        Returns:
        -1 if the determinant is negative,
      • signOfDet2x2

        public static int signOfDet2x2​(double dx1,
                                       double dy1,
                                       double dx2,
                                       double dy2)
        Computes the sign of the determinant of the 2x2 matrix with the given entries.
        Returns:
        -1 if the determinant is negative,
      • intersection

        public static Coordinate intersection​(Coordinate p1,
                                              Coordinate p2,
                                              Coordinate q1,
                                              Coordinate q2)
        Computes an intersection point between two lines using DD arithmetic. Currently does not handle case of parallel lines.
        Parameters:
        p1 -
        p2 -
        q1 -
        q2 -
        Returns: