PackageBox2D.Collision.Shapes
Classpublic class b2PolygonShape
Inheritanceb2PolygonShape Inheritance b2Shape
Sourceb2PolygonShape.as

Convex polygon. The vertices must be in CCW order for a right-handed coordinate system with the z-axis coming out of the screen.

See also

b2PolygonDef


Public Methods
 MethodDefined by
  
AsArray(vertices:Array, vertexCount:Number):b2PolygonShape
[static]
b2PolygonShape
  
AsBox(hx:Number, hy:Number):b2PolygonShape
[static]
b2PolygonShape
  
[static] Set this as a single edge.
b2PolygonShape
  
AsOrientedBox(hx:Number, hy:Number, center:b2Vec2 = null, angle:Number = 0.0):b2PolygonShape
[static]
b2PolygonShape
  
AsVector(vertices:Vector, vertexCount:Number):b2PolygonShape
[static]
b2PolygonShape
  
Given a transform, compute the associated axis aligned bounding box for this shape.
b2PolygonShape
  
ComputeCentroid(vs:Vector, count:uint):b2Vec2
[static] Computes the centroid of the given polygon
b2PolygonShape
  
ComputeMass(massData:b2MassData, density:Number):void
Compute the mass properties of this shape using its dimensions and density.
b2PolygonShape
  
ComputeSubmergedArea(normal:b2Vec2, offset:Number, xf:b2Transform, c:b2Vec2):Number
Compute the volume and centroid of this shape intersected with a half plane
b2PolygonShape
  
b2PolygonShape
  
GetNormals():Vector
Get the edge normal vectors.
b2PolygonShape
  
Get the supporting vertex index in the given direction.
b2PolygonShape
  
b2PolygonShape
 Inherited
GetType():int
Get the type of this shape.
b2Shape
  
Get the vertex count.
b2PolygonShape
  
GetVertices():Vector
Get the vertices in local coordinates.
b2PolygonShape
  
RayCast(output:b2RayCastOutput, input:b2RayCastInput, transform:b2Transform):Boolean
Cast a ray against this shape.
b2PolygonShape
  
Set(other:b2Shape):void
b2PolygonShape
  
SetAsArray(vertices:Array, vertexCount:Number = 0):void
Copy vertices.
b2PolygonShape
  
SetAsBox(hx:Number, hy:Number):void
Build vertices to represent an axis-aligned box.
b2PolygonShape
  
SetAsEdge(v1:b2Vec2, v2:b2Vec2):void
Set this as a single edge.
b2PolygonShape
  
SetAsOrientedBox(hx:Number, hy:Number, center:b2Vec2 = null, angle:Number = 0.0):void
b2PolygonShape
  
SetAsVector(vertices:Vector, vertexCount:Number = 0):void
Copy vertices.
b2PolygonShape
 Inherited
TestOverlap(shape1:b2Shape, transform1:b2Transform, shape2:b2Shape, transform2:b2Transform):Boolean
[static]
b2Shape
  
TestPoint(xf:b2Transform, p:b2Vec2):Boolean
Test a point for containment in this shape.
b2PolygonShape
Public Constants
 ConstantDefined by
 Inheritede_hitCollide : int = 1
[static] Possible return values for TestSegment
b2Shape
 Inheritede_missCollide : int = 0
[static] Return value for TestSegment indicating a miss.
b2Shape
 Inheritede_startsInsideCollide : int = -1
[static] Return value for TestSegment indicating that the segment starting point, p1, is already inside the shape.
b2Shape
Method detail
AsArray()method
public static function AsArray(vertices:Array, vertexCount:Number):b2PolygonShapeParameters
vertices:Array
 
vertexCount:Number

Returns
b2PolygonShape
AsBox()method 
public static function AsBox(hx:Number, hy:Number):b2PolygonShapeParameters
hx:Number
 
hy:Number

Returns
b2PolygonShape
AsEdge()method 
public static function AsEdge(v1:b2Vec2, v2:b2Vec2):b2PolygonShape

Set this as a single edge.

Parameters
v1:b2Vec2
 
v2:b2Vec2

Returns
b2PolygonShape
AsOrientedBox()method 
public static function AsOrientedBox(hx:Number, hy:Number, center:b2Vec2 = null, angle:Number = 0.0):b2PolygonShapeParameters
hx:Number
 
hy:Number
 
center:b2Vec2 (default = null)
 
angle:Number (default = 0.0)

Returns
b2PolygonShape
AsVector()method 
public static function AsVector(vertices:Vector, vertexCount:Number):b2PolygonShapeParameters
vertices:Vector
 
vertexCount:Number

Returns
b2PolygonShape
ComputeAABB()method 
public override function ComputeAABB(aabb:b2AABB, xf:b2Transform):void

Given a transform, compute the associated axis aligned bounding box for this shape.

Parameters
aabb:b2AABB — returns the axis aligned box.
 
xf:b2Transform — the world transform of the shape.
ComputeCentroid()method 
public static function ComputeCentroid(vs:Vector, count:uint):b2Vec2

Computes the centroid of the given polygon

Parameters
vs:Vector — vector of b2Vec specifying a polygon
 
count:uint — length of vs

Returns
b2Vec2 — the polygon centroid
ComputeMass()method 
public override function ComputeMass(massData:b2MassData, density:Number):void

Compute the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin, not the centroid.

Parameters
massData:b2MassData — returns the mass data for this shape.
 
density:Number
ComputeSubmergedArea()method 
public override function ComputeSubmergedArea(normal:b2Vec2, offset:Number, xf:b2Transform, c:b2Vec2):Number

Compute the volume and centroid of this shape intersected with a half plane

Parameters
normal:b2Vec2 — the surface normal
 
offset:Number — the surface offset along normal
 
xf:b2Transform — the shape transform
 
c:b2Vec2 — returns the centroid

Returns
Number — the total volume less than offset along normal
Copy()method 
public override function Copy():b2Shape

Returns
b2Shape
GetNormals()method 
public function GetNormals():Vector

Get the edge normal vectors. There is one for each vertex.

Returns
Vector
GetSupport()method 
public function GetSupport(d:b2Vec2):int

Get the supporting vertex index in the given direction.

Parameters
d:b2Vec2

Returns
int
GetSupportVertex()method 
public function GetSupportVertex(d:b2Vec2):b2Vec2Parameters
d:b2Vec2

Returns
b2Vec2
GetVertexCount()method 
public function GetVertexCount():int

Get the vertex count.

Returns
int
GetVertices()method 
public function GetVertices():Vector

Get the vertices in local coordinates.

Returns
Vector
RayCast()method 
public override function RayCast(output:b2RayCastOutput, input:b2RayCastInput, transform:b2Transform):Boolean

Cast a ray against this shape.

Parameters
output:b2RayCastOutput — the ray-cast results.
 
input:b2RayCastInput — the ray-cast input parameters.
 
transform:b2Transform — the transform to be applied to the shape.

Returns
Boolean
Set()method 
public override function Set(other:b2Shape):voidParameters
other:b2Shape
SetAsArray()method 
public function SetAsArray(vertices:Array, vertexCount:Number = 0):void

Copy vertices. This assumes the vertices define a convex polygon. It is assumed that the exterior is the the right of each edge.

Parameters
vertices:Array
 
vertexCount:Number (default = 0)
SetAsBox()method 
public function SetAsBox(hx:Number, hy:Number):void

Build vertices to represent an axis-aligned box.

Parameters
hx:Number — the half-width.
 
hy:Number — the half-height.
SetAsEdge()method 
public function SetAsEdge(v1:b2Vec2, v2:b2Vec2):void

Set this as a single edge.

Parameters
v1:b2Vec2
 
v2:b2Vec2
SetAsOrientedBox()method 
public function SetAsOrientedBox(hx:Number, hy:Number, center:b2Vec2 = null, angle:Number = 0.0):voidParameters
hx:Number
 
hy:Number
 
center:b2Vec2 (default = null)
 
angle:Number (default = 0.0)
SetAsVector()method 
public function SetAsVector(vertices:Vector, vertexCount:Number = 0):void

Copy vertices. This assumes the vertices define a convex polygon. It is assumed that the exterior is the the right of each edge.

Parameters
vertices:Vector
 
vertexCount:Number (default = 0)
TestPoint()method 
public override function TestPoint(xf:b2Transform, p:b2Vec2):Boolean

Test a point for containment in this shape. This only works for convex shapes.

Parameters
xf:b2Transform — the shape world transform.
 
p:b2Vec2 — a point in world coordinates.

Returns
Boolean