Class Plane

java.lang.Object
cnuphys.swim.util.Plane

public class Plane extends Object
A plane is defined by the equation ax + by + cz = d
Author:
heddle
  • Constructor Summary

    Constructors
    Constructor
    Description
    Plane(double a, double b, double c, double d)
    Create a plane of the form ax + by + cz = d
  • Method Summary

    Modifier and Type
    Method
    Description
    static Plane
    constantPhiPlane(double phi)
    Create a plane of constant azimuthal angle phi
    boolean
    contained(double x, double y, double z, double tolerance)
    See if a point is contained (on) a plane
    static Plane
    createPlane(double[] norm, double d)
    Create a plane from a normal vector and a distance to the plane
    static Plane
    createPlane(double[] norm, double[] p)
    Create a plane from a normal vector and a point on the plane
    static Plane
    createPlane(double normX, double normY, double normZ, double d)
    Create a plane from a normal vector and a distance to the plane
    static Plane
    Create a plane in the clas12 tilted system
    int
    directionSign(double x, double y, double z)
    Get the sign of a point relative to a plane.
    double
    distanceToPlane(double x, double y, double z)
    Get the perpendicular distance for a point to the plane
    double
    dot(double x, double y, double z)
    Get the common construct a*x + b*y + c*z -d for the plane defined by ax + by + cz = d
    double[]
    infiniteLineIntersection(double[] p1, double[] p2)
    Compute the intersection of an infinite line with the plane
    static void
    main(String[] arg)
     
    double
    timeToPlane(double x, double y, double z, double vx, double vy, double vz)
    Given a current position and velocity, compute the time to intersect the plane

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Plane

      public Plane(double a, double b, double c, double d)
      Create a plane of the form ax + by + cz = d
      Parameters:
      a -
      b -
      c -
      d -
  • Method Details

    • createPlane

      public static Plane createPlane(double normX, double normY, double normZ, double d)
      Create a plane from a normal vector and a distance to the plane
      Parameters:
      normX - the x component of the normal vector
      normY - the y component of the normal vector
      normZ - the z component of the normal vector
      d - the d value of the plane ax + by + cz = d
      Returns:
      the plane that contains p and its normal is norm
    • createPlane

      public static Plane createPlane(double[] norm, double d)
      Create a plane from a normal vector and a distance to the plane
      Parameters:
      norm - the outward normal vector where the components (0, 1, 2) map to (x, y, z)
      d - the distance from the origin to the plane
      Returns:
      the plane that contains p and its normal is norm
    • createPlane

      public static Plane createPlane(double[] norm, double[] p)
      Create a plane from a normal vector and a point on the plane
      Parameters:
      norm - the normal vector where the components (0, 1, 2) map to (x, y, z)
      p - a point in the plane where the components (0, 1, 2) map to (x, y, z)
      Returns:
      the plane that contains p and its normal is norm
    • createTiltedPlane

      public static Plane createTiltedPlane(double d)
      Create a plane in the clas12 tilted system
      Parameters:
      d - the distance from the nominal target to the plane
      Returns:
      The plane
    • contained

      public boolean contained(double x, double y, double z, double tolerance)
      See if a point is contained (on) a plane
      Parameters:
      x - x coordinate
      y - y coordinate
      z - z coordinate
      tolerance - the maximum distance from the plane in the same units as the coordinates
      Returns:
    • distanceToPlane

      public double distanceToPlane(double x, double y, double z)
      Get the perpendicular distance for a point to the plane
      Parameters:
      x - the x coordinate of the point.
      y - the y coordinate of the point.
      z - the z coordinate of the point.
      Returns:
      the perpendicular distance
    • timeToPlane

      public double timeToPlane(double x, double y, double z, double vx, double vy, double vz)
      Given a current position and velocity, compute the time to intersect the plane
      Parameters:
      x - x coordinate
      y - y coordinate
      z - z coordinate
      vx - x component of velocity (arbitrary units)
      vy - y component of velocity
      vz - z component of velocity
      Returns:
      the time to intersect the plane
    • dot

      public double dot(double x, double y, double z)
      Get the common construct a*x + b*y + c*z -d for the plane defined by ax + by + cz = d
      Parameters:
      x -
      y -
      z -
      Returns:
    • infiniteLineIntersection

      public double[] infiniteLineIntersection(double[] p1, double[] p2)
      Compute the intersection of an infinite line with the plane
      Parameters:
      p1 - a point on the line where the components (0, 1, 2) map to (x, y, z)
      p2 - a point on the line where the components (0, 1, 2) map to (x, y, z)
      Returns:
      the intersection p where the components (0, 1, 2) map to (x, y, z). If there is no intersection, returns null.
    • directionSign

      public int directionSign(double x, double y, double z)
      Get the sign of a point relative to a plane. If it is -1 it is on one side of the plane (call it left). If it is +1 it is on the other. Thus you can determine when you cross the plane: when the sign changes.
      Parameters:
      x - the x coordinate of the point
      y - the y coordinate of the point
      z - the z coordinate of the point
      Returns:
      0 if the point is on (or almost on modulo TINY) the plane, -1 if it is on one side, + 1 if it is on the other.
    • constantPhiPlane

      public static Plane constantPhiPlane(double phi)
      Create a plane of constant azimuthal angle phi
      Parameters:
      phi - the azimuthal angle in degrees
      Returns:
      the plane of constant phi
    • main

      public static void main(String[] arg)