Banner Image

Module Shapes.TRIANGLE

TRIANGLE class with properties and methods for handling triangles.

This class is mostly used by the POLYGON class, but you can use it on its own as well

Author: nielsvaes/coconutcockpit


Global(s)

Global TRIANGLE

Type(s)

Fields and Methods inherited from CUBE Description

CUBE.ClassName

Name of the class.

CUBE.Coords

coordinates of the line

CUBE.Points

points of the line

Fields and Methods inherited from TRIANGLE Description

TRIANGLE.ContainsPoint(pt, points, self)

Checks if a point is contained within the triangle.

TRIANGLE:Draw()

Draws the triangle on the map, just for debugging

TRIANGLE.GetRandomVec2(points, self)

Returns a random Vec2 within the triangle.

TRIANGLE.New(p1, p2, p3, self)

Creates a new triangle from three points.

TRIANGLE:RemoveDraw()

Removes the drawing of the triangle from the map.

LINE class.

Field(s)

#string CUBE.ClassName

Name of the class.

#number CUBE.Coords

coordinates of the line

#number CUBE.Points

points of the line

Function(s)

Field(s)

Function(s)

Checks if a point is contained within the triangle.

Defined in:

TRIANGLE

Parameters:

#table pt

The point to check

#table points

(optional) The points of the triangle, or 3 other points if you're just using the TRIANGLE class without an object of it

self

Return value:

True if the point is contained, false otherwise

Draws the triangle on the map, just for debugging

Defined in:

TRIANGLE

Returns a random Vec2 within the triangle.

Defined in:

TRIANGLE

Parameters:

#table points

The points of the triangle, or 3 other points if you're just using the TRIANGLE class without an object of it

self

Return value:

#table:

The random Vec2

Creates a new triangle from three points.

The points need to be given as Vec2s

Defined in:

TRIANGLE

Parameters:

#table p1

The first point of the triangle

#table p2

The second point of the triangle

#table p3

The third point of the triangle

self

Return value:

The new triangle

Removes the drawing of the triangle from the map.

Defined in:

TRIANGLE