BRender Technical Reference Manual:4 Data Structures (Alphabetical Reference):br_vector2
Next|Prev|Up
The Structure
Members
Arithmetic
BrVector2Negate()
BrVector2Add()
BrVector2Accumulate()
BrVector2Sub()
BrVector2Scale()
BrVector2InvScale()
BrVector2Dot()
BrVector2Length()
BrVector2LengthSquared()
BrVector2Normalise()
Copy/Assign
BrVector2Copy()
Referencing & Lifetime
Initialisation
BrVector2Set()
BrVector2SetFloat()
BrVector2SetInt()

br_vector2


The Structure

This is the two ordinate vector structure, typically used for 2D purposes. Functions are provided to allow it be used as though it were an integral type.

The typedef

(See vector.h for precise declaration and ordering)

br_scalar v[2] Ordinates (0=x, 1=y)

Related Functions

Image Support

See BrOriginToScreenXY()
251, BrPointToScreenXY()251, BrPointToScreenXYMany()251,

Maths

See BrMatrix23ApplyP()173, BrMatrix23ApplyV()175, BrMatrix23TApplyP()175, BrMatrix23TApplyV()175.

Related Structures

See br_matrix23171, br_vertex367.

Members

br_scalar v[2]

First and second ordinate. Conventionally, the first ordinate is the x-axis component, and the second, the y axis component.

Arithmetic


BrVector2Negate()

Description:
Negate a vector and place the result in a second destination vector. Equivalent to the expression:

Declaration:
void BrVector2Negate(br_vector2* v1, const br_vector2* v2)

Arguments:
br_vector2 * v1

A pointer to the destination vector (may be same as source).

const br_vector2 * v2

A pointer to the source vector.


BrVector2Add()

Description:
Add two vectors and place the result in a third destination vector.

Equivalent to the expression:

Declaration:
void BrVector2Add(br_vector2* v1, const br_vector2* v2, const br_vector2* v3)

Arguments:
br_vector2 * v1

A pointer to the destination vector (may be same as either source).

const br_vector2 * v2

A pointer to the first vector of the sum.

const br_vector2 * v3

A pointer to the second vector of the sum.


BrVector2Accumulate()

Description:
Add one vector to another. Equivalent to the expression:

Declaration:
void BrVector2Accumulate(br_vector2* v1, const br_vector2* v2)

Arguments:
br_vector2 * v1

A pointer to the accumulating vector (may be same as v2).

const br_vector2 * v2

A pointer to the vector to add.


BrVector2Sub()

Description:
Subtract one vector from another and place the result in a third destination vector.

Equivalent to the expression:

Declaration:
void BrVector2Sub(br_vector2* v1, const br_vector2* v2, const br_vector2* v3)

Arguments:
br_vector2 * v1

A pointer to the destination vector (may be same as v1 or v2).

const br_vector2 * v2

A pointer to the additive vector.

const br_vector2 * v3

A pointer to the subtractive vector.


BrVector2Scale()

Description:
Scale a vector by a scalar and place the result in a destination vector. Equivalent to the expression:

Declaration:
void BrVector2Scale(br_vector2* v1, const br_vector2* v2, br_scalar s)

Arguments:
br_vector2 * v1

A pointer to the destination vector (may be same as source).

const br_vector2 * v2

A pointer to the source vector.

br_scalar s

Scale factor.


BrVector2InvScale()

Description:
Scale a vector by the reciprocal of a scalar and place the result in a destination vector. Equivalent to the expression:

Declaration:
void BrVector2InvScale(br_vector2* v1, const br_vector2* v2, br_scalar s)

Arguments:
br_vector2 * v1

A pointer to the destination vector (may be same as source).

const br_vector2 * v2

A pointer to the source vector.

br_scalar s

Reciprocal scale factor.


BrVector2Dot()

Description:
Calculate the dot product of two vectors. Equivalent to the expression:

Declaration:
br_scalar BrVector2Dot(const br_vector2* v1, const br_vector2* v2)

Arguments:
const br_vector2 * v1

Pointer to left hand vector (may be same as v2).

const br_vector2 * v2

Pointers to right hand vector.

Result:
br_scalar

Returns the dot product of the two source vectors. Equivalent to:


BrVector2Length()

Description:
Calculate the length of a vector. Equivalent to the expression:

Declaration:
br_scalar BrVector2Length(const br_vector2* v1)

Arguments:
const br_vector2 * v1

A pointer to the source vector.

Result:
br_scalar

Returns the length of the vector. Equivalent to:

See Also:
BrVector2LengthSquared()
352


BrVector2LengthSquared()

Description:
Calculate the squared length of a vector. Equivalent to the expression:

or

Declaration:
br_scalar BrVector2LengthSquared(const br_vector2* v1)

Arguments:
const br_vector2 * v1

A pointer to the source vector.

Result:
br_scalar

Returns the squared length of the vector. Equivalent to:

See Also:
BrVector2Length()
352


BrVector2Normalise()

Description:
Normalise a vector and place the result in a destination vector. Equivalent to the expression:

Declaration:
void BrVector2Normalise(br_vector2* v1, const br_vector2* v2)

Arguments:
br_vector2 * v1

A pointer to the destination vector (may be same as source).

const br_vector2 * v2

A pointer to the source vector.

Remarks:
If the source vector's length is zero
*1 the unit vector along the x axis is stored at the destination instead.


Copy/Assign

Although copy by structure assignment currently works, use BrVector2Copy()
353 to ensure compatibility.


BrVector2Copy()

Description:
Copy a vector. Equivalent to the expression:

Declaration:
void BrVector2Copy(br_vector2* v1, const br_vector2* v2)

Arguments:
br_vector2 * v1

A pointer to the destination vector (may be same as source).

const br_vector2 * v2

A pointer to the source vector.


Referencing & Lifetime

This structure may be freely referenced, though take care if there is potential to supply the same vector as more than one argument to the same function.

Initialisation

The following macro may be used as a static initialiser.

BR_VECTOR2(a,b)
Macro expands to {BR_SCALAR(a),BR_SCALAR(b)}.

All other initialisation should use the functions, BrVector2Set()354, BrVector2SetInt()355, BrVector2SetFloat()354 or BrVector2Copy()353.


BrVector2Set()

Description:
Set a vector with a pair of scalars.

Declaration:
void BrVector2Set(br_vector2* v1, br_scalar s1, br_scalar s2)

Arguments:
br_vector2 * v1

A pointer to the destination vector.

br_scalar s1

The first vector element (x axis component).

br_scalar s2

The second vector element (y axis component).

Example:
br_vector2 *va;
...
BrVector2Set(va,BR_SCALAR(1.0),BR_SCALAR(-1.0));

BrVector2SetFloat()

Description:
Set a vector from a pair of standard C floating point numbers.

Declaration:
void BrVector2SetFloat(br_vector2* v1, float f1, float f2)

Arguments:
br_vector2 * v1

A pointer to the destination vector.

float f1

The first vector element (x axis component).

float f2

The second vector element (y axis component).

Example:
br_vector2 *va;
...
BrVector2Set(va,1.f,-1.f);


BrVector2SetInt()

Description:
Set a vector from a pair of standard C integers.

Declaration:
void BrVector2SetInt(br_vector2* v1, int i1, int i2)

Arguments:
br_vector2 * v1

A pointer to the destination vector.

int i1

The first vector element (x axis component).

int i2

The second vector element (y axis component).

Example:
br_vector2 *va;
...
BrVector2Set(va,1,-1);



Generated with
CERN WebMaker