toxi.geom
Class Triangle2D

java.lang.Object
  extended by toxi.geom.Triangle2D

public class Triangle2D
extends java.lang.Object


Field Summary
 Vec2D a
           
 Vec2D b
           
 Vec2D c
           
 Vec2D centroid
           
 
Constructor Summary
Triangle2D()
           
Triangle2D(Vec2D a, Vec2D b, Vec2D c)
           
 
Method Summary
 Vec2D computeCentroid()
           
 boolean containsPoint(Vec2D p)
          Checks if point vector is inside the triangle created by the points a, b and c.
static Triangle2D createEquilateralFrom(Vec2D a, Vec2D b)
           
 Vec2D getClosestVertexTo(Vec2D p)
          Finds and returns the closest point on any of the triangle edges to the point given.
 boolean isClockwise()
           
static boolean isClockwise(Vec2D a, Vec2D b, Vec2D c)
           
 void set(Vec2D a2, Vec2D b2, Vec2D c2)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

a

public Vec2D a

b

public Vec2D b

c

public Vec2D c

centroid

public Vec2D centroid
Constructor Detail

Triangle2D

public Triangle2D()

Triangle2D

public Triangle2D(Vec2D a,
                  Vec2D b,
                  Vec2D c)
Method Detail

createEquilateralFrom

public static Triangle2D createEquilateralFrom(Vec2D a,
                                               Vec2D b)

isClockwise

public static boolean isClockwise(Vec2D a,
                                  Vec2D b,
                                  Vec2D c)

computeCentroid

public Vec2D computeCentroid()

containsPoint

public boolean containsPoint(Vec2D p)
Checks if point vector is inside the triangle created by the points a, b and c. These points will create a plane and the point checked will have to be on this plane in the region between a,b,c. Note: The triangle must be defined in clockwise order a,b,c

Returns:
true, if point is in triangle.

getClosestVertexTo

public Vec2D getClosestVertexTo(Vec2D p)
Finds and returns the closest point on any of the triangle edges to the point given.

Parameters:
p - point to check
Returns:
closest point

isClockwise

public boolean isClockwise()

set

public void set(Vec2D a2,
                Vec2D b2,
                Vec2D c2)

toString

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