Package mgui.geometry

Class Triangle2D

java.lang.Object
mgui.geometry.Shape2D
mgui.geometry.Triangle2D
All Implemented Interfaces:
java.lang.Cloneable, Shape, XMLObject

public class Triangle2D
extends Shape2D
Represents a 2D triangle.
Since:
1.0
Version:
1.0
Author:
Andrew Reid
  • 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 class Shape2D
    • setVertices

      public void setVertices​(java.util.ArrayList<org.jogamp.vecmath.Point2f> vertices)
      Specified by:
      setVertices in class Shape2D
    • getVertex

      public org.jogamp.vecmath.Point2f getVertex​(int i)
      Specified by:
      getVertex in class Shape2D
    • 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
      Overrides:
      contains in class Shape2D