public class Triangle extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
Triangle.TriangleIntersection
Defines a line segment representing the intersection of a line with and in the plane of a triangle.
|
Constructor and Description |
---|
Triangle(Vec4 a,
Vec4 b,
Vec4 c)
Construct a triangle from three counter-clockwise ordered vertices.
|
Modifier and Type | Method and Description |
---|---|
protected static Triangle.TriangleIntersection |
compute_intervals_isectline(Vec4[] v,
double vv0,
double vv1,
double vv2,
double d0,
double d1,
double d2,
double d0d1,
double d0d2) |
boolean |
contains(Vec4 p)
Indicates whether a specified point is on the triangle.
|
protected static boolean |
coplanarTriangles(Vec4 n,
Vec4[] v,
Vec4[] u) |
protected static boolean |
edgeEdgeTest(double[] v0,
double[] u0,
double[] u1,
int i0,
int i1,
double ax,
double ay) |
static void |
expandTriangleFan(List<Integer> indices,
FloatBuffer inBuf,
FloatBuffer outBuf)
Expands a buffer of indexed triangle fan vertices to a buffer of non-indexed general-triangle vertices.
|
static void |
expandTriangleFan(List<Integer> indices,
IntBuffer outBuf) |
static void |
expandTriangles(List<Integer> indices,
FloatBuffer inBuf,
FloatBuffer outBuf)
Expands a buffer of indexed triangle vertices to a buffer of non-indexed triangle vertices.
|
static void |
expandTriangles(List<Integer> indices,
IntBuffer outBuf) |
static void |
expandTriangleStrip(List<Integer> indices,
FloatBuffer inBuf,
FloatBuffer outBuf)
Expands a buffer of indexed triangle strip vertices to a buffer of non-indexed general-triangle vertices.
|
static void |
expandTriangleStrip(List<Integer> indices,
IntBuffer outBuf) |
Vec4 |
getA()
Returns the first vertex.
|
Vec4 |
getB()
Returns the second vertex.
|
Vec4 |
getC()
Returns the third vertex.
|
Vec4 |
intersect(Line line)
Determine the intersection of the triangle with a specified line.
|
static Intersection |
intersect(Line line,
double vax,
double vay,
double vaz,
double vbx,
double vby,
double vbz,
double vcx,
double vcy,
double vcz)
Determines the intersection of a specified line with a triangle specified by individual coordinates.
|
static Intersection |
intersect(Line line,
Vec4 a,
Vec4 b,
Vec4 c)
Determines the intersection of a specified line with a specified triangle.
|
protected static Triangle.TriangleIntersection |
intersect(Vec4 v0,
Vec4 v1,
Vec4 v2,
double vv0,
double vv1,
double vv2,
double d0,
double d1,
double d2) |
static List<Intersection> |
intersectTriangles(Line line,
FloatBuffer vertices)
Compute the intersections of a line with a collection of triangles.
|
static List<Intersection> |
intersectTriangles(Line line,
FloatBuffer vertices,
IntBuffer indices)
Compute the intersections of a line with a collection of triangles.
|
static int |
intersectTriangles(Vec4[] v,
Vec4[] u,
Vec4[] intersectionVertices)
Intersects two triangles and returns their intersection vertices.
|
static List<Intersection> |
intersectTriangleTypes(Line line,
FloatBuffer vertices,
IntBuffer indices,
int triangleType)
Compute the intersections of a line with a triangle collection.
|
static List<Intersection> |
intersectTriFan(Line line,
FloatBuffer vertices,
IntBuffer indices)
Compute the intersections of a line with a triangle fan.
|
static List<Intersection> |
intersectTriFan(Line line,
Vec4[] vertices,
IntBuffer indices)
Compute the intersections of a line with a triangle fan.
|
static List<Intersection> |
intersectTriStrip(Line line,
FloatBuffer vertices,
IntBuffer indices)
Compute the intersections of a line with a triangle strip.
|
static List<Intersection> |
intersectTriStrip(Line line,
Vec4[] vertices,
IntBuffer indices)
Compute the intersections of a line with a triangle strip.
|
protected static boolean |
pointInTri(double[] v0,
double[] u0,
double[] u1,
double[] u2,
int i0,
int i1) |
String |
toString() |
protected static boolean |
triangleEdgeTest(double[] v0,
double[] v1,
double[] u0,
double[] u1,
double[] u2,
int i0,
int i1) |
public Triangle(Vec4 a, Vec4 b, Vec4 c)
a
- the first vertex.b
- the second vertex.c
- the third vertex.IllegalArgumentException
- if any vertex is null.protected static Triangle.TriangleIntersection compute_intervals_isectline(Vec4[] v, double vv0, double vv1, double vv2, double d0, double d1, double d2, double d0d1, double d0d2)
public boolean contains(Vec4 p)
p
- the point to test. If null, the method returns false.protected static boolean edgeEdgeTest(double[] v0, double[] u0, double[] u1, int i0, int i1, double ax, double ay)
public static void expandTriangleFan(List<Integer> indices, FloatBuffer inBuf, FloatBuffer outBuf)
indices
- the triangle indices.inBuf
- the vertex buffer the indices refer to, in the order x, y, z, x, y, z, ...outBuf
- the buffer in which to place the expanded triangle vertices. The buffer must have a limit
sufficient to hold the output vertices.IllegalArgumentException
- if the index list or the input or output buffer is null, or if the output buffer
size is insufficient.public static void expandTriangles(List<Integer> indices, FloatBuffer inBuf, FloatBuffer outBuf)
indices
- the triangle indices.inBuf
- the vertex buffer the indices refer to, in the order x, y, z, x, y, z, ...outBuf
- the buffer in which to place the expanded triangle vertices. The buffer must have a limit
sufficient to hold the output vertices.IllegalArgumentException
- if the index list or the input or output buffer is null, or if the output buffer
size is insufficient.public static void expandTriangleStrip(List<Integer> indices, FloatBuffer inBuf, FloatBuffer outBuf)
indices
- the triangle indices.inBuf
- the vertex buffer the indices refer to, in the order x, y, z, x, y, z, ...outBuf
- the buffer in which to place the expanded triangle vertices. The buffer must have a limit
sufficient to hold the output vertices.IllegalArgumentException
- if the index list or the input or output buffer is null, or if the output buffer
size is insufficient.public Vec4 getA()
public Vec4 getB()
public Vec4 getC()
public Vec4 intersect(Line line)
line
- the line to test.IllegalArgumentException
- if the line is null.public static Intersection intersect(Line line, double vax, double vay, double vaz, double vbx, double vby, double vbz, double vcx, double vcy, double vcz)
line
- the line to test.vax
- the X coordinate of the first vertex of the triangle.vay
- the Y coordinate of the first vertex of the triangle.vaz
- the Z coordinate of the first vertex of the triangle.vbx
- the X coordinate of the second vertex of the triangle.vby
- the Y coordinate of the second vertex of the triangle.vbz
- the Z coordinate of the second vertex of the triangle.vcx
- the X coordinate of the third vertex of the triangle.vcy
- the Y coordinate of the third vertex of the triangle.vcz
- the Z coordinate of the third vertex of the triangle.public static Intersection intersect(Line line, Vec4 a, Vec4 b, Vec4 c)
line
- the line to test.a
- the first vertex of the triangle.b
- the second vertex of the triangle.c
- the third vertex of the triangle.IllegalArgumentException
- if the line or any of the triangle vertices is null.protected static Triangle.TriangleIntersection intersect(Vec4 v0, Vec4 v1, Vec4 v2, double vv0, double vv1, double vv2, double d0, double d1, double d2)
public static List<Intersection> intersectTriangles(Line line, FloatBuffer vertices)
line
- the line to intersect.vertices
- the triangles, arranged in a buffer as GL_TRIANGLES (9 floats per triangle).IllegalArgumentException
- if the line or vertex buffer is null.public static List<Intersection> intersectTriangles(Line line, FloatBuffer vertices, IntBuffer indices)
line
- the line to intersect.vertices
- the triangles, arranged in a buffer as GL_TRIANGLES (9 floats per triangle).indices
- the indices forming the triangles.IllegalArgumentException
- if the line, vertex buffer or index buffer is null.public static int intersectTriangles(Vec4[] v, Vec4[] u, Vec4[] intersectionVertices)
v
- the Cartesian coordinates of the first triangle.u
- the Cartesian coordinates of the second triangle.intersectionVertices
- a pre-allocated two-element array in which the intersection vertices, if any, are
returned.public static List<Intersection> intersectTriangleTypes(Line line, FloatBuffer vertices, IntBuffer indices, int triangleType)
line
- the line to intersect.vertices
- the tri-fan vertices, in the order x, y, z, x, y, z, ...indices
- the indices forming the tri-fan.triangleType
- the type of triangle collection, either GL.GL_TRIANGLE_STRIP or GL.GL_TRIANGLE_FAN.public static List<Intersection> intersectTriFan(Line line, FloatBuffer vertices, IntBuffer indices)
line
- the line to intersect.vertices
- the tri-fan vertices.indices
- the indices forming the tri-fan.IllegalArgumentException
- if the line, vertex buffer or index buffer is null.public static List<Intersection> intersectTriFan(Line line, Vec4[] vertices, IntBuffer indices)
line
- the line to intersect.vertices
- the tri-fan vertices.indices
- the indices forming the tri-fan.IllegalArgumentException
- if the line, vertex array or index buffer is null.public static List<Intersection> intersectTriStrip(Line line, FloatBuffer vertices, IntBuffer indices)
line
- the line to intersect.vertices
- the tri-strip vertices.indices
- the indices forming the tri-strip.IllegalArgumentException
- if the line, vertex buffer or index buffer is null.public static List<Intersection> intersectTriStrip(Line line, Vec4[] vertices, IntBuffer indices)
line
- the line to intersect.vertices
- the tri-strip vertices.indices
- the indices forming the tri-strip.IllegalArgumentException
- if the line, vertex array or index buffer is null.protected static boolean pointInTri(double[] v0, double[] u0, double[] u1, double[] u2, int i0, int i1)
protected static boolean triangleEdgeTest(double[] v0, double[] v1, double[] u0, double[] u1, double[] u2, int i0, int i1)