Optionalx1: numberx coordinate of the first point. Default 0.
Optionaly1: numbery coordinate of the first point. Default 0.
Optionalx2: numberx coordinate of the second point. Default 0.
Optionaly2: numbery coordinate of the second point. Default 0.
Optionalx3: numberx coordinate of the third point. Default 0.
Optionaly3: numbery coordinate of the third point. Default 0.
Bottom most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly.
Left most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly.
Right most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly.
Top most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly.
ReadonlytypeThe geometry constant type of this object: GEOM_CONST.TRIANGLE.
Used for fast type comparisons.
x coordinate of the first point.
x coordinate of the second point.
x coordinate of the third point.
y coordinate of the first point.
y coordinate of the second point.
y coordinate of the third point.
Checks whether a given points lies within the triangle.
The x coordinate of the point to check.
The y coordinate of the point to check.
Calculates a list of evenly distributed points on the triangle. It is either possible to pass an amount of points to be generated (quantity) or the distance between two points (stepRate).
Number of points to be generated. Can be falsey when stepRate should be used. All points have the same distance along the triangle.
OptionalstepRate: numberDistance between two points. Will only be used when quantity is falsey.
Optionaloutput: OOptional array of Vector2 points for writing the calculated points into. Otherwise a new array will be created.
Sets all three points of the triangle. Leaving out any coordinate sets it to be 0.
Optionalx1: numberx coordinate of the first point. Default 0.
Optionaly1: numbery coordinate of the first point. Default 0.
Optionalx2: numberx coordinate of the second point. Default 0.
Optionaly2: numbery coordinate of the second point. Default 0.
Optionalx3: numberx coordinate of the third point. Default 0.
Optionaly3: numbery coordinate of the third point. Default 0.
StaticAreaStaticBuildBuilds an equilateral triangle. In the equilateral triangle, all the sides are the same length (congruent) and all the angles are the same size (congruent). The x/y specifies the top-middle of the triangle (x1/y1) and length is the length of each side.
x coordinate of the top point of the triangle.
y coordinate of the top point of the triangle.
Length of each side of the triangle.
StaticBuildTakes an array of vertex coordinates, and optionally an array of hole indices, then returns an array of Triangle instances, where the given vertices have been decomposed into a series of triangles.
A flat array of vertex coordinates like [x0,y0, x1,y1, x2,y2, ...]
Optionalholes: any[]An array of hole indices if any (e.g. [5, 8] for a 12-vertex input would mean one hole with vertices 5–7 and another with 8–11). Default null.
OptionalscaleX: numberHorizontal scale factor to multiply the resulting points by. Default 1.
OptionalscaleY: numberVertical scale factor to multiply the resulting points by. Default 1.
Optionalout: OAn array to store the resulting Triangle instances in. If not provided, a new array is created.
StaticBuildBuilds a right triangle, i.e. one which has a 90-degree angle and two acute angles.
The X coordinate of the right angle, which will also be the first X coordinate of the constructed Triangle.
The Y coordinate of the right angle, which will also be the first Y coordinate of the constructed Triangle.
The length of the side which is to the left or to the right of the right angle.
The length of the side which is above or below the right angle.
StaticCenterPositions the Triangle so that it is centered on the given coordinates.
The triangle to be positioned.
The horizontal coordinate to center on.
The vertical coordinate to center on.
OptionalcenterFunc: CenterFunctionThe function used to center the triangle. Defaults to Centroid centering.
StaticCentroidCalculates the position of a Triangle's centroid, which is also its center of mass (center of gravity).
The centroid is the point in a Triangle at which its three medians (the lines drawn from the vertices to the bisectors of the opposite sides) meet. It divides each one in a 2:1 ratio.
StaticCircumComputes the circumcentre of a triangle. The circumcentre is the centre of the circumcircle, the smallest circle which encloses the triangle. It is also the common intersection point of the perpendicular bisectors of the sides of the triangle, and is the only point which has equal distance to all three vertices of the triangle.
Adapted from http://bjornharrtell.github.io/jsts/doc/api/jsts_geom_Triangle.js.html
StaticCircumFinds the circumscribed circle (circumcircle) of a Triangle object. The circumcircle is the circle which touches all of the triangle's vertices.
Adapted from https://gist.github.com/mutoo/5617691
StaticCloneStaticContainsStaticContainsFilters an array of point-like objects to only those contained within a triangle.
If returnFirst is true, will return an array containing only the first point in the provided array that is within the triangle (or an empty array if there are no such points).
The triangle that the points are being checked in.
An array of Vector2 objects to check if they are within the triangle.
OptionalreturnFirst: booleanIf true, return an array containing only the first point found that is within the triangle. Default false.
Optionalout: any[]If provided, the points that are within the triangle will be appended to this array instead of being added to a new array. If returnFirst is true, only the first point found within the triangle will be appended. This array will also be returned by this function.
StaticContainsStaticCopyStaticDecomposeStaticEqualsStaticGetStaticGetReturns an array of evenly spaced points on the perimeter of a Triangle.
The Triangle to get the points from.
The number of evenly spaced points to return. Set to 0 to return an arbitrary number of points based on the stepRate.
If quantity is 0, the distance between each returned point.
Optionalout: OAn array to which the points should be appended.
StaticInCalculates the position of the incenter of a Triangle object. This is the point where its three angle bisectors meet and it's also the center of the incircle, which is the circle inscribed in the triangle.
StaticOffsetMoves each point (vertex) of a Triangle by a given offset, thus moving the entire Triangle by that offset.
The Triangle to move.
The horizontal offset (distance) by which to move each point. Can be positive or negative.
The vertical offset (distance) by which to move each point. Can be positive or negative.
StaticPerimeterStaticRandomReturns a random Point from within the area of the given Triangle.
StaticRotateStaticRotateStaticRotateRotates an entire Triangle at a given angle about a specific point.
The Triangle to rotate.
The X coordinate of the point to rotate the Triangle about.
The Y coordinate of the point to rotate the Triangle about.
The angle by which to rotate the Triangle, in radians.
A triangle is a plane created by connecting three points. The first two arguments specify the first point, the middle two arguments specify the second point, and the last two arguments specify the third point.