 Angel 3.2 A 2D Game Prototyping Engine
Vector3 Struct Reference

A three-dimensional floating point vector and associated math functions. More...

`#include <Vector3.h>`

## Public Member Functions

Vector3 (float x, float y, float z)

Vector3 (float value)

Vector3 ()

float Length ()

float LengthSquared ()

void Normalize ()

bool operator== (const Vector3 &v) const

bool operator!= (const Vector3 &v) const

Vector3 operator- () const

Vector3 operator- (const Vector3 &v) const

Vector3 operator+ (const Vector3 &v) const

Vector3 operator/ (float divider) const

Vector3 operator* (float scaleFactor) const

Vector3operator+= (const Vector3 &v)

Vector3operator-= (const Vector3 &v)

Vector3operator*= (float f)

Vector3operator/= (float f)

## Static Public Member Functions

static float Distance (const Vector3 &value1, const Vector3 &value2)

static float DistanceSquared (const Vector3 &value1, const Vector3 &value2)

static float Dot (const Vector3 &value1, const Vector3 &value2)

static Vector3 Normalize (const Vector3 &value)

static Vector3 Reflect (const Vector3 &vector, const Vector3 &normal)

static Vector3 Min (const Vector3 &value1, const Vector3 &value2)

static Vector3 Max (const Vector3 &value1, const Vector3 &value2)

static Vector3 Clamp (const Vector3 &value1, const Vector3 &min, const Vector3 &max)

static Vector3 Lerp (const Vector3 &value1, const Vector3 &value2, float amount)

static Vector3 Negate (const Vector3 &value)

float X

float Y

float Z

## Static Public Attributes

static Vector3 Zero

static Vector3 One

static Vector3 UnitX

static Vector3 UnitY

static Vector3 UnitZ

## Detailed Description

A floating point three-dimensional vector. Can be used either as a traditional vector (indicating a direction) or a position (treating X, Y, and Z as coordinates).

Definition at line 38 of file Vector3.h.

## Constructor & Destructor Documentation

 Vector3::Vector3 ( float x, float y, float z )

Constructor to initialize the vector to set dimensions

Parameters
 x The X dimension y The Y dimension z The Z dimension

Definition at line 43 of file Vector3.cpp.

 Vector3::Vector3 ( float value )

Constructor to initialize the vector to uniform dimensions

Parameters
 value The value to use for the X, Y, and Z dimensions

Definition at line 49 of file Vector3.cpp.

 Vector3::Vector3 ( )

Constructor to initialize a zero-length vector (0, 0, 0)

Definition at line 55 of file Vector3.cpp.

## Member Function Documentation

 float Vector3::Length ( )

Get the absolute magnitude of the vector. Uses a square-root, so be careful calling this too much within a loop.

Returns
The length (magnitude) of the vector

Definition at line 61 of file Vector3.cpp.

 float Vector3::LengthSquared ( )

Get the squared magnitude of the vector – if all you care about is comparison, it's a lot faster to consider the squared lengths of the vectors.

Returns
The length (magnitude) of the vector squared

Definition at line 66 of file Vector3.cpp.

 float Vector3::Distance ( const Vector3 & value1, const Vector3 & value2 )
static

Get the absolute distance between two points (most useful if the Vector2 represents a position). Uses a square-root, so be careful calling this too much within a loop.

Parameters
 value1 The first point value2 The second point
Returns
The distance between the two points

Definition at line 71 of file Vector3.cpp.

 float Vector3::DistanceSquared ( const Vector3 & value1, const Vector3 & value2 )
static

Get the absolute distance between two points – if all you care about is comparison, it's a lot faster to consider the squared lengths of the vectors.

Parameters
 value1 The first point value2 The second point
Returns
The distance between the two points squared

Definition at line 76 of file Vector3.cpp.

 float Vector3::Dot ( const Vector3 & value1, const Vector3 & value2 )
static

Get the dot product of two vectors.

Parameters
 value1 The first vector value2 The second vector
Returns
The dot product

Definition at line 82 of file Vector3.cpp.

 void Vector3::Normalize ( )

Normalizes a vector in place – retains its direction, but ensures that its magnitude is equal to 1.0.

Definition at line 87 of file Vector3.cpp.

 Vector3 Vector3::Normalize ( const Vector3 & value )
static

Get the normalized value for a Vector2 without affecting the original.

Parameters
 value The Vector3 to normalize
Returns
A normalized version of the passed-in Vector3

Definition at line 107 of file Vector3.cpp.

 Vector3 Vector3::Reflect ( const Vector3 & vector, const Vector3 & normal )
static

Reflect one Vector around another

Parameters
 vector The vector to reflect normal The normal to reflect it around
Returns
The new vector resulting from the reflection

Definition at line 114 of file Vector3.cpp.

 Vector3 Vector3::Min ( const Vector3 & value1, const Vector3 & value2 )
static

Get a new vector from the minimum X, Y, and Z of the two

Returns
The vector composed from minimums on all axes

Definition at line 119 of file Vector3.cpp.

 Vector3 Vector3::Max ( const Vector3 & value1, const Vector3 & value2 )
static

Get a new vector from the maximum X, Y, and Z of the two

Returns
The vector composed from the maximums on all axes

Definition at line 124 of file Vector3.cpp.

 Vector3 Vector3::Clamp ( const Vector3 & value1, const Vector3 & min, const Vector3 & max )
static

Clamp a vector to a given minimum and maximum

Parameters
 value The vector to be clamped min The vector representing the X, Y, and Z minimums for the clamping max The vector representing the X, Y, and Z maximums for the clamping
Returns
The clamped vector

Definition at line 129 of file Vector3.cpp.

 Vector3 Vector3::Lerp ( const Vector3 & value1, const Vector3 & value2, float amount )
static

Perform a linear interpolation between two vectors

Parameters
 value1 The starting point vector value2 The ending point vector amount The amount (from 0.0 to 1.0) to interpolate between them
Returns
The interpolated vector

Definition at line 134 of file Vector3.cpp.

 Vector3 Vector3::Negate ( const Vector3 & value )
static

Get a negated vector – if you add the result and the original, you should get a zero-length vector (0, 0)

Parameters
 value The vector to negate
Returns
The negated vector

Definition at line 138 of file Vector3.cpp.

## Member Data Documentation

 float Vector3::X

The X dimension, publicly available because it's so often gotten or set and there's no good reason to encapsulate it.

Definition at line 44 of file Vector3.h.

 float Vector3::Y

The Z dimension, publicly available because it's so often gotten or set and there's no good reason to encapsulate it.

Definition at line 50 of file Vector3.h.

 float Vector3::Z

The Z dimension, publicly available because it's so often gotten or set and there's no good reason to encapsulate it.

Definition at line 56 of file Vector3.h.

 Vector3 Vector3::Zero
static

A reference to a zero-length vector (0, 0, 0)

NB: We can't make a static member variable constant, so it is possible to change this value. That is a horrible idea and will make the engine act "odd" at best.

Definition at line 65 of file Vector3.h.

 Vector3 Vector3::One
static

A reference to a (1, 1, 1) vector

NB: We can't make a static member variable constant, so it is possible to change this value. That is a horrible idea and will make the engine act "odd" at best.

Definition at line 74 of file Vector3.h.

 Vector3 Vector3::UnitX
static

A reference to a (1, 0, 0) vector

NB: We can't make a static member variable constant, so it is possible to change this value. That is a horrible idea and will make the engine act "odd" at best.

Definition at line 83 of file Vector3.h.

 Vector3 Vector3::UnitY
static

A reference to a (0, 1, 0) vector

NB: We can't make a static member variable constant, so it is possible to change this value. That is a horrible idea and will make the engine act "odd" at best.

Definition at line 92 of file Vector3.h.

 Vector3 Vector3::UnitZ
static

A reference to a (0, 0, 1) vector

NB: We can't make a static member variable constant, so it is possible to change this value. That is a horrible idea and will make the engine act "odd" at best.

Definition at line 101 of file Vector3.h.

The documentation for this struct was generated from the following files: