Changes

Jump to navigation Jump to search

Category:Physics Engine/Polygon Shapes

3,995 bytes added, 08:33, 31 July 2012
no edit summary
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 enclosed area of the polygon must be convex and the vertices must be defined in counterclockwise order.  
+
----
 +
===== 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.
   −
Poygon shapes are of type TI.cpPolyShape.  
+
Introduced in platform.apiLevel = '2.0'
    
[[Category:Physics_Engine]] [[Category:Physics_Engine/Shapes]]
 
[[Category:Physics_Engine]] [[Category:Physics_Engine/Shapes]]

Navigation menu