Difference between revisions of "love.math.triangulate"

m
m
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{newin|[[0.9.0]]|090|type=function}}
 
{{newin|[[0.9.0]]|090|type=function}}
Triangulate a simple polygon.
+
Decomposes a simple convex or concave polygon into triangles.
 
== Function ==
 
== Function ==
 
=== Synopsis ===
 
=== Synopsis ===
Line 9: Line 9:
 
{{param|table|polygon|Polygon to triangulate. Must not intersect itself.}}
 
{{param|table|polygon|Polygon to triangulate. Must not intersect itself.}}
 
=== Returns ===
 
=== Returns ===
{{param|table|triangles|List of triangles the polygon is composed of, in the form of <nowiki>{{x1, y1, x2, y2, x3, y3},  {x1, y1, x2, y2, x3, y3}, ...}</nowiki>.}}
+
{{param|table|triangles|List of triangles the polygon is composed of, in the form of <code><nowiki>{{x1, y1, x2, y2, x3, y3},  {x1, y1, x2, y2, x3, y3}, ...}</nowiki></code>.}}
 +
== Function ==
 +
=== Synopsis ===
 +
<source lang="lua">
 +
triangles = love.math.triangulate( x1, y1, x2, y2, x3, y3, ... )
 +
</source>
 +
=== Arguments ===
 +
{{param|number|x1|The position of the first vertex of the polygon on the x-axis.}}
 +
{{param|number|y1|The position of the first vertex of the polygon on the y-axis.}}
 +
{{param|number|x2|The position of the second vertex of the polygon on the x-axis.}}
 +
{{param|number|y2|The position of the second vertex of the polygon on the y-axis.}}
 +
{{param|number|x3|The position of the third vertex of the polygon on the x-axis.}}
 +
{{param|number|y3|The position of the third vertex of the polygon on the y-axis.}}
 +
=== Returns ===
 +
{{param|table|triangles|List of triangles the polygon is composed of, in the form of <code><nowiki>{{x1, y1, x2, y2, x3, y3},  {x1, y1, x2, y2, x3, y3}, ...}</nowiki></code>.}}
 
== See Also ==
 
== See Also ==
 
* [[parent::love.math]]
 
* [[parent::love.math]]
Line 15: Line 29:
 
* [[love.physics.newPolygonShape]]
 
* [[love.physics.newPolygonShape]]
 
[[Category:Functions]]
 
[[Category:Functions]]
{{#set:Description=Triangulate a simple polygon.}}
+
{{#set:Description=Decomposes a simple polygon into triangles.}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.math.triangulate}}
 
{{i18n|love.math.triangulate}}

Latest revision as of 23:53, 5 September 2015

Available since LÖVE 0.9.0
This function is not supported in earlier versions.

Decomposes a simple convex or concave polygon into triangles.

Function

Synopsis

triangles = love.math.triangulate( polygon )

Arguments

table polygon
Polygon to triangulate. Must not intersect itself.

Returns

table triangles
List of triangles the polygon is composed of, in the form of {{x1, y1, x2, y2, x3, y3}, {x1, y1, x2, y2, x3, y3}, ...}.

Function

Synopsis

triangles = love.math.triangulate( x1, y1, x2, y2, x3, y3, ... )

Arguments

number x1
The position of the first vertex of the polygon on the x-axis.
number y1
The position of the first vertex of the polygon on the y-axis.
number x2
The position of the second vertex of the polygon on the x-axis.
number y2
The position of the second vertex of the polygon on the y-axis.
number x3
The position of the third vertex of the polygon on the x-axis.
number y3
The position of the third vertex of the polygon on the y-axis.

Returns

table triangles
List of triangles the polygon is composed of, in the form of {{x1, y1, x2, y2, x3, y3}, {x1, y1, x2, y2, x3, y3}, ...}.

See Also

Other Languages