Package mgui.geometry
Class Triangle3D
java.lang.Object
mgui.geometry.Shape3D
mgui.geometry.Triangle3D
public class Triangle3D extends Shape3D
Represents a 3D triangle.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Nested Class Summary
Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType -
Field Summary
Fields Modifier and Type Field Description org.jogamp.vecmath.Point3fAorg.jogamp.vecmath.Point3fBorg.jogamp.vecmath.Point3fCFields inherited from class mgui.geometry.Shape3D
xml_count, xml_current_block, xml_encoding, xml_itr, xml_vertices -
Constructor Summary
Constructors Constructor Description Triangle3D()Triangle3D(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2, org.jogamp.vecmath.Point3f p3) -
Method Summary
Modifier and Type Method Description booleancontains(org.jogamp.vecmath.Point3f p)Determines whetherpis contained by this triangle.float[]getAngles()Returns face angles as an array ordered by: ∠A, ∠B, ∠Cfloat[]getCoords()float[]getEdgeLengths()Returns edge lengths as an array ordered by: |AB|,|BC|,|AC|.org.jogamp.vecmath.Vector3f[]getEdges()Returns edges as an array of vectors ordered by: AB,BC,CA.Plane3DgetPlane()org.jogamp.vecmath.Point3fgetVertex(int i)Returns the vertex at the specified index as aPoint3f.java.util.ArrayList<org.jogamp.vecmath.Point3f>getVertices()Returns a list of this shape's nodes asPoint3f's.voidsetCoords(float[] coords)voidsetVertices(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes)java.lang.StringtoString()Methods inherited from class mgui.geometry.Shape3D
clone, getBoundBox, getCenter, getDTD, getLocalName, getProximity, getProximityPoint, getShortXML, getSize, getXML, getXML, getXMLSchema, handleXMLElementEnd, handleXMLElementStart, handleXMLString, loadAsciiCoords, loadBinaryCoords, loadCoords, loadXMLCoord, setVertices, transform, transform, writeAsciiCoords, writeBinaryCoords, writeCoords, writeXML, writeXML, writeXMLMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
A
public org.jogamp.vecmath.Point3f A -
B
public org.jogamp.vecmath.Point3f B -
C
public org.jogamp.vecmath.Point3f C
-
-
Constructor Details
-
Triangle3D
public Triangle3D() -
Triangle3D
public Triangle3D(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2, org.jogamp.vecmath.Point3f p3)
-
-
Method Details
-
getPlane
-
getVertices
public java.util.ArrayList<org.jogamp.vecmath.Point3f> getVertices()Description copied from class:Shape3DReturns a list of this shape's nodes asPoint3f's. This list is a copy, so operations performed on these nodes will not affect this shape.- Specified by:
getVerticesin classShape3D- Returns:
-
getEdgeLengths
public float[] getEdgeLengths()Returns edge lengths as an array ordered by: |AB|,|BC|,|AC|.- Returns:
-
getAngles
public float[] getAngles()Returns face angles as an array ordered by: ∠A, ∠B, ∠C- Returns:
-
getEdges
public org.jogamp.vecmath.Vector3f[] getEdges()Returns edges as an array of vectors ordered by: AB,BC,CA.- Returns:
-
getVertex
public org.jogamp.vecmath.Point3f getVertex(int i)Description copied from class:Shape3DReturns the vertex at the specified index as aPoint3f. This vertex is a copy, so operations performed on it will not affect this shape.Note: subclasses may want to provide a more efficient implementation of this method.
-
contains
public boolean contains(org.jogamp.vecmath.Point3f p)Determines whetherpis contained by this triangle. Assumes thatpis conplanar with this triangle. From http://www.blackpawn.com/texts/pointinpoly/default.html: function SameSide(p1,p2, a,b) cp1 = CrossProduct(b-a, p1-a) cp2 = CrossProduct(b-a, p2-a) if DotProduct(cp1, cp2) >= 0 then return true else return false function PointInTriangle(p, a,b,c) if SameSide(p,a, b,c) and SameSide(p,b, a,c) and SameSide(p,c, a,b) then return true else return false -
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
getCoords
public float[] getCoords() -
setCoords
public void setCoords(float[] coords) -
setVertices
public void setVertices(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes)- Specified by:
setVerticesin classShape3D
-