Class Shape3D

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

public class Shape3D extends Object implements Transformable, Showable
A collection of Face3D objects.

Faces can be added and retrieved via addFace(org.jlab.geom.prim.Face3D) and face(int).

The center of the shape can be calculated via center(), which returns the geometric mean of all of the points of all the faces contained in this shape.

The moveTo(org.jlab.geom.prim.Point3D) method translates this shape so that its center is at the given point.

Author:
gavalian
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    Constructs a new empty Shape3D.
    Shape3D(Face3D... faces)
    Constructs a new Shape3D from the given faces.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    void
    Adds the given face to this shape.
    static Shape3D
    box(double xd, double yd, double zd)
     
    Constructs a point center of the shape.
    face(int index)
    Returns the face corresponding to the given index.
     
    boolean
    Returns true if the infinite line intersects this shape.
    boolean
    Returns true if the ray intersects this shape.
    boolean
    Returns true if the line segment intersects this shape.
    int
    intersection(Line3D line, List<Point3D> intersections)
    Finds intersections of the given infinite line with this shape.
    int
    intersection_with_faces(Line3D line, List<Point3D> intersections, List<Integer> ifaces)
    Finds intersections of the given infinite line with this shape.
    int
    intersectionRay(Line3D line, List<Point3D> intersections)
    Finds intersections of the given ray with this shape.
    int
    intersectionSegment(Line3D line, List<Point3D> intersections)
    Finds intersections of the given line segment with this shape.
    void
    moveTo(double x, double y, double z)
    Translates this shape so that it's geometric center coincides with the given point at the given coordinates.
    void
    moveTo(Point3D point)
    Translates this shape so that it's geometric center coincides with the given point.
    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
    Invokes System.out.println(this).
    int
    Returns the number of faces in this shape.
     
    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

    • Shape3D Link icon

      public Shape3D()
      Constructs a new empty Shape3D.
    • Shape3D Link icon

      public Shape3D(Face3D... faces)
      Constructs a new Shape3D from the given faces. If any of the face are subsequently modified, then this shape will also be modified.
      Parameters:
      faces - the faces of of this shape
  • Method Details Link icon

    • addFace Link icon

      public void addFace(Face3D face)
      Adds the given face to this shape. If the face is subsequently modified, this shape will also be modified.
      Parameters:
      face - the face to add
    • face Link icon

      public Face3D face(int index)
      Returns the face corresponding to the given index.
      Parameters:
      index - the index of the face to get
      Returns:
      the face at the corresponding index or null if there is no such face
    • size Link icon

      public int size()
      Returns the number of faces in this shape.
      Returns:
      the number of faces in this shape
    • center Link icon

      public Point3D center()
      Constructs a point center of the shape. This point is at the geometric mean of every point in every face of the shape.
      Returns:
      a point at the geometric center of the shape, or a point at the origin if the shape has no faces
    • 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
    • moveTo Link icon

      public void moveTo(Point3D point)
      Translates this shape so that it's geometric center coincides with the given point.
      Parameters:
      point - the new position of the shape's center
    • moveTo Link icon

      public void moveTo(double x, double y, double z)
      Translates this shape so that it's geometric center coincides with the given point at the given coordinates.
      Parameters:
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
    • intersection Link icon

      public int intersection(Line3D line, List<Point3D> intersections)
      Finds intersections of the given infinite line with this shape. Intersection points will be appended to the given list.
      Parameters:
      line - the infinite line
      intersections - the list of intersections
      Returns:
      the number of intersections that were found
    • intersection_with_faces Link icon

      public int intersection_with_faces(Line3D line, List<Point3D> intersections, List<Integer> ifaces)
      Finds intersections of the given infinite line with this shape. Intersection points will be appended to the given list.
      Parameters:
      line - the infinite line
      intersections - the list of intersections
      Returns:
      the number of intersections that were found
    • intersectionRay Link icon

      public int intersectionRay(Line3D line, List<Point3D> intersections)
      Finds intersections of the given ray with this shape. Intersection points will be appended to the given list.
      Parameters:
      line - the ray
      intersections - the list of intersections
      Returns:
      the number of intersections that were found
    • intersectionSegment Link icon

      public int intersectionSegment(Line3D line, List<Point3D> intersections)
      Finds intersections of the given line segment with this shape. Intersection points will be appended to the given list.
      Parameters:
      line - the line segment
      intersections - the list of intersections
      Returns:
      the number of intersections that were found
    • hasIntersection Link icon

      public boolean hasIntersection(Line3D line)
      Returns true if the infinite line intersects this shape.
      Parameters:
      line - the infinite line
      Returns:
      true if the line intersects the shape
    • hasIntersectionRay Link icon

      public boolean hasIntersectionRay(Line3D line)
      Returns true if the ray intersects this shape.
      Parameters:
      line - the ray
      Returns:
      true if the line intersects the shape
    • hasIntersectionSegment Link icon

      public boolean hasIntersectionSegment(Line3D line)
      Returns true if the line segment intersects this shape.
      Parameters:
      line - the line segment
      Returns:
      true if the line intersects the shape
    • 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
    • box Link icon

      public static Shape3D box(double xd, double yd, double zd)
    • getMeshFXML Link icon

      public String getMeshFXML()