Package mgui.geometry
Class Polygon3D
java.lang.Object
mgui.geometry.Shape3D
mgui.geometry.Polygon3D
public class Polygon3D extends Shape3D
Geometry class for a polygon in R3. Nodes are stored in a Point3f[] array,
such that a reference to this array can be passed to a Java3D node. The number
of nodes is indicated by the field n. Note that the nodes array actually contains
n + 1 nodes, since the final node is the same as the first for a closed polygon.
- 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 inherited from class mgui.geometry.Shape3D
xml_count, xml_current_block, xml_encoding, xml_itr, xml_vertices
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
addNode(org.jogamp.vecmath.Point3f node)
void
finalize()
float[]
getCoords()
Returns an array of n coordinates {x1,y1,z1,x2,...,zn}float
getPerimeter()
org.jogamp.vecmath.Point3f
getVertex(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.void
setCoords(float[] f)
Sets the nodes array from an array in the form {x1,y1,z1,x2,...,zn} The last coordinate must equal the first.void
setVertices(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes)
void
setVertices(org.jogamp.vecmath.Point3f[] nodes)
Methods inherited from class mgui.geometry.Shape3D
clone, contains, getBoundBox, getCenter, getDTD, getLocalName, getProximity, getProximityPoint, getShortXML, getSize, getXML, getXML, getXMLSchema, handleXMLElementEnd, handleXMLElementStart, handleXMLString, loadAsciiCoords, loadBinaryCoords, loadCoords, loadXMLCoord, transform, transform, writeAsciiCoords, writeBinaryCoords, writeCoords, writeXML, writeXML, writeXML
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
nodes
public float[] nodes -
n
public int n
-
-
Constructor Details
-
Polygon3D
public Polygon3D() -
Polygon3D
public Polygon3D(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodeList) -
Polygon3D
public Polygon3D(org.jogamp.vecmath.Point3f[] nodeList)
-
-
Method Details
-
addNode
public void addNode(org.jogamp.vecmath.Point3f node) -
getCoords
public float[] getCoords()Returns an array of n coordinates {x1,y1,z1,x2,...,zn} -
setCoords
public void setCoords(float[] f)Sets the nodes array from an array in the form {x1,y1,z1,x2,...,zn} The last coordinate must equal the first. TODO: check for this and add if absent -
getVertices
public java.util.ArrayList<org.jogamp.vecmath.Point3f> getVertices()Description copied from class:Shape3D
Returns 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:
getVertices
in classShape3D
- Returns:
-
getPerimeter
public float getPerimeter() -
finalize
public void finalize()- Overrides:
finalize
in classjava.lang.Object
-
setVertices
public void setVertices(org.jogamp.vecmath.Point3f[] nodes)- Overrides:
setVertices
in classShape3D
-
setVertices
public void setVertices(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes)- Specified by:
setVertices
in classShape3D
-
getVertex
public org.jogamp.vecmath.Point3f getVertex(int i)Description copied from class:Shape3D
Returns 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.
-