Package mgui.geometry
Class Triangle2D
java.lang.Object
mgui.geometry.Shape2D
mgui.geometry.Triangle2D
public class Triangle2D extends Shape2D
Represents a 2D 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
-
Constructor Summary
Constructors Constructor Description Triangle2D()
Triangle2D(java.util.ArrayList<org.jogamp.vecmath.Point2f> nodes)
Triangle2D(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2, org.jogamp.vecmath.Point2f p3)
-
Method Summary
Modifier and Type Method Description boolean
contains(org.jogamp.vecmath.Point2f p)
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 falseorg.jogamp.vecmath.Point2f
getVertex(int i)
java.util.ArrayList<org.jogamp.vecmath.Point2f>
getVertices()
void
setVertices(java.util.ArrayList<org.jogamp.vecmath.Point2f> vertices)
Methods inherited from class mgui.geometry.Shape2D
clone, getBounds, getCenterPt, getCoords, getDTD, getLocalName, getProximity, getProximityPoint, getShortXML, getSize, getVertices, getXML, getXML, getXMLSchema, handleXMLElementEnd, handleXMLElementStart, handleXMLString, setCoords, setVertices, transform, transform, writeXML, writeXML, writeXML
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Triangle2D
public Triangle2D() -
Triangle2D
public Triangle2D(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2, org.jogamp.vecmath.Point2f p3) -
Triangle2D
public Triangle2D(java.util.ArrayList<org.jogamp.vecmath.Point2f> nodes)
-
-
Method Details
-
getVertices
public java.util.ArrayList<org.jogamp.vecmath.Point2f> getVertices()- Specified by:
getVertices
in classShape2D
-
setVertices
public void setVertices(java.util.ArrayList<org.jogamp.vecmath.Point2f> vertices)- Specified by:
setVertices
in classShape2D
-
getVertex
public org.jogamp.vecmath.Point2f getVertex(int i) -
contains
public boolean contains(org.jogamp.vecmath.Point2f p)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
-