Class Coordinates

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Coordinates>

    public final class Coordinates
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Comparable<Coordinates>
    Class to encapsulate 3D coordinates
    See Also:
    Serialized Form
    • Field Detail

      • x

        public double x
      • y

        public double y
      • z

        public double z
    • Constructor Detail

      • Coordinates

        public Coordinates()
      • Coordinates

        public Coordinates​(double x,
                           double y,
                           double z)
    • Method Detail

      • set

        public Coordinates set​(Coordinates c)
        Copies x,y,z from c to this
        Parameters:
        c -
        Returns:
        this after copying c
      • set

        public void set​(double x,
                        double y,
                        double z)
      • getLength

        public double getLength()
      • dist

        public final double dist()
      • distSq

        public final double distSq()
      • distanceSquared

        public final double distanceSquared​(Coordinates c)
      • distSquareTo

        public final double distSquareTo​(Coordinates c)
      • distance

        public final double distance​(Coordinates c)
      • getAngle

        public final double getAngle​(Coordinates c)
        Gets the angle formed between the 2 vectors ([0,PI])
        Parameters:
        c -
        Returns:
        angle in radian
      • getAngleXY

        public double getAngleXY​(Coordinates c)
        Calculates the angle of the line from this location to c projected into the x/y plane. With Y facing upwards and X right, if the line points in Y direction, ten angle is 0.0 increasing in clockwise direction.
        Parameters:
        c -
        Returns:
        -PI < angle < PI
      • scaleC

        public final Coordinates scaleC​(double scale)
      • add

        public void add​(double dx,
                        double dy,
                        double dz)
      • scale

        public final Coordinates scale​(double scale)
        Parameters:
        scale -
        Returns:
        this after scaling this
      • negate

        public final void negate()
      • rotate

        public Coordinates rotate​(double[][] m)
        Parameters:
        m -
        Returns:
        this after rotating it with rotation matrix m
      • rotateC

        public Coordinates rotateC​(double[][] m)
        Parameters:
        m -
        Returns:
        new Coordinates created from this point rotated by rotation matrix m
      • unitC

        public final Coordinates unitC()
        Returns:
        new Coordinates with a copy of this scaled to length=1.0
      • unit

        public final Coordinates unit()
        Returns:
        this after scaling it to length=1.0
      • center

        public Coordinates center​(Coordinates c)
        Calculates the center point between this and c and sets this to the center point.
        Parameters:
        c -
        Returns:
        this after updating it to the center position
      • center

        public void center​(Coordinates c1,
                           Coordinates c2)
        Updates this to contains the center between c1 and c2.
        Parameters:
        c1 -
        c2 -
      • between

        public Coordinates between​(Coordinates c1,
                                   Coordinates c2,
                                   double f)
        Updates this to contain a point on the straight line through c1 and c2.
        Parameters:
        c1 -
        c2 -
        f - location on line 0.0 -> c1, 1.0 -> c2
        Returns:
        this after updating to be a point on the line
      • insideBounds

        public final boolean insideBounds​(Coordinates[] bounds)
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toStringSpaceDelimited

        public final java.lang.String toStringSpaceDelimited()
      • equals

        public final boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • isNaN

        public final boolean isNaN()
      • getDihedral

        public static final double getDihedral​(Coordinates c1,
                                               Coordinates c2,
                                               Coordinates c3,
                                               Coordinates c4)
        Calculates a signed torsion as an exterior spherical angle from a valid sequence of 4 points in space. Looking along the line from c2 to c3, the torsion angle is 0.0, if the projection of c2->c1 and c3->c4 point in the same direction. If the projection of vector c2-c1 is rotated in clockwise direction, the angle increases, i.e. has a positive value. http://en.wikipedia.org/wiki/Dihedral_angle
        Parameters:
        c1 -
        c2 -
        c3 -
        c4 -
        Returns:
        torsion in the range: -pi <= torsion <= pi
      • compareTo

        public int compareTo​(Coordinates o)
        Specified by:
        compareTo in interface java.lang.Comparable<Coordinates>