Difference between revisions of "Category:Physics Engine/Polygon Shapes"
Line 1: | Line 1: | ||
Polygon shapes are bounded by a set of line segments. | Polygon shapes are bounded by a set of line segments. | ||
+ | The enclosed area of the polygon must be convex and the vertices must be defined in counterclockwise order. | ||
+ | Poygon shapes are of type TI.cpPolyShape. | ||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | ===== PolyShape ===== | ||
+ | |||
+ | |||
+ | <!-- code start--> | ||
+ | <pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd"> | ||
+ | ps = physics.PolyShape(body, vertices, offset) | ||
+ | </pre><!-- code end--> | ||
+ | |||
+ | |||
+ | <!-- table start --> | ||
+ | {| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable" | ||
+ | <!-- header row start --> | ||
+ | ! Parameter !! Type !! Description | ||
+ | <!-- header row end --> | ||
+ | |- | ||
+ | | body | ||
+ | | '''in''' physics.Body | ||
+ | | A Body or nil | ||
+ | |- | ||
+ | | vertices '''in''' <nowiki>{</nowiki>physics.Vect<nowiki>}</nowiki> | ||
+ | | The list of vertices that define the boundaries of the polygon defined in counterclockwise order | ||
+ | |- | ||
+ | | offset | ||
+ | | '''in''' physics.Vect | ||
+ | | The offset of the PolyShape from the Body | ||
+ | |- | ||
+ | | ps | ||
+ | | '''out''' physics.PolyShape | ||
+ | | A new PolyShape | ||
+ | |}<!-- table end --> | ||
+ | |||
+ | <br/> | ||
+ | Returns a new PolyShape with the given [[#Body|body]], table of vertices, and offset from the body's center of gravity. Specify nil for the body to use the space's static body. | ||
+ | |||
+ | Introduced in platform.apiLevel = '2.0' | ||
+ | |||
+ | ---- | ||
+ | ===== numVerts ===== | ||
+ | |||
+ | |||
+ | <!-- code start--> | ||
+ | <pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd"> | ||
+ | nv = physics.PolyShape:numVerts() | ||
+ | </pre><!-- code end--> | ||
+ | |||
+ | |||
+ | <!-- table start --> | ||
+ | {| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable" | ||
+ | <!-- header row start --> | ||
+ | ! Parameter !! Type !! Description | ||
+ | <!-- header row end --> | ||
+ | |- | ||
+ | | self | ||
+ | | '''in''' physics.PolyShape | ||
+ | | The input PolyShape | ||
+ | |- | ||
+ | | nv | ||
+ | | '''out''' number | ||
+ | | The number of vertices in the PolyShape | ||
+ | |}<!-- table end --> | ||
+ | |||
+ | <br/> | ||
+ | Returns the number of vertices in the table of polygon vertices. | ||
+ | |||
+ | Introduced in platform.apiLevel = '2.0' | ||
− | The | + | ---- |
+ | ===== points ===== | ||
+ | |||
+ | |||
+ | <!-- code start--> | ||
+ | <pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd"> | ||
+ | points = physics.PolyShape:points() | ||
+ | </pre><!-- code end--> | ||
+ | |||
+ | |||
+ | <!-- table start --> | ||
+ | {| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable" | ||
+ | <!-- header row start --> | ||
+ | ! Parameter !! Type !! Description | ||
+ | <!-- header row end --> | ||
+ | |- | ||
+ | | self | ||
+ | | '''in''' physics.PolyShape | ||
+ | | The input PolyShape | ||
+ | |- | ||
+ | | points '''out''' <nowiki>{</nowiki>physics.Vect<nowiki>}</nowiki> | ||
+ | | A table of vertices that define the boundary of the polygon. The vertices are translated to the polygon's current world coordinates | ||
+ | |}<!-- table end --> | ||
+ | |||
+ | <br/> | ||
+ | Returns a copy of the table of vertices defining the bounds of the polygon. The vertices are translated to the polygon's current world coordinates. | ||
+ | {| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;" | ||
+ | |- | ||
+ | | <span style="color:#AAAA00">'''NOTE'''</span><hr> | ||
+ | |- | ||
+ | |||
+ | <div style="white-space: pre"> | ||
+ | |||
+ | When a PolyShape has not been added to a Space, it has no world coordinates. In this case, each vertex returned by physics.PolyShape:points() will have x and y equal to 0. | ||
+ | |||
+ | </div> | ||
+ | |} | ||
+ | <br/> | ||
+ | Introduced in platform.apiLevel = '2.0' | ||
+ | |||
+ | ---- | ||
+ | ===== vert ===== | ||
+ | |||
+ | |||
+ | <!-- code start--> | ||
+ | <pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd"> | ||
+ | v = physics.PolyShape:vert(n) | ||
+ | </pre><!-- code end--> | ||
+ | |||
+ | |||
+ | <!-- table start --> | ||
+ | {| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable" | ||
+ | <!-- header row start --> | ||
+ | ! Parameter !! Type !! Description | ||
+ | <!-- header row end --> | ||
+ | |- | ||
+ | | self | ||
+ | | '''in''' physics.PolyShape | ||
+ | | The input PolyShape | ||
+ | |- | ||
+ | | v | ||
+ | | '''out''' physics.Vect | ||
+ | | The nth vertex of the polygon. The coordinates of the vector are relative to the shape's Body | ||
+ | |}<!-- table end --> | ||
+ | |||
+ | <br/> | ||
+ | Returns vertex number ''n_ of the table of vertices defining the bounds of the polygon. If the shape is static then the vertex values are in world coordinates, otherwise the vertex coordiates are relative to the shape's [[#Body|body]]. Returns nil if _n'' is less than 1 or greater than the number of vertices in the polygon. | ||
− | + | Introduced in platform.apiLevel = '2.0' | |
[[Category:Physics_Engine]] [[Category:Physics_Engine/Shapes]] | [[Category:Physics_Engine]] [[Category:Physics_Engine/Shapes]] |
Latest revision as of 07:33, 31 July 2012
Polygon shapes are bounded by a set of line segments. The enclosed area of the polygon must be convex and the vertices must be defined in counterclockwise order. Poygon shapes are of type TI.cpPolyShape.
Contents
PolyShape
ps = physics.PolyShape(body, vertices, offset)
Parameter | Type | Description |
---|---|---|
body | in physics.Body | A Body or nil |
vertices in {physics.Vect} | The list of vertices that define the boundaries of the polygon defined in counterclockwise order | |
offset | in physics.Vect | The offset of the PolyShape from the Body |
ps | out physics.PolyShape | A new PolyShape |
Returns a new PolyShape with the given body, table of vertices, and offset from the body's center of gravity. Specify nil for the body to use the space's static body.
Introduced in platform.apiLevel = '2.0'
numVerts
nv = physics.PolyShape:numVerts()
Parameter | Type | Description |
---|---|---|
self | in physics.PolyShape | The input PolyShape |
nv | out number | The number of vertices in the PolyShape |
Returns the number of vertices in the table of polygon vertices.
Introduced in platform.apiLevel = '2.0'
points
points = physics.PolyShape:points()
Parameter | Type | Description |
---|---|---|
self | in physics.PolyShape | The input PolyShape |
points out {physics.Vect} | A table of vertices that define the boundary of the polygon. The vertices are translated to the polygon's current world coordinates |
Returns a copy of the table of vertices defining the bounds of the polygon. The vertices are translated to the polygon's current world coordinates.
When a PolyShape has not been added to a Space, it has no world coordinates. In this case, each vertex returned by physics.PolyShape:points() will have x and y equal to 0.
NOTE |
Introduced in platform.apiLevel = '2.0'
vert
v = physics.PolyShape:vert(n)
Parameter | Type | Description |
---|---|---|
self | in physics.PolyShape | The input PolyShape |
v | out physics.Vect | The nth vertex of the polygon. The coordinates of the vector are relative to the shape's Body |
Returns vertex number n_ of the table of vertices defining the bounds of the polygon. If the shape is static then the vertex values are in world coordinates, otherwise the vertex coordiates are relative to the shape's body. Returns nil if _n is less than 1 or greater than the number of vertices in the polygon.
Introduced in platform.apiLevel = '2.0'
This category currently contains no pages or media.