Package mgui.geometry

Class Polygon3D

java.lang.Object
mgui.geometry.Shape3D
mgui.geometry.Polygon3D
All Implemented Interfaces:
java.lang.Cloneable, Shape, XMLObject

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
  • 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}
      Specified by:
      getCoords in interface Shape
      Specified by:
      getCoords in class Shape3D
      Returns:
    • 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
      Specified by:
      setCoords in interface Shape
      Specified by:
      setCoords in class Shape3D
    • getVertices

      public java.util.ArrayList<org.jogamp.vecmath.Point3f> getVertices()
      Description copied from class: Shape3D
      Returns a list of this shape's nodes as Point3f's. This list is a copy, so operations performed on these nodes will not affect this shape.
      Specified by:
      getVertices in class Shape3D
      Returns:
    • getPerimeter

      public float getPerimeter()
    • finalize

      public void finalize()
      Overrides:
      finalize in class java.lang.Object
    • setVertices

      public void setVertices​(org.jogamp.vecmath.Point3f[] nodes)
      Overrides:
      setVertices in class Shape3D
    • setVertices

      public void setVertices​(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes)
      Specified by:
      setVertices in class Shape3D
    • getVertex

      public org.jogamp.vecmath.Point3f getVertex​(int i)
      Description copied from class: Shape3D
      Returns the vertex at the specified index as a Point3f. 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.

      Specified by:
      getVertex in class Shape3D
      Returns: