Class PathTriangle
java.lang.Object
com.marginallyclever.ro3.apps.pathtracer.PathTriangle
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPathTriangle
(javax.vecmath.Point3d a, javax.vecmath.Point3d b, javax.vecmath.Point3d c, javax.vecmath.Vector3d normal, javax.vecmath.Point2d tA, javax.vecmath.Point2d tB, javax.vecmath.Point2d tC) -
Method Summary
Modifier and TypeMethodDescriptiondouble
getArea()
double
getCentroidAxis
(int axis) Get the centroid of the triangle along a specific axis.javax.vecmath.Point3d
Get a random point inside the triangle using barycentric coordinates.javax.vecmath.Point2d
getUVAt
(javax.vecmath.Point3d point) Get the UV coordinates of the texture at a specific point on the triangle.double
intersectRay
(Ray ray) Test if a ray intersects this triangle.
-
Field Details
-
a
public final javax.vecmath.Point3d a -
b
public final javax.vecmath.Point3d b -
c
public final javax.vecmath.Point3d c -
tA
public final javax.vecmath.Point2d tA -
tB
public final javax.vecmath.Point2d tB -
tC
public final javax.vecmath.Point2d tC -
normal
public final javax.vecmath.Vector3d normal -
bounds
-
-
Constructor Details
-
PathTriangle
public PathTriangle(javax.vecmath.Point3d a, javax.vecmath.Point3d b, javax.vecmath.Point3d c, javax.vecmath.Vector3d normal, javax.vecmath.Point2d tA, javax.vecmath.Point2d tB, javax.vecmath.Point2d tC)
-
-
Method Details
-
getBounds
-
intersectRay
Test if a ray intersects this triangle.- Parameters:
ray
- the ray to test- Returns:
- the distance along the ray to the intersection point, or Double.MAX_VALUE if there is no intersection.
-
getRandomPointInside
public javax.vecmath.Point3d getRandomPointInside()Get a random point inside the triangle using barycentric coordinates.- Returns:
- a random point inside the triangle.
-
getArea
public double getArea() -
getUVAt
public javax.vecmath.Point2d getUVAt(javax.vecmath.Point3d point) Get the UV coordinates of the texture at a specific point on the triangle.- Parameters:
point
- the 3d world point of intersection with the triangle.- Returns:
- the UV coordinates of the texture at the point.
-
getCentroidAxis
public double getCentroidAxis(int axis) Get the centroid of the triangle along a specific axis.- Parameters:
axis
- the axis to get the centroid along (0 for x, 1 for y, or 2 for z)- Returns:
- the centroid coordinate along the specified axis
-