Package org.jlab.geom.prim
Class Shape3D
java.lang.Object
org.jlab.geom.prim.Shape3D
- All Implemented Interfaces:
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given face to this shape.static Shape3Dbox(double xd, double yd, double zd) center()Constructs a point center of the shape.face(int index) Returns the face corresponding to the given index.booleanhasIntersection(Line3D line) Returns true if the infinite line intersects this shape.booleanhasIntersectionRay(Line3D line) Returns true if the ray intersects this shape.booleanhasIntersectionSegment(Line3D line) Returns true if the line segment intersects this shape.intintersection(Line3D line, List<Point3D> intersections) Finds intersections of the given infinite line with this shape.intFinds intersections of the given infinite line with this shape.intintersectionRay(Line3D line, List<Point3D> intersections) Finds intersections of the given ray with this shape.intintersectionSegment(Line3D line, List<Point3D> intersections) Finds intersections of the given line segment with this shape.voidmoveTo(double x, double y, double z) Translates this shape so that it's geometric center coincides with the given point at the given coordinates.voidTranslates this shape so that it's geometric center coincides with the given point.voidrotateX(double angle) Rotates this object clockwise around the x axis.voidrotateY(double angle) Rotates this object clockwise around the y axis.voidrotateZ(double angle) Rotates this object clockwise around the z axis.voidshow()InvokesSystem.out.println(this).intsize()Returns the number of faces in this shape.toString()voidtranslateXYZ(double x, double y, double z) Translates this object linearly by the amounts specified.
-
Constructor Details
-
Shape3D
public Shape3D()Constructs a new emptyShape3D. -
Shape3D
Constructs a newShape3Dfrom 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
-
addFace
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
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
public int size()Returns the number of faces in this shape.- Returns:
- the number of faces in this shape
-
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
public void translateXYZ(double x, double y, double z) Description copied from interface:TransformableTranslates this object linearly by the amounts specified.- Specified by:
translateXYZin interfaceTransformable- Parameters:
x- amount to translate along the x axisy- amount to translate along the y axisz- amount to translate along the z axis
-
rotateX
public void rotateX(double angle) Description copied from interface:TransformableRotates this object clockwise around the x axis.- Specified by:
rotateXin interfaceTransformable- Parameters:
angle- rotation angle in radians
-
rotateY
public void rotateY(double angle) Description copied from interface:TransformableRotates this object clockwise around the y axis.- Specified by:
rotateYin interfaceTransformable- Parameters:
angle- rotation angle in radians
-
rotateZ
public void rotateZ(double angle) Description copied from interface:TransformableRotates this object clockwise around the z axis.- Specified by:
rotateZin interfaceTransformable- Parameters:
angle- rotation angle in radians
-
moveTo
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
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 coordinatey- the y coordinatez- the z coordinate
-
intersection
Finds intersections of the given infinite line with this shape. Intersection points will be appended to the given list.- Parameters:
line- the infinite lineintersections- the list of intersections- Returns:
- the number of intersections that were found
-
intersection_with_faces
Finds intersections of the given infinite line with this shape. Intersection points will be appended to the given list.- Parameters:
line- the infinite lineintersections- the list of intersections- Returns:
- the number of intersections that were found
-
intersectionRay
Finds intersections of the given ray with this shape. Intersection points will be appended to the given list.- Parameters:
line- the rayintersections- the list of intersections- Returns:
- the number of intersections that were found
-
intersectionSegment
Finds intersections of the given line segment with this shape. Intersection points will be appended to the given list.- Parameters:
line- the line segmentintersections- the list of intersections- Returns:
- the number of intersections that were found
-
hasIntersection
Returns true if the infinite line intersects this shape.- Parameters:
line- the infinite line- Returns:
- true if the line intersects the shape
-
hasIntersectionRay
Returns true if the ray intersects this shape.- Parameters:
line- the ray- Returns:
- true if the line intersects the shape
-
hasIntersectionSegment
Returns true if the line segment intersects this shape.- Parameters:
line- the line segment- Returns:
- true if the line intersects the shape
-
show
public void show()InvokesSystem.out.println(this). -
toString
-
box
-
getMeshFXML
-