Package mgui.geometry

Class Triangle3D

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

public class Triangle3D
extends Shape3D
Represents a 3D triangle.
Since:
1.0
Version:
1.0
Author:
Andrew Reid
  • 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

      public Plane3D getPlane()
    • 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:
    • 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: 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:
    • contains

      public boolean contains​(org.jogamp.vecmath.Point3f p)
      Determines whether p is contained by this triangle. Assumes that p is 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
      Overrides:
      contains in class Shape3D
      Returns:
      true if this shape contains point; false otherwise.
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • getCoords

      public float[] getCoords()
      Specified by:
      getCoords in interface Shape
      Specified by:
      getCoords in class Shape3D
    • setCoords

      public void setCoords​(float[] coords)
      Specified by:
      setCoords in interface Shape
      Specified by:
      setCoords in class Shape3D
    • setVertices

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