Jeffrey T. Palmer > Box2D > Box2D::b2Math

# NAME

Box2D::b2Math - Vector and matrix functions.

# SYNOPSIS

my \$dot_product = Box2D::b2Math::b2DotV2V2( \$a, \$b );
my cross_product = Box2D::b2Math::b2CrossV2V2( \$a, \$b );
my \$distance = Box2D::b2Math::b2Distance( \$a, \$b );

# DESCRIPTION

Box2D includes a simple small vector and matrix module. This has been designed to suit the internal needs of Box2D and the API. Some the members are exposed, so you may use them freely in your application.

# METHODS

Parameters:

• float32 \$x

Returns a bool

## b2InvSqrt( \$x )

Compute the inverse square-root of a scalar. Approximate yet fast.

Parameters:

• float32 \$x

Returns a float32

## b2Abs( \$x )

Parameters:

• float32 \$x

Returns a float32

## b2DotV2V2( \$a, \$b )

Compute the dot product of two vectors.

Parameters:

• Box2D::b2Vec2 \$a
• Box2D::b2Vec2 \$b

Returns a float32

## b2CrossV2V2( \$a, \$b )

Compute the cross product of two vectors.

Parameters:

• Box2D::b2Vec2 \$a
• Box2D::b2Vec2 \$b

Returns a float32

## b2CrossV2S( \$v, \$s )

Compute the cross product of a vector and a scalar.

Parameters:

• Box2D::b2Vec2 \$v
• float32 \$s

Returns a Box2D::b2Vec2

## b2CrossSV2( \$s, \$v )

Compute the cross product of a scalar and a vector.

Parameters:

• float32 \$s
• Box2D::b2Vec2 \$v

Returns a Box2D::b2Vec2

## b2MulM22V2( \$M, \$v )

Multiply a matrix and a vector.

Parameters:

• Box2D::b2Mat22 \$M
• Box2D::b2Vec2 \$v

Returns a Box2D::b2Vec2

## b2MulTM22V2( \$M, \$v )

Multiply a matrix transpose and a vector.

Parameters:

• Box2D::b2Mat22 \$M
• Box2D::b2Vec2 \$v

Returns a Box2D::b2Vec2

Parameters:

• Box2D::b2Vec2 \$a
• Box2D::b2Vec2 \$b

Returns a Box2D::b2Vec2

## b2SubV2V2( \$a, \$b )

Subtract one vector from another.

Parameters:

• Box2D::b2Vec2 \$a
• Box2D::b2Vec2 \$b

Returns a Box2D::b2Vec2

## b2MulSV2( \$s, \$v )

Multiply a scalar and a vector.

Parameters:

• float32 \$s
• Box2D::b2Vec2 \$v

Returns a Box2D::b2Vec2

## b2EqlV2V2( \$a, \$b )

Are these vectors equal?

Parameters:

• Box2D::b2Vec2 \$a
• Box2D::b2Vec2 \$b

Returns a bool

## b2Distance( \$a, \$b )

Compute the distance between two vectors.

Parameters:

• Box2D::b2Vec2 \$a
• Box2D::b2Vec2 \$b

Returns a float32

## b2DistanceSquared( \$a, \$b )

Compute the square of the distance between two vectors.

Parameters:

• Box2D::b2Vec2 \$a
• Box2D::b2Vec2 \$b

Returns a float32