Class Point

java.lang.Object
cnuphys.adaptiveSwim.geometry.Point
Direct Known Subclasses:
Vector

public class Point extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    double
    x component
    double
    y component
    double
    z component
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a point at the origin
    Point(double[] p)
    Create a point
    Point(double x, double y, double z)
    Create a point
    Copy constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    static Point
    Get the difference between two points
    static void
    Get the in-place difference between two points
    double
    distance(double x, double y, double z)
    Compute the distance to another point
    double
    Compute the distance to another point
    double
    The dot product of this "vector" with another vector
    static double
    dot(Point a, Point b)
    The dot product of two vectors or points
    void
    set(double x, double y, double z)
    Set the components of the vector
    Get a string representation of the Point

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • x

      public double x
      x component
    • y

      public double y
      y component
    • z

      public double z
      z component
  • Constructor Details

    • Point

      public Point()
      Create a point at the origin
    • Point

      public Point(Point p)
      Copy constructor
      Parameters:
      p - the point to copy
    • Point

      public Point(double x, double y, double z)
      Create a point
      Parameters:
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
    • Point

      public Point(double[] p)
      Create a point
      Parameters:
      p - the point as an xyz array
  • Method Details

    • set

      public void set(double x, double y, double z)
      Set the components of the vector
      Parameters:
      x - the x component
      y - the y component
      z - the z component
    • difference

      public static Point difference(Point a, Point b)
      Get the difference between two points
      Parameters:
      a - one point
      b - the other point
      Returns:
      the difference between two points a - b
    • difference

      public static void difference(Point a, Point b, Point c)
      Get the in-place difference between two points
      Parameters:
      a - one point
      b - the other point
      c - upon return the difference between two points a - b
    • dot

      public double dot(Point v)
      The dot product of this "vector" with another vector
      Parameters:
      v - the other vector or point
      Returns:
      the dot product
    • dot

      public static double dot(Point a, Point b)
      The dot product of two vectors or points
      Parameters:
      a - one vector or point
      b - the other vector or point
      Returns:
      the dot product
    • toString

      public String toString()
      Get a string representation of the Point
      Overrides:
      toString in class Object
      Returns:
      a String representation
    • distance

      public double distance(double x, double y, double z)
      Compute the distance to another point
      Parameters:
      x - the x coordinate of the other point
      y - the y coordinate of the other point
      z - the z coordinate of the other point
      Returns:
      the distance between the points
    • distance

      public double distance(Point p)
      Compute the distance to another point
      Parameters:
      p - the other point
      Returns:
      the distance between the points