Package org.jlab.geom.prim
Class Triangle3D
java.lang.Object
org.jlab.geom.prim.Triangle3D
- All Implemented Interfaces:
- Face3D,- Transformable,- Showable
A 3D triangle represented by three points.
 
 Since any three points in 3D space that are not collinear define a plane,
 a triangle can be converted into a plane via plane().
 
The normal of the surface of a triangle is oriented such that when looking antiparallel to the normal towards the triangle the triangle'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 triangle can be calculated using the
 intersection methods:
 intersection(...), 
 intersectionRay(...), 
 intersectionSegment(...).
- Author:
- gavalian
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a newTriangle3Dwith all three points at the origin.Triangle3D(double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2) Constructs a newTriangle3Dwith the points at the specified coordinates.Triangle3D(Point3D point0, Point3D point1, Point3D point2) Constructs a newTriangle3Dfrom the given points.Triangle3D(Triangle3D triangle) Constructs a newTriangle3Dwith its points coinciding with the points of the given triangle.
- 
Method SummaryModifier and TypeMethodDescriptioncenter()Constructs a newPoint3Dat the geometric mean of the three points in thisTriangle3D.voidcopy(Triangle3D triangle) Sets the points of thisTriangle3Dto coincide with points of the given triangle.doubleComputes the minimum distance of the given point from the edges of thisTriangle3D.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 inside the area of thisTriangle3D.normal()Constructs the unit vector normal to the plane of thisTriangle3D.plane()Constructs the the plane of thisTriangle3D.point(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) Sets the points of the triangle to coincide with the given coordinates.voidSets the points of thisTriangle3Dto 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- 
Triangle3Dpublic Triangle3D()Constructs a newTriangle3Dwith all three points at the origin.
- 
Triangle3Dpublic Triangle3D(double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2) Constructs a newTriangle3Dwith 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
 
- 
Triangle3DConstructs a newTriangle3Dfrom the given points.- Parameters:
- point0- the first point
- point1- the second point
- point2- the third point
 
- 
Triangle3DConstructs a newTriangle3Dwith its points coinciding with the points of the given triangle.- Parameters:
- triangle- the triangle to copy
 
 
- 
- 
Method Details- 
copySets the points of thisTriangle3Dto coincide with points of the given triangle.- Parameters:
- triangle- the triangle to copy
 
- 
setpublic void set(double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2) Sets the points of the triangle 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
 
- 
setSets the points of thisTriangle3Dto coincide with the given points.- Parameters:
- point0- the first point
- point1- the second point
- point2- the third point
 
- 
pointDescription copied from interface:Face3DReturns the point from thisFace3Dwith corresponding index. If an invalid index is given, then null is returned.
- 
centerConstructs a newPoint3Dat the geometric mean of the three points in thisTriangle3D.- Returns:
- the center of this Triangle3D
 
- 
normalConstructs the unit vector normal to the plane of thisTriangle3D.- Returns:
- the normal to the plane of this Triangle3D
 
- 
planeConstructs the the plane of thisTriangle3D.- Returns:
- the plane of this Triangle3D
 
- 
isInsideTest whether the given point is inside the area of thisTriangle3D.- Parameters:
- p- the given point
- Returns:
- true if inside or false if outside
 
- 
distanceFromEdgeComputes the minimum distance of the given point from the edges of thisTriangle3D.- Parameters:
- p- the given point
- Returns:
- the signed distance to the Triangle3Dedges, positive if inside or negative if outside
 
- 
intersectionDescription 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 interface- Face3D
- Parameters:
- line- the infinite line
- intersections- the list to store the intersections in
- Returns:
- the number of intersections found
 
- 
intersectionRayDescription 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 interface- Face3D
- Parameters:
- line- the ray
- intersections- the list to store the intersections in
- Returns:
- the number of intersections found
 
- 
intersectionSegmentDescription 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 interface- Face3D
- Parameters:
- line- the line segment
- intersections- the list to store the intersections in
- Returns:
- the number of intersections found
 
- 
translateXYZpublic void translateXYZ(double x, double y, double z) Description copied from interface:TransformableTranslates this object linearly by the amounts specified.- Specified by:
- translateXYZin 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
 
- 
rotateXpublic void rotateX(double angle) Description copied from interface:TransformableRotates this object clockwise around the x axis.- Specified by:
- rotateXin interface- Transformable
- Parameters:
- angle- rotation angle in radians
 
- 
rotateYpublic void rotateY(double angle) Description copied from interface:TransformableRotates this object clockwise around the y axis.- Specified by:
- rotateYin interface- Transformable
- Parameters:
- angle- rotation angle in radians
 
- 
rotateZpublic void rotateZ(double angle) Description copied from interface:TransformableRotates this object clockwise around the z axis.- Specified by:
- rotateZin interface- Transformable
- Parameters:
- angle- rotation angle in radians
 
- 
showpublic void show()InvokesSystem.out.println(this).
- 
toString
 
-