#include <Vector.h>
Public Member Functions | |
Vector () | |
Default constructor, initializes the X, Y, Z components to 0 and W to 1. | |
Vector (float x, float y, float z) | |
Initializes the X, Y, Z components to the specified values and W to 1. | |
Vector (float x, float y, float z, float w) | |
Initializes all the components to the specified values. | |
float & | operator[] (int which) |
Mutable accessor for a Vector component. | |
float | operator[] (int which) const |
Immutable accessor for a Vector component. | |
const float * | toArray () const |
Accessor for the raw Vector data. | |
const Vector | normalize () const |
Normalize the Vector: divide all components by the Vector length. | |
float | length () const |
Returns the length of the Vector. | |
float | dot (const Vector &vert) const |
Computes the dot product between this Vector and another Vector. | |
const Vector | cross (const Vector &vert) const |
Computes the cross product between this Vector and another Vector. | |
float | angle (const Vector &vert) const |
Computes the angle (in radians) between this Vector and another Vector. | |
const Vector | add (const Vector &vert) const |
Computes the sum between the X, Y and Z components of this Vector and another Vector's. | |
const Vector | subtract (const Vector &vert) const |
Computes the difference between the X, Y and Z components of this Vector and another Vector's. | |
const Vector | scale (float scale) const |
Scales this vector's X, Y, and Z components by a given factor. | |
const Vector | multiplyLeft (const Matrix &matrix) const |
Transform this Vector by multiplying it on the left with the given Matrix. | |
const Vector | rangeCompress (float scale=1.0f) const |
Range compress the Vector to make it suitable for storage in a texture or a cubemap. | |
Static Public Attributes | |
const int | X = 0 |
The X coordinate index in the array representing this Vector. | |
const int | Y = 1 |
The Y coordinate index in the array representing this Vector. | |
const int | Z = 2 |
The Z coordinate index in the array representing this Vector. | |
const int | W = 3 |
The W coordinate index in the array representing this Vector. | |
const Vector | ORIGIN |
Constant vector representing the origin (0, 0, 0, 1). | |
Private Member Functions | |
void | initialize (float x, float y, float z, float w) |
Initialize the components to the specified values. | |
Private Attributes | |
float | m_data [4] |
The data array containing the X, Y, Z and W values. | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const Vector &vect) |
Insertion operator for this Vector into an output stream. |
|
Returns the length of the Vector. The length is computed by taking the square root of the sum of the squares of the X, Y and Z Vector components. |
|
Computes the angle (in radians) between this Vector and another Vector.
The angle is computed as follows: |
|
Transform this Vector by multiplying it on the left with the given Matrix. The resulting Vector's X, Y, and Z components are scaled by 1/W and the W component is set to 1. |
|
Range compress the Vector to make it suitable for storage in a texture or a cubemap. The range compression is done by adding 1 to the X, Y, and Z Vector components, dividing them by 2 and finally multiplying them by the scale parameter. The reverse operation is performed to uncompress the coordinates (for example, inside a pixel shader program). This method assumes that the X, Y, and Z components have values ranging from -1.0 to 1.0; the compression allows negative values to be represented in (otherwise) unsigned texture components (in which case scale would be 255: the maximum range for a texture component value). |