PixelLightAPI
.
|
2D vector More...
#include <Vector2.h>
Public Types | |
enum | Component { X = 0, Y = 1 } |
Vector component. More... | |
Public Member Functions | |
Vector2 () | |
Default constructor setting all components to 0. | |
Vector2 (float fX, float fY) | |
Vector2 (const float fV[]) | |
Vector2 (const Vector2 &vV) | |
PLMATH_API | Vector2 (const Vector3 &vV) |
PLMATH_API | Vector2 (const Vector4 &vV) |
Vector2 (const PLCore::String &sString) | |
~Vector2 () | |
Vector2 & | operator= (const float fV[]) |
Vector2 & | operator= (const Vector2 &vV) |
PLMATH_API Vector2 & | operator= (const Vector3 &vV) |
PLMATH_API Vector2 & | operator= (const Vector4 &vV) |
bool | operator== (const Vector2 &vV) const |
Compares two vectors. | |
bool | operator!= (const Vector2 &vV) const |
Compares two vectors. | |
bool | operator< (const Vector2 &vV) const |
Compares two vectors lexicographically. | |
bool | operator> (const Vector2 &vV) const |
Compares two vectors lexicographically. | |
bool | operator<= (const Vector2 &vV) const |
Compares two vectors lexicographically. | |
bool | operator>= (const Vector2 &vV) const |
Compares two vectors lexicographically. | |
Vector2 | operator+ (const Vector2 &vV) const |
Vector2 | operator+ (float fN) const |
Vector2 & | operator+= (const Vector2 &vV) |
Vector2 & | operator+= (float fN) |
Vector2 | operator- () const |
Vector2 | operator- (float fN) const |
Vector2 | operator- (const Vector2 &vV) const |
Vector2 & | operator-= (const Vector2 &vV) |
Vector2 & | operator-= (float fN) |
Vector2 | operator* (const Vector2 &vV) const |
Per component multiplication. | |
Vector2 | operator* (float fS) const |
Vector2 & | operator*= (const Vector2 &vV) |
Per component multiplication. | |
Vector2 & | operator*= (float fS) |
PLMATH_API Vector2 & | operator*= (const Matrix3x3 &mRot) |
Rotates the vector. | |
PLMATH_API Vector2 & | operator*= (const Matrix3x4 &mRot) |
Rotates the vector. | |
PLMATH_API Vector2 & | operator*= (const Matrix4x4 &mTrans) |
Transforms the vector. | |
Vector2 | operator/ (const Vector2 &vV) const |
Per component division. | |
Vector2 | operator/ (float fS) const |
Vector2 & | operator/= (const Vector2 &vV) |
Per component division. | |
Vector2 & | operator/= (float fS) |
operator float * () | |
operator const float * () const | |
float & | operator[] (int nIndex) |
const float & | operator[] (int nIndex) const |
void | GetXY (float &fX, float &fY) const |
float | GetX () const |
float | GetY () const |
void | SetXY (float fX=0.0f, float fY=0.0f) |
void | SetXY (const float fV[]) |
void | SetX (float fX=0.0f) |
void | SetY (float fY=0.0f) |
void | IncXY (float fX=0.0f, float fY=0.0f) |
void | IncXY (const float fV[]) |
void | IncX (float fX) |
void | IncY (float fY) |
bool | IsNull () const |
Returns whether the vector is null or not. | |
bool | IsPacked () const |
Returns whether the vector is packed (within range of 0-1) or not. | |
void | PackTo01 () |
Packs/clamps the vector into a range of 0-1. | |
Vector2 | GetPackedTo01 () const |
Returns a vector which is packed/clamped into the range of 0-1. | |
void | UnpackFrom01 () |
Unpacks the packed vector into a range of -1 to 1. | |
Vector2 | GetUnpackedFrom01 () const |
Returns a unpacked vector of the range of -1 to 1. | |
Component | GetSmallestComponent () const |
Returns the smallest component. | |
float | GetSmallestValue () const |
Returns the value of the smallest component. | |
Component | GetGreatestComponent () const |
Returns the greatest component. | |
float | GetGreatestValue () const |
Returns the value of the greatest component. | |
void | Invert () |
Inverts the vector. | |
Vector2 | GetInverted () const |
Returns the inverted vector. | |
float | GetLength () const |
Returns the length of the vector (also called magnitude) | |
float | GetSquaredLength () const |
Returns the squared length of the vector (also called norm) | |
void | SetLength (float fLength=1.0f) |
Sets the vector to the given length. | |
Vector2 & | Normalize () |
Normalizes the vector. | |
Vector2 | GetNormalized () const |
Returns the normalized vector. | |
float | GetDistance (const Vector2 &vV) const |
Returns the distance to another vector. | |
float | GetSquaredDistance (const Vector2 &vV) const |
Returns the squared distance to another vector. | |
float | DotProduct (const Vector2 &vV) const |
Returns the dot product of two vectors. | |
Vector2 | ProjectVector (const Vector2 &vA, const Vector2 &vB) const |
Project vector a onto another vector b. | |
float | GetAngle (const Vector2 &vV) const |
Calculates the angle between two vectors. | |
PLMATH_API PLCore::String | ToString () const |
To string. | |
PLMATH_API bool | FromString (const PLCore::String &sString) |
From string. | |
Public Attributes | |
union { | |
float fV [2] | |
Vertex element array access. | |
struct { | |
float x | |
float y | |
} | |
Known vertex element names when dealing with positions or directions. | |
struct { | |
float u | |
float v | |
} | |
Known vertex element names when dealing with texture coordinates. | |
}; | |
Some direct vertex element accesses. | |
Static Public Attributes | |
static PLMATH_API const Vector2 | Zero |
static PLMATH_API const Vector2 | One |
static PLMATH_API const Vector2 | NegativeOne |
static PLMATH_API const Vector2 | UnitX |
static PLMATH_API const Vector2 | UnitY |
static PLMATH_API const Vector2 | NegativeUnitX |
static PLMATH_API const Vector2 | NegativeUnitY |
2D vector
PLMath::Vector2::Vector2 | ( | ) | [inline] |
Default constructor setting all components to 0.
PLMath::Vector2::Vector2 | ( | float | fX, |
float | fY | ||
) | [inline] |
PLMath::Vector2::Vector2 | ( | const float | fV[] | ) | [inline] |
PLMath::Vector2::Vector2 | ( | const Vector2 & | vV | ) | [inline] |
PLMATH_API PLMath::Vector2::Vector2 | ( | const Vector3 & | vV | ) |
PLMATH_API PLMath::Vector2::Vector2 | ( | const Vector4 & | vV | ) |
PLMath::Vector2::Vector2 | ( | const PLCore::String & | sString | ) | [inline] |
PLMath::Vector2::~Vector2 | ( | ) | [inline] |
Vector2 & PLMath::Vector2::operator= | ( | const float | fV[] | ) | [inline] |
bool PLMath::Vector2::operator== | ( | const Vector2 & | vV | ) | const [inline] |
Compares two vectors.
[in] | vV | Vector to compare with |
bool PLMath::Vector2::operator!= | ( | const Vector2 & | vV | ) | const [inline] |
Compares two vectors.
[in] | vV | Vector to compare with |
bool PLMath::Vector2::operator< | ( | const Vector2 & | vV | ) | const [inline] |
Compares two vectors lexicographically.
[in] | vV | Vector to compare with |
bool PLMath::Vector2::operator> | ( | const Vector2 & | vV | ) | const [inline] |
Compares two vectors lexicographically.
[in] | vV | Vector to compare with |
bool PLMath::Vector2::operator<= | ( | const Vector2 & | vV | ) | const [inline] |
Compares two vectors lexicographically.
[in] | vV | Vector to compare with |
bool PLMath::Vector2::operator>= | ( | const Vector2 & | vV | ) | const [inline] |
Compares two vectors lexicographically.
[in] | vV | Vector to compare with |
Vector2 PLMath::Vector2::operator+ | ( | float | fN | ) | const [inline] |
Vector2 & PLMath::Vector2::operator+= | ( | float | fN | ) | [inline] |
Vector2 PLMath::Vector2::operator- | ( | ) | const [inline] |
Vector2 PLMath::Vector2::operator- | ( | float | fN | ) | const [inline] |
Vector2 & PLMath::Vector2::operator-= | ( | float | fN | ) | [inline] |
Per component multiplication.
[in] | vV | Vector to multiplicate with |
Vector2 PLMath::Vector2::operator* | ( | float | fS | ) | const [inline] |
Per component multiplication.
[in] | vV | Vector to multiplicate with |
Vector2 & PLMath::Vector2::operator*= | ( | float | fS | ) | [inline] |
Rotates the vector.
[in] | mRot | Matrix which rotates the vector |
Rotates the vector.
[in] | mRot | Matrix which rotates the vector |
Transforms the vector.
[in] | mTrans | Matrix which transforms the vector |
Per component division.
[in] | vV | Vector to divide through |
Vector2 PLMath::Vector2::operator/ | ( | float | fS | ) | const [inline] |
Per component division.
[in] | vV | Vector to divide through |
Vector2 & PLMath::Vector2::operator/= | ( | float | fS | ) | [inline] |
PLMath::Vector2::operator float * | ( | ) | [inline] |
PLMath::Vector2::operator const float * | ( | ) | const [inline] |
float & PLMath::Vector2::operator[] | ( | int | nIndex | ) | [inline] |
const float & PLMath::Vector2::operator[] | ( | int | nIndex | ) | const [inline] |
void PLMath::Vector2::GetXY | ( | float & | fX, |
float & | fY | ||
) | const [inline] |
float PLMath::Vector2::GetX | ( | ) | const [inline] |
float PLMath::Vector2::GetY | ( | ) | const [inline] |
void PLMath::Vector2::SetXY | ( | float | fX = 0.0f , |
float | fY = 0.0f |
||
) | [inline] |
void PLMath::Vector2::SetXY | ( | const float | fV[] | ) | [inline] |
void PLMath::Vector2::SetX | ( | float | fX = 0.0f | ) | [inline] |
void PLMath::Vector2::SetY | ( | float | fY = 0.0f | ) | [inline] |
void PLMath::Vector2::IncXY | ( | float | fX = 0.0f , |
float | fY = 0.0f |
||
) | [inline] |
void PLMath::Vector2::IncXY | ( | const float | fV[] | ) | [inline] |
void PLMath::Vector2::IncX | ( | float | fX | ) | [inline] |
void PLMath::Vector2::IncY | ( | float | fY | ) | [inline] |
bool PLMath::Vector2::IsNull | ( | ) | const [inline] |
Returns whether the vector is null or not.
bool PLMath::Vector2::IsPacked | ( | ) | const [inline] |
Returns whether the vector is packed (within range of 0-1) or not.
void PLMath::Vector2::PackTo01 | ( | ) | [inline] |
Packs/clamps the vector into a range of 0-1.
Vector2 PLMath::Vector2::GetPackedTo01 | ( | ) | const [inline] |
Returns a vector which is packed/clamped into the range of 0-1.
void PLMath::Vector2::UnpackFrom01 | ( | ) | [inline] |
Unpacks the packed vector into a range of -1 to 1.
Vector2 PLMath::Vector2::GetUnpackedFrom01 | ( | ) | const [inline] |
Returns a unpacked vector of the range of -1 to 1.
Vector2::Component PLMath::Vector2::GetSmallestComponent | ( | ) | const [inline] |
Returns the smallest component.
float PLMath::Vector2::GetSmallestValue | ( | ) | const [inline] |
Returns the value of the smallest component.
Vector2::Component PLMath::Vector2::GetGreatestComponent | ( | ) | const [inline] |
Returns the greatest component.
float PLMath::Vector2::GetGreatestValue | ( | ) | const [inline] |
Returns the value of the greatest component.
void PLMath::Vector2::Invert | ( | ) | [inline] |
Inverts the vector.
Vector2 PLMath::Vector2::GetInverted | ( | ) | const [inline] |
float PLMath::Vector2::GetLength | ( | ) | const [inline] |
Returns the length of the vector (also called magnitude)
float PLMath::Vector2::GetSquaredLength | ( | ) | const [inline] |
Returns the squared length of the vector (also called norm)
void PLMath::Vector2::SetLength | ( | float | fLength = 1.0f | ) | [inline] |
Sets the vector to the given length.
[in] | fLength | Length to set |
Vector2 & PLMath::Vector2::Normalize | ( | ) | [inline] |
Normalizes the vector.
Vector2 PLMath::Vector2::GetNormalized | ( | ) | const [inline] |
float PLMath::Vector2::GetDistance | ( | const Vector2 & | vV | ) | const [inline] |
Returns the distance to another vector.
[in] | vV | The other vector |
float PLMath::Vector2::GetSquaredDistance | ( | const Vector2 & | vV | ) | const [inline] |
Returns the squared distance to another vector.
[in] | vV | The other vector |
float PLMath::Vector2::DotProduct | ( | const Vector2 & | vV | ) | const [inline] |
Returns the dot product of two vectors.
[in] | vV | Second vector |
Vector2 PLMath::Vector2::ProjectVector | ( | const Vector2 & | vA, |
const Vector2 & | vB | ||
) | const [inline] |
Project vector a onto another vector b.
Project the vector onto another vector.
[in] | vA | Vector to project |
[in] | vB | Vector to project onto |
^. / . / . a / . / . a.DotProduct(b) / . projb(a) = b * ----------------- / . b.DotProduct(b) / . --->____. b ^= projb(a)
float PLMath::Vector2::GetAngle | ( | const Vector2 & | vV | ) | const [inline] |
Calculates the angle between two vectors.
Calculates the angle between two vectos.
[in] | vV | Second vector |
v1.DotProduct(v2) cos A = -------------------------------- v1.GetLength() * v2.GetLength()
PLMATH_API PLCore::String PLMath::Vector2::ToString | ( | ) | const |
To string.
PLMATH_API bool PLMath::Vector2::FromString | ( | const PLCore::String & | sString | ) |
From string.
[in] | sString | String with the data |
PLMATH_API const Vector2 PLMath::Vector2::Zero [static] |
0.0, 0.0
PLMATH_API const Vector2 PLMath::Vector2::One [static] |
1.0, 1.0
PLMATH_API const Vector2 PLMath::Vector2::NegativeOne [static] |
-1.0, -1.0
PLMATH_API const Vector2 PLMath::Vector2::UnitX [static] |
1.0, 0.0
PLMATH_API const Vector2 PLMath::Vector2::UnitY [static] |
0.0, 1.0
PLMATH_API const Vector2 PLMath::Vector2::NegativeUnitX [static] |
-1.0, 0.0
PLMATH_API const Vector2 PLMath::Vector2::NegativeUnitY [static] |
0.0, -1.0
float PLMath::Vector2::fV[2] |
Vertex element array access.
float PLMath::Vector2::x |
float PLMath::Vector2::y |
float PLMath::Vector2::u |
float PLMath::Vector2::v |
union { ... } |
Some direct vertex element accesses.
|