Package org.jlab.geom.prim
Class Trap3D
java.lang.Object
org.jlab.geom.prim.Trap3D
- All Implemented Interfaces:
Face3D,Transformable,Showable
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
ConstructorsConstructorDescriptionTrap3D()Constructs a newTrap3Dwith 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 newTrap3Dwith the points at the specified coordinates.Constructs a newTrap3Dfrom the given points.Constructs a newTrap3Dwith its points coinciding with the points of the given Trap. -
Method Summary
Modifier and TypeMethodDescriptioncenter()Constructs a newPoint3Dat the geometric mean of the four points in thisTrap3D.voidSets the points of thisTrap3Dto coincide with points of the given Trap.doubleComputes the minimum distance of the given point from the edges of thisTrap3D.intintersection(Line3D line, List<Point3D> intersections) Finds the intersections of the given infinite line with thisFace3D.intintersectionRay(Line3D line, List<Point3D> intersections) Finds the intersections of the given ray with thisFace3D.intintersectionSegment(Line3D line, List<Point3D> intersections) Finds the intersections of the given line segment with thisFace3D.booleanTest whether the given point is in the trapezoid planebooleanTest whether the given point is inside the area of thisTrap3D.booleanisPlanar()Check trapezoid planaritynormal()Constructs the normal vector to the trapezoid plane, defined from the first three pointsplane()Constructs the plane representing the trapezoid surfacepoint(int index) Returns the point from thisFace3Dwith corresponding index.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.voidset(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.voidSets the points of thisTrap3Dto coincide with the given points.voidshow()InvokesSystem.out.println(this).toString()voidtranslateXYZ(double x, double y, double z) Translates this object linearly by the amounts specified.
-
Constructor Details
-
Trap3D
public Trap3D()Constructs a newTrap3Dwith all three points at the origin. -
Trap3D
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 newTrap3Dwith the points at the specified coordinates.- Parameters:
x0- x coordinate of the first pointy0- y coordinate of the first pointz0- z coordinate of the first pointx1- x coordinate of the second pointy1- y coordinate of the second pointz1- z coordinate of the second pointx2- x coordinate of the third pointy2- y coordinate of the third pointz2- z coordinate of the third pointx3- x coordinate of the fourth pointy3- y coordinate of the fourth pointz3- z coordinate of the fourth point
-
Trap3D
Constructs a newTrap3Dfrom the given points.- Parameters:
point0- the first pointpoint1- the second pointpoint2- the third pointpoint3- the fourth point
-
Trap3D
Constructs a newTrap3Dwith its points coinciding with the points of the given Trap.- Parameters:
Trap- the Trap to copy
-
-
Method Details
-
copy
Sets the points of thisTrap3Dto coincide with points of the given Trap.- Parameters:
Trap- the Trap to copy
-
set
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 pointy0- y coordinate of the first pointz0- z coordinate of the first pointx1- x coordinate of the second pointy1- y coordinate of the second pointz1- z coordinate of the second pointx2- x coordinate of the third pointy2- y coordinate of the third pointz2- z coordinate of the third pointx3- x coordinate of the fourth pointy3- y coordinate of the fourth pointz3- z coordinate of the fourth point
-
set
Sets the points of thisTrap3Dto coincide with the given points.- Parameters:
point0- the first pointpoint1- the second pointpoint2- the third pointpoint3- the fourth point
-
isPlanar
public boolean isPlanar()Check trapezoid planarity- Returns:
- true if the four points are on a plane, false otherwise
-
point
Description copied from interface:Face3DReturns the point from thisFace3Dwith corresponding index. If an invalid index is given, then null is returned. -
center
Constructs a newPoint3Dat the geometric mean of the four points in thisTrap3D.- Returns:
- the center of this
Trap3D
-
normal
Constructs the normal vector to the trapezoid plane, defined from the first three points- Returns:
- unit vector
Trap3D
-
plane
Constructs the plane representing the trapezoid surface- Returns:
- the plane of this
Trap3D
-
isInPlane
Test whether the given point is in the trapezoid plane- Parameters:
p- the given point- Returns:
- true or false
Trap3D
-
isInside
Test whether the given point is inside the area of thisTrap3D.- Parameters:
p- the given point- Returns:
- true if inside or false if outside
-
distanceFromEdge
Computes the minimum distance of the given point from the edges of thisTrap3D.- Parameters:
p- the given point- Returns:
- the signed distance to the
Trap3Dedges, positive if inside or negative if outside
-
intersection
Description copied from interface:Face3DFinds the intersections of the given infinite line with thisFace3D. 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:
intersectionin interfaceFace3D- Parameters:
line- the infinite lineintersections- the list to store the intersections in- Returns:
- the number of intersections found
-
intersectionRay
Description copied from interface:Face3DFinds the intersections of the given ray with thisFace3D. 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:
intersectionRayin interfaceFace3D- Parameters:
line- the rayintersections- the list to store the intersections in- Returns:
- the number of intersections found
-
intersectionSegment
Description copied from interface:Face3DFinds the intersections of the given line segment with thisFace3D. 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:
intersectionSegmentin interfaceFace3D- Parameters:
line- the line segmentintersections- the list to store the intersections in- Returns:
- the number of intersections found
-
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
-
show
public void show()InvokesSystem.out.println(this). -
toString
-