## toxi.geom Class Triangle2D

```java.lang.Object
toxi.geom.Triangle2D
```
All Implemented Interfaces:
Shape2D

`public class Triangle2Dextends java.lang.Objectimplements Shape2D`

Field Summary
` Vec2D` `a`

` Vec2D` `b`

` Vec2D` `c`

` Vec2D` `centroid`

Constructor Summary
`Triangle2D()`

```Triangle2D(ReadonlyVec2D a, ReadonlyVec2D b, ReadonlyVec2D c)```

Method Summary
` Triangle2D` `adjustTriangleSizeBy(float offset)`

` Triangle2D` ```adjustTriangleSizeBy(float offAB, float offBC, float offCA)```

` Vec2D` `computeCentroid()`

` boolean` `containsPoint(ReadonlyVec2D p)`
Checks if point vector is inside the triangle created by the points a, b and c.
` Triangle2D` `copy()`

`static Triangle2D` ```createEquilateralFrom(ReadonlyVec2D a, ReadonlyVec2D b)```

` Triangle2D` `flipVertexOrder()`

` Vec2D` `fromBarycentric(ReadonlyVec3D p)`

` float` `getArea()`
Computes the area of the shape.
` Rect` `getBounds()`

` Circle` `getCircumCircle()`

` float` `getCircumference()`
Computes the shape's circumference.
` Vec2D` `getClosestPointTo(ReadonlyVec2D p)`
Finds and returns the closest point on any of the triangle edges to the point given.
` boolean` `intersectsTriangle(Triangle2D tri)`

` boolean` `isClockwise()`

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

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

` Polygon2D` `toPolygon2D()`
Creates a `Polygon2D` instance of the triangle.
` 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(ReadonlyVec2D a,
Method Detail

### createEquilateralFrom

```public static Triangle2D createEquilateralFrom(ReadonlyVec2D a,

### isClockwise

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

`public Triangle2D adjustTriangleSizeBy(float offset)`

```public Triangle2D adjustTriangleSizeBy(float offAB,
float offBC,
float offCA)```

### computeCentroid

`public Vec2D computeCentroid()`

### containsPoint

`public boolean containsPoint(ReadonlyVec2D 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

Specified by:
`containsPoint` in interface `Shape2D`
Returns:
true, if point is in triangle.

### copy

`public Triangle2D copy()`

### flipVertexOrder

`public Triangle2D flipVertexOrder()`

### fromBarycentric

`public Vec2D fromBarycentric(ReadonlyVec3D p)`

### getArea

`public float getArea()`
Description copied from interface: `Shape2D`
Computes the area of the shape.

Specified by:
`getArea` in interface `Shape2D`
Returns:
area

### getBounds

`public Rect getBounds()`

### getCircumCircle

`public Circle getCircumCircle()`

### getCircumference

`public float getCircumference()`
Description copied from interface: `Shape2D`
Computes the shape's circumference.

Specified by:
`getCircumference` in interface `Shape2D`
Returns:
circumference

### getClosestPointTo

`public Vec2D getClosestPointTo(ReadonlyVec2D 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

### intersectsTriangle

`public boolean intersectsTriangle(Triangle2D tri)`

### isClockwise

`public boolean isClockwise()`

### set

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

### toPolygon2D

`public Polygon2D toPolygon2D()`
Creates a `Polygon2D` instance of the triangle. The vertices of this polygon are disconnected from the ones defining this triangle.

Returns:
triangle as polygon

### toString

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