Class Trap3D

java.lang.Object
org.jlab.geom.prim.Trap3D
All Implemented Interfaces:
Face3D, Transformable, Showable

public final class Trap3D extends Object implements Face3D
A 3D trapezoid represented by four points laying on the same plane.

The normal of the surface of a trapezoid is oriented such that when looking antiparallel to the normal towards the trapezoid the Trap's points wound counterclockwise. Conversely, when looking in a direction parallel to the normal, the points are wound in a clockwise fashion.

The intersection of a line with a trapezoid can be calculated using the intersection methods: intersection(...), intersectionRay(...), intersectionSegment(...).

Author:
devita
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    Constructs a new Trap3D with all three points at the origin.
    Trap3D(double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3)
    Constructs a new Trap3D with the points at the specified coordinates.
    Trap3D(Point3D point0, Point3D point1, Point3D point2, Point3D point3)
    Constructs a new Trap3D from the given points.
    Trap3D(Trap3D Trap)
    Constructs a new Trap3D with its points coinciding with the points of the given Trap.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    Constructs a new Point3D at the geometric mean of the four points in this Trap3D.
    void
    copy(Trap3D Trap)
    Sets the points of this Trap3D to coincide with points of the given Trap.
    double
    Computes the minimum distance of the given point from the edges of this Trap3D.
    int
    intersection(Line3D line, List<Point3D> intersections)
    Finds the intersections of the given infinite line with this Face3D.
    int
    intersectionRay(Line3D line, List<Point3D> intersections)
    Finds the intersections of the given ray with this Face3D.
    int
    intersectionSegment(Line3D line, List<Point3D> intersections)
    Finds the intersections of the given line segment with this Face3D.
    boolean
    Test whether the given point is in the trapezoid plane
    boolean
    Test whether the given point is inside the area of this Trap3D.
    boolean
    Check trapezoid planarity
    Constructs the normal vector to the trapezoid plane, defined from the first three points
    Constructs the plane representing the trapezoid surface
    point(int index)
    Returns the point from this Face3D with corresponding index.
    void
    rotateX(double angle)
    Rotates this object clockwise around the x axis.
    void
    rotateY(double angle)
    Rotates this object clockwise around the y axis.
    void
    rotateZ(double angle)
    Rotates this object clockwise around the z axis.
    void
    set(double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3)
    Sets the points of the Trap to coincide with the given coordinates.
    void
    set(Point3D point0, Point3D point1, Point3D point2, Point3D point3)
    Sets the points of this Trap3D to coincide with the given points.
    void
    Invokes System.out.println(this).
     
    void
    translateXYZ(double x, double y, double z)
    Translates this object linearly by the amounts specified.

    Methods inherited from class java.lang.Object Link icon

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

    • Trap3D Link icon

      public Trap3D()
      Constructs a new Trap3D with all three points at the origin.
    • Trap3D Link icon

      public Trap3D(double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3)
      Constructs a new Trap3D with the points at the specified coordinates.
      Parameters:
      x0 - x coordinate of the first point
      y0 - y coordinate of the first point
      z0 - z coordinate of the first point
      x1 - x coordinate of the second point
      y1 - y coordinate of the second point
      z1 - z coordinate of the second point
      x2 - x coordinate of the third point
      y2 - y coordinate of the third point
      z2 - z coordinate of the third point
      x3 - x coordinate of the fourth point
      y3 - y coordinate of the fourth point
      z3 - z coordinate of the fourth point
    • Trap3D Link icon

      public Trap3D(Point3D point0, Point3D point1, Point3D point2, Point3D point3)
      Constructs a new Trap3D from the given points.
      Parameters:
      point0 - the first point
      point1 - the second point
      point2 - the third point
      point3 - the fourth point
    • Trap3D Link icon

      public Trap3D(Trap3D Trap)
      Constructs a new Trap3D with its points coinciding with the points of the given Trap.
      Parameters:
      Trap - the Trap to copy
  • Method Details Link icon

    • copy Link icon

      public void copy(Trap3D Trap)
      Sets the points of this Trap3D to coincide with points of the given Trap.
      Parameters:
      Trap - the Trap to copy
    • set Link icon

      public void set(double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3)
      Sets the points of the Trap to coincide with the given coordinates.
      Parameters:
      x0 - x coordinate of the first point
      y0 - y coordinate of the first point
      z0 - z coordinate of the first point
      x1 - x coordinate of the second point
      y1 - y coordinate of the second point
      z1 - z coordinate of the second point
      x2 - x coordinate of the third point
      y2 - y coordinate of the third point
      z2 - z coordinate of the third point
      x3 - x coordinate of the fourth point
      y3 - y coordinate of the fourth point
      z3 - z coordinate of the fourth point
    • set Link icon

      public void set(Point3D point0, Point3D point1, Point3D point2, Point3D point3)
      Sets the points of this Trap3D to coincide with the given points.
      Parameters:
      point0 - the first point
      point1 - the second point
      point2 - the third point
      point3 - the fourth point
    • isPlanar Link icon

      public boolean isPlanar()
      Check trapezoid planarity
      Returns:
      true if the four points are on a plane, false otherwise
    • point Link icon

      public Point3D point(int index)
      Description copied from interface: Face3D
      Returns the point from this Face3D with corresponding index. If an invalid index is given, then null is returned.
      Specified by:
      point in interface Face3D
      Parameters:
      index - index of the point
      Returns:
      the point at the corresponding index, otherwise null
    • center Link icon

      public Point3D center()
      Constructs a new Point3D at the geometric mean of the four points in this Trap3D.
      Returns:
      the center of this Trap3D
    • normal Link icon

      public Vector3D normal()
      Constructs the normal vector to the trapezoid plane, defined from the first three points
      Returns:
      unit vector Trap3D
    • plane Link icon

      public Plane3D plane()
      Constructs the plane representing the trapezoid surface
      Returns:
      the plane of this Trap3D
    • isInPlane Link icon

      public boolean isInPlane(Point3D p)
      Test whether the given point is in the trapezoid plane
      Parameters:
      p - the given point
      Returns:
      true or false Trap3D
    • isInside Link icon

      public boolean isInside(Point3D p)
      Test whether the given point is inside the area of this Trap3D.
      Parameters:
      p - the given point
      Returns:
      true if inside or false if outside
    • distanceFromEdge Link icon

      public double distanceFromEdge(Point3D p)
      Computes the minimum distance of the given point from the edges of this Trap3D.
      Parameters:
      p - the given point
      Returns:
      the signed distance to the Trap3D edges, positive if inside or negative if outside
    • intersection Link icon

      public int intersection(Line3D line, List<Point3D> intersections)
      Description copied from interface: Face3D
      Finds the intersections of the given infinite line with this Face3D. If intersections are found they will be appended to the given list. The return value will indicate the number of intersections that were found.
      Specified by:
      intersection in interface Face3D
      Parameters:
      line - the infinite line
      intersections - the list to store the intersections in
      Returns:
      the number of intersections found
    • intersectionRay Link icon

      public int intersectionRay(Line3D line, List<Point3D> intersections)
      Description copied from interface: Face3D
      Finds the intersections of the given ray with this Face3D. If intersections are found they will be appended to the given list. The return value will indicate the number of intersections that were found.
      Specified by:
      intersectionRay in interface Face3D
      Parameters:
      line - the ray
      intersections - the list to store the intersections in
      Returns:
      the number of intersections found
    • intersectionSegment Link icon

      public int intersectionSegment(Line3D line, List<Point3D> intersections)
      Description copied from interface: Face3D
      Finds the intersections of the given line segment with this Face3D. If intersections are found they will be appended to the given list. The return value will indicate the number of intersections that were found.
      Specified by:
      intersectionSegment in interface Face3D
      Parameters:
      line - the line segment
      intersections - the list to store the intersections in
      Returns:
      the number of intersections found
    • translateXYZ Link icon

      public void translateXYZ(double x, double y, double z)
      Description copied from interface: Transformable
      Translates this object linearly by the amounts specified.
      Specified by:
      translateXYZ in interface Transformable
      Parameters:
      x - amount to translate along the x axis
      y - amount to translate along the y axis
      z - amount to translate along the z axis
    • rotateX Link icon

      public void rotateX(double angle)
      Description copied from interface: Transformable
      Rotates this object clockwise around the x axis.
      Specified by:
      rotateX in interface Transformable
      Parameters:
      angle - rotation angle in radians
    • rotateY Link icon

      public void rotateY(double angle)
      Description copied from interface: Transformable
      Rotates this object clockwise around the y axis.
      Specified by:
      rotateY in interface Transformable
      Parameters:
      angle - rotation angle in radians
    • rotateZ Link icon

      public void rotateZ(double angle)
      Description copied from interface: Transformable
      Rotates this object clockwise around the z axis.
      Specified by:
      rotateZ in interface Transformable
      Parameters:
      angle - rotation angle in radians
    • show Link icon

      public void show()
      Invokes System.out.println(this).
      Specified by:
      show in interface Showable
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object