Class Plane

java.lang.Object
cz.fidentis.analyst.data.shapes.Plane
All Implemented Interfaces:
Serializable

public class Plane extends Object implements Serializable
Immutable symmetry plane.
See Also:
  • Constructor Summary Link icon

    Constructors
    Modifier
    Constructor
    Description
    protected
    Plane(double distance)
     
     
    Plane(Plane plane)
    Copy constructor without normalization.
     
    Plane(Plane plane, boolean normalize)
    Copy constructor with possible normalization.
     
    Plane(List<Plane> planes)
    Creates average plane from existing planes.
     
    Plane(javax.vecmath.Point3d p1, javax.vecmath.Point3d p2, javax.vecmath.Point3d p3)
    Construction from three points.
     
    Plane(javax.vecmath.Tuple3d point)
    Construction from a 3D point.
     
    Plane(javax.vecmath.Tuple3d normal, double dist)
    Constructor.
     
    Plane(javax.vecmath.Tuple3d point1, javax.vecmath.Tuple3d point2)
    Symmetry plane constructed from two points.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    boolean
     
    Returns a plane with flipped direction
    javax.vecmath.Matrix4d
    getAlignmentMatrix(Plane other, boolean forbidRotation)
    Computes and returns transformation matrix that transforms given plane into this plane.
    double
     
    protected javax.vecmath.Vector3d
    Returns a normalized vector laying on the plane and directing ahead (toward the plus Z axis).
    javax.vecmath.Point3d
    getIntersectionWithLine(javax.vecmath.Point3d p1, javax.vecmath.Point3d p2)
    Calculates an intersection of a plane and a line given by two points
    getMesh(Box bbox)
    Returns rectangular mesh facet of this symmetry plane.
    getMesh(javax.vecmath.Point3d point, double width, double height)
    Returns rectangular mesh facet of this symmetry plane.
    javax.vecmath.Vector3d
    Returns reference to the normal vector
    javax.vecmath.Point3d
    Returns a point laying at the plane
    double
    getPointDistance(javax.vecmath.Point3d point)
    Returns distance of the point from the plane.
    protected javax.vecmath.Vector3d
    Returns a normalized vector laying on the plane and directing right (toward the plus X axis).
    protected static javax.vecmath.Matrix4d
    getRotationAroundAxis(javax.vecmath.Vector3d targetV, javax.vecmath.Vector3d trV, javax.vecmath.Vector3d axis)
    Computes transformation matrix that rotates the given normal vector so that it fits our normal vector.
    protected javax.vecmath.Vector3d
    Returns a normalized vector laying on the plane and directing up (toward the plus Y axis).
    int
     
    javax.vecmath.Point3d
    projectToPlane(javax.vecmath.Point3d point)
    Returns a point laying on the plane.
    javax.vecmath.Point3d
    reflectPointOverPlane(javax.vecmath.Point3d point)
    Returns a point laying on the opposite side of the plane ("mirrors" the point).
    javax.vecmath.Vector3d
    reflectUnitVectorOverPlane(javax.vecmath.Vector3d vector)
    Reflects the give unit vector over this plane.
    void
    Rotates plane over Y axis by 90 degrees.
    void
    Rotates plane over Z axis by 90 degrees.
    protected final void
    setNormal(javax.vecmath.Tuple3d normal)
    Changes the normal vector.
    shift(double value)
    Translate the plane along its normal
    Returns string description of the plane

    Methods inherited from class java.lang.Object Link icon

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details Link icon

    • Plane Link icon

      public Plane(javax.vecmath.Tuple3d normal, double dist)
      Constructor.
      Parameters:
      normal - Normalized (!) normal vector of the plane
      dist - distance
      Throws:
      IllegalArgumentException - if the @code{plane} argument is null
    • Plane Link icon

      public Plane(Plane plane, boolean normalize)
      Copy constructor with possible normalization.
      Parameters:
      plane - original plane
      normalize - normalize the normal vector and distance
      Throws:
      IllegalArgumentException - if the @code{plane} argument is null
    • Plane Link icon

      public Plane(Plane plane)
      Copy constructor without normalization.
      Parameters:
      plane - original plane
      Throws:
      IllegalArgumentException - if the @code{plane} argument is null
    • Plane Link icon

      public Plane(javax.vecmath.Tuple3d point)
      Construction from a 3D point.
      Parameters:
      point - point in space
      Throws:
      IllegalArgumentException - if the @code{plane} argument is null
    • Plane Link icon

      public Plane(javax.vecmath.Tuple3d point1, javax.vecmath.Tuple3d point2)
      Symmetry plane constructed from two points.
      Parameters:
      point1 - point in space
      point2 - point in space
      Throws:
      IllegalArgumentException - if the @code{plane} argument is null
    • Plane Link icon

      public Plane(javax.vecmath.Point3d p1, javax.vecmath.Point3d p2, javax.vecmath.Point3d p3)
      Construction from three points.
      Parameters:
      p1 - A first point from the plane
      p2 - A second point from the plane
      p3 - A third point from the plane
      Throws:
      NullPointerException - if some point is missing
    • Plane Link icon

      public Plane(List<Plane> planes)
      Creates average plane from existing planes.
      Parameters:
      planes - Source planes, at leas two
      Throws:
      IllegalArgumentException - if the planes list is null or empty
    • Plane Link icon

      protected Plane(double distance)
  • Method Details Link icon

    • hashCode Link icon

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals Link icon

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString Link icon

      public String toString()
      Returns string description of the plane
      Overrides:
      toString in class Object
      Returns:
      description of the plane
    • getDistance Link icon

      public double getDistance()
    • getPlanePoint Link icon

      public javax.vecmath.Point3d getPlanePoint()
      Returns a point laying at the plane
      Returns:
      a point laying at the plane
    • getUpPlanarVector Link icon

      protected javax.vecmath.Vector3d getUpPlanarVector()
      Returns a normalized vector laying on the plane and directing up (toward the plus Y axis).
      Returns:
      a normalized vector laying on the plane and directing up (toward the plus Y axis) or null
    • getRightPlanarVector Link icon

      protected javax.vecmath.Vector3d getRightPlanarVector()
      Returns a normalized vector laying on the plane and directing right (toward the plus X axis).
      Returns:
      a normalized vector laying on the plane and directing up (toward the plus X axis) or null
    • getFrontPlanarVector Link icon

      protected javax.vecmath.Vector3d getFrontPlanarVector()
      Returns a normalized vector laying on the plane and directing ahead (toward the plus Z axis).
      Returns:
      a normalized vector laying on the plane and directing ahead (toward the plus Z axis) or null
    • shift Link icon

      public Plane shift(double value)
      Translate the plane along its normal
      Parameters:
      value - a value to be added to the current plane's distance value
      Returns:
      shifted plane
    • flip Link icon

      public Plane flip()
      Returns a plane with flipped direction
      Returns:
      a plane with flipped direction
    • getAlignmentMatrix Link icon

      public javax.vecmath.Matrix4d getAlignmentMatrix(Plane other, boolean forbidRotation)
      Computes and returns transformation matrix that transforms given plane into this plane.
      Parameters:
      other - plane to be transformed
      forbidRotation - If false, then the rotation around the normal is ignored.
      Returns:
      transformation matrix or null
    • projectToPlane Link icon

      public javax.vecmath.Point3d projectToPlane(javax.vecmath.Point3d point)
      Returns a point laying on the plane.
      Parameters:
      point - A 3D point, which is projected to the plane
      Returns:
      a point laying on the plane.
      Throws:
      NullPointerException - if the point is null
    • reflectPointOverPlane Link icon

      public javax.vecmath.Point3d reflectPointOverPlane(javax.vecmath.Point3d point)
      Returns a point laying on the opposite side of the plane ("mirrors" the point).
      Parameters:
      point - A 3D point to be reflected
      Returns:
      a point on the opposite side of the plane.
      Throws:
      NullPointerException - if the point is null
    • reflectUnitVectorOverPlane Link icon

      public javax.vecmath.Vector3d reflectUnitVectorOverPlane(javax.vecmath.Vector3d vector)
      Reflects the give unit vector over this plane.
      Parameters:
      vector - A normalized 3D vector
      Returns:
      reflected vector
      Throws:
      NullPointerException - if the point is null
    • getMesh Link icon

      public MeshFacet getMesh(javax.vecmath.Point3d point, double width, double height)
      Returns rectangular mesh facet of this symmetry plane.
      Parameters:
      point - A 3D point, which is projected to the plane and used as a center of the rectangular facet
      width - Width
      height - Height
      Returns:
      a rectangular mesh facet of this symmetry plane
      Throws:
      NullPointerException - if the point is null
      IllegalArgumentException - if width or height are <= 0
    • getMesh Link icon

      public MeshFacet getMesh(Box bbox)
      Returns rectangular mesh facet of this symmetry plane. The centroid and size are estimated from bounding box.
      Parameters:
      bbox - Bounding box
      Returns:
      a rectangular mesh facet of this symmetry plane
      Throws:
      NullPointerException - if the midPoint or bbox are null
    • getNormal Link icon

      public javax.vecmath.Vector3d getNormal()
      Returns reference to the normal vector
      Returns:
      reference to the normal vector
    • setNormal Link icon

      protected final void setNormal(javax.vecmath.Tuple3d normal)
      Changes the normal vector.
      Parameters:
      normal - new normalized normal vector
      Throws:
      IllegalArgumentException - if the normal is null or if length is not one.
    • getPointDistance Link icon

      public double getPointDistance(javax.vecmath.Point3d point)
      Returns distance of the point from the plane.
      Parameters:
      point - Point whose distance is to be computed
      Returns:
      Point's distance. If the point is on the opposite side with the respect to the plane's normal, the negative distance is returned
    • getIntersectionWithLine Link icon

      public javax.vecmath.Point3d getIntersectionWithLine(javax.vecmath.Point3d p1, javax.vecmath.Point3d p2)
      Calculates an intersection of a plane and a line given by two points
      Parameters:
      p1 - first point of the line
      p2 - second point of the line
      Returns:
      The point of intersection of null if no point found
    • getRotationAroundAxis Link icon

      protected static javax.vecmath.Matrix4d getRotationAroundAxis(javax.vecmath.Vector3d targetV, javax.vecmath.Vector3d trV, javax.vecmath.Vector3d axis)
      Computes transformation matrix that rotates the given normal vector so that it fits our normal vector. Based on https://math.stackexchange.com/questions/180418/calculate-rotation-matrix-to-align-vector-a-to-vector-b-in-3d
      Parameters:
      targetV - Vector towards which we want to rotate the second vector
      trV - Vector to be rotated
      axis - Rotation axis. If null, then it's automatically computed
      Returns:
      transformation matrix
    • rotateOverZ Link icon

      public void rotateOverZ()
      Rotates plane over Z axis by 90 degrees.
    • rotateOverY Link icon

      public void rotateOverY()
      Rotates plane over Y axis by 90 degrees.