Class b2EdgeShape

An edge shape.

Hierarchy

Index

Constructor methods

Methods

Constructor methods

constructor(v1: b2Vec2, v2: b2Vec2): b2EdgeShape

Creates a new edge shape.

Parameters

Returns

b2EdgeShape

Methods

public ComputeAABB(aabb: b2AABB, xf: b2Transform)

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

Parameters

  • aabb: b2AABB

    Calculated AABB, this argument is out.

  • xf: b2Transform

    Transform to calculate the AABB.

public ComputeMass(massData: b2MassData, density: number)

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

    Calculate the mass, this argument is out.

  • density: number

public 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 the normal.

  • xf: b2Transform

    The shape transform.

  • c: b2Vec2

    The centroid, this argument is out.

Returns

number

public Copy(): b2Shape

Clone the shape.

Returns

b2Shape

public Corner1IsConvex(): boolean

Determines if the first corner of this edge bends towards the solid side.

Returns

boolean

True if convex, otherwise false.

public Corner2IsConvex(): boolean

Determines if the second corner of this edge bends towards the solid side.

Returns

boolean

True if convex, otherwise false.

public GetCoreVertex1(): b2Vec2

Get a core vertex 1 in local coordinates. These vertices represent a smaller edge that is used for time of impact.

Returns

b2Vec2

core vertex 1 in local coordinates.

public GetCoreVertex2(): b2Vec2

Get a core vertex 2 in local coordinates. These vertices represent a smaller edge that is used for time of impact.

Returns

b2Vec2

core vertex 2 in local coordinates.

public GetCorner1Vector(): b2Vec2

Returns a unit vector halfway between direction and previous direction.

Returns

b2Vec2

Halfway unit vector between direction and previous direction.

public GetCorner2Vector(): b2Vec2

Returns a unit vector halfway between direction and previous direction.

Returns

b2Vec2

Halfway unit vector between direction and previous direction.

public GetDirectionVector(): b2Vec2

Get a parallel unit vector, pointing from vertex 1 to vertex 2.

Returns

b2Vec2

Vertex 1 to vertex 2 directional vector.

public GetFirstVertex(xf: b2Transform): b2Vec2

Get the first vertex and apply the supplied transform.

Parameters

Returns

b2Vec2

First vertex with xf transform applied.

public GetLength(): number

Get the distance from vertex1 to vertex2.

Returns

number

Distance from vertex1 to vertex2.

public GetNextEdge(): b2EdgeShape

Get the next edge in the chain.

Returns

b2EdgeShape

Next edge shape or null if there is no next edge shape.

public GetNormalVector(): b2Vec2

Get a perpendicular unit vector, pointing from the solid side to the empty side.

Returns

b2Vec2

Normal vector.

public GetPrevEdge(): b2EdgeShape

Get the previous edge in the chain.

Returns

b2EdgeShape

Previous edge shape or null if there is no previous edge shape.

public GetType(): number

Get the type of this shape. You can use this to down cast to the concrete shape.

Returns

number

public GetVertex1(): b2Vec2

Get the local position of vertex1 in the parent body.

Returns

b2Vec2

Local position of vertex1 in the parent body.

public GetVertex2(): b2Vec2

Get the local position of vertex2 in the parent body.

Returns

b2Vec2

Local position of vertex2 in the parent body.

public RayCast(output: b2RayCastOutput, input: b2RayCastInput, transform: b2Transform): boolean

Cast a ray against this shape.

Parameters

Returns

boolean

True if the ray hits the shape, otherwise false.

public Set(other: b2Shape)

Set the shape values from another shape.

Parameters

  • other: b2Shape

    The other shape to copy values from.

public Support(xf: b2Transform, dX: number, dY: number): b2Vec2

Get the support point in the given world direction with the supplied transform.

Parameters

  • xf: b2Transform

    Transform to apply.

  • dX: number

    X world direction.

  • dY: number

    Y world direction.

Returns

b2Vec2

Support point.

public TestPoint(xf: b2Transform, p: b2Vec2): boolean

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

Parameters

  • xf: b2Transform

    Shape world transform.

  • p: b2Vec2

    Point to test against, in world coordinates.

Returns

boolean

True if the point is in this shape, otherwise false.