G3D::Vector3 Class ReferenceSwizzles Vector classes have swizzle operators, e.g.
More...
#include <Vector3.h>
List of all members.
|
Public Types |
| enum | Axis { X_AXIS = 0,
Y_AXIS = 1,
Z_AXIS = 2,
DETECT_AXIS = -1
} |
Public Member Functions |
| float | average () const |
| Vector3 | clamp (float low, float high) const |
| Vector3 | clamp (const Vector3 &low, const Vector3 &high) const |
| Matrix3 | cross () const |
| Vector3 | cross (const Vector3 &rkVector) const |
| void | deserialize (class TextInput &t) |
| void | deserialize (class BinaryInput &b) |
| Vector3 | direction () const |
| Vector3 | directionOrZero () const |
| float | dot (const Vector3 &rkVector) const |
| Vector3 | fastDirection () const |
| Vector3 | fastUnit () const |
| bool | fuzzyEq (const Vector3 &other) const |
| bool | fuzzyNe (const Vector3 &other) const |
| size_t | hashCode () const |
| bool | isFinite () const |
| bool | isUnit () const |
| bool | isZero () const |
| float | length () const |
| Vector3 | lerp (const Vector3 &v, float alpha) const |
| float | magnitude () const |
| Vector3 | max (const Vector3 &v) const |
| Vector3 | min (const Vector3 &v) const |
| Vector3 | operator * (const Vector3 &v) const |
| Vector3 | operator * (float s) const |
| Vector3 & | operator *= (const Vector3 &v) |
| Vector3 & | operator *= (float s) |
| | operator const float * () const |
| | operator float * () |
| bool | operator!= (const Vector3 &rkVector) const |
| Vector3 | operator+ (const Vector3 &v) const |
| Vector3 & | operator+= (const Vector3 &v) |
| Vector3 | operator- () const |
| Vector3 | operator- (const Vector3 &v) const |
| Vector3 & | operator-= (const Vector3 &v) |
| Vector3 | operator/ (const Vector3 &v) const |
| Vector3 | operator/ (float s) const |
| Vector3 & | operator/= (const Vector3 &v) |
| Vector3 & | operator/= (float s) |
| Vector3 & | operator= (const Vector3 &rkVector) |
| bool | operator== (const Vector3 &rkVector) const |
| float & | operator[] (int i) |
| const float & | operator[] (int i) const |
| Axis | primaryAxis () const |
| Vector3 | reflectionDirection (const Vector3 &normal) const |
| Vector3 | refractionDirection (const Vector3 &normal, float iInside, float iOutside) const |
| void | serialize (class TextOutput &t) const |
| void | serialize (class BinaryOutput &b) const |
| float | squaredLength () const |
| float | squaredMagnitude () const |
| float | sum () const |
| std::string | toString () const |
| Vector3 | unit () const |
| Vector3 | unitCross (const Vector3 &rkVector) const |
| float | unitize (float tolerance=1e-06) |
| | Vector3 (class TextInput &t) |
| | Vector3 (const class Vector3int16 &v) |
| | Vector3 (const Vector3 &rkVector) |
| | Vector3 (double coordinate[3]) |
| | Vector3 (float coordinate[3]) |
| | Vector3 (const class Vector2 &v, float _z) |
| | Vector3 (float _x, float _y, float _z) |
| | Vector3 (class BinaryInput &b) |
| | Vector3 (const Vector4int8 &) |
| | Vector3 () |
| Vector2 | xx () const |
| Vector3 | xxx () const |
| Vector4 | xxxx () const |
| Vector4 | xxxy () const |
| Vector4 | xxxz () const |
| Vector3 | xxy () const |
| Vector4 | xxyx () const |
| Vector4 | xxyy () const |
| Vector4 | xxyz () const |
| Vector3 | xxz () const |
| Vector4 | xxzx () const |
| Vector4 | xxzy () const |
| Vector4 | xxzz () const |
| Vector2 | xy () const |
| Vector3 | xyx () const |
| Vector4 | xyxx () const |
| Vector4 | xyxy () const |
| Vector4 | xyxz () const |
| Vector3 | xyy () const |
| Vector4 | xyyx () const |
| Vector4 | xyyy () const |
| Vector4 | xyyz () const |
| Vector3 | xyz () const |
| Vector4 | xyzx () const |
| Vector4 | xyzy () const |
| Vector4 | xyzz () const |
| Vector2 | xz () const |
| Vector3 | xzx () const |
| Vector4 | xzxx () const |
| Vector4 | xzxy () const |
| Vector4 | xzxz () const |
| Vector3 | xzy () const |
| Vector4 | xzyx () const |
| Vector4 | xzyy () const |
| Vector4 | xzyz () const |
| Vector3 | xzz () const |
| Vector4 | xzzx () const |
| Vector4 | xzzy () const |
| Vector4 | xzzz () const |
| Vector2 | yx () const |
| Vector3 | yxx () const |
| Vector4 | yxxx () const |
| Vector4 | yxxy () const |
| Vector4 | yxxz () const |
| Vector3 | yxy () const |
| Vector4 | yxyx () const |
| Vector4 | yxyy () const |
| Vector4 | yxyz () const |
| Vector3 | yxz () const |
| Vector4 | yxzx () const |
| Vector4 | yxzy () const |
| Vector4 | yxzz () const |
| Vector2 | yy () const |
| Vector3 | yyx () const |
| Vector4 | yyxx () const |
| Vector4 | yyxy () const |
| Vector4 | yyxz () const |
| Vector3 | yyy () const |
| Vector4 | yyyx () const |
| Vector4 | yyyy () const |
| Vector4 | yyyz () const |
| Vector3 | yyz () const |
| Vector4 | yyzx () const |
| Vector4 | yyzy () const |
| Vector4 | yyzz () const |
| Vector2 | yz () const |
| Vector3 | yzx () const |
| Vector4 | yzxx () const |
| Vector4 | yzxy () const |
| Vector4 | yzxz () const |
| Vector3 | yzy () const |
| Vector4 | yzyx () const |
| Vector4 | yzyy () const |
| Vector4 | yzyz () const |
| Vector3 | yzz () const |
| Vector4 | yzzx () const |
| Vector4 | yzzy () const |
| Vector4 | yzzz () const |
| Vector2 | zx () const |
| Vector3 | zxx () const |
| Vector4 | zxxx () const |
| Vector4 | zxxy () const |
| Vector4 | zxxz () const |
| Vector3 | zxy () const |
| Vector4 | zxyx () const |
| Vector4 | zxyy () const |
| Vector4 | zxyz () const |
| Vector3 | zxz () const |
| Vector4 | zxzx () const |
| Vector4 | zxzy () const |
| Vector4 | zxzz () const |
| Vector2 | zy () const |
| Vector3 | zyx () const |
| Vector4 | zyxx () const |
| Vector4 | zyxy () const |
| Vector4 | zyxz () const |
| Vector3 | zyy () const |
| Vector4 | zyyx () const |
| Vector4 | zyyy () const |
| Vector4 | zyyz () const |
| Vector3 | zyz () const |
| Vector4 | zyzx () const |
| Vector4 | zyzy () const |
| Vector4 | zyzz () const |
| Vector2 | zz () const |
| Vector3 | zzx () const |
| Vector4 | zzxx () const |
| Vector4 | zzxy () const |
| Vector4 | zzxz () const |
| Vector3 | zzy () const |
| Vector4 | zzyx () const |
| Vector4 | zzyy () const |
| Vector4 | zzyz () const |
| Vector3 | zzz () const |
| Vector4 | zzzx () const |
| Vector4 | zzzy () const |
| Vector4 | zzzz () const |
Static Public Member Functions |
| static Vector3 | cosRandom (const Vector3 &normal) |
| static void | generateOrthonormalBasis (Vector3 &rkU, Vector3 &rkV, Vector3 &rkW, bool bUnitLengthW=true) |
| static Vector3 | hemiRandom (const Vector3 &normal) |
| static const Vector3 & | inf () |
| static const Vector3 & | maxFinite () |
| static const Vector3 & | minFinite () |
| static const Vector3 & | nan () |
| static const Vector3 & | one () |
| static void | orthonormalize (Vector3 akVector[3]) |
| static Vector3 | random () |
| static const Vector3 & | unitX () |
| static const Vector3 & | unitY () |
| static const Vector3 & | unitZ () |
| static const Vector3 & | zero () |
Public Attributes |
| float | x |
| float | y |
| float | z |
Static Public Attributes |
| static Vector3 | dummy |
Detailed Description
Swizzles Vector classes have swizzle operators, e.g.
v.xy(), that allow selection of arbitrary sub-fields. These cannot be used as write masks. Examples
Vector3 v(1, 2, 3);
Vector3 j;
Vector2 b;
b = v.xz();
j = b.xx();
Warning
Do not subclass-- this implementation makes assumptions about the memory layout.
Member Enumeration Documentation
- Enumerator:
-
| X_AXIS |
|
| Y_AXIS |
|
| Z_AXIS |
|
| DETECT_AXIS |
|
Constructor & Destructor Documentation
| G3D::Vector3::Vector3 |
( |
|
) |
[inline] |
| G3D::Vector3::Vector3 |
( |
float |
_x, |
|
|
float |
_y, |
|
|
float |
_z | |
|
) |
| | [inline] |
| G3D::Vector3::Vector3 |
( |
const class Vector2 & |
v, |
|
|
float |
_z | |
|
) |
| | |
| G3D::Vector3::Vector3 |
( |
float |
coordinate[3] |
) |
[inline] |
| G3D::Vector3::Vector3 |
( |
double |
coordinate[3] |
) |
[inline] |
| G3D::Vector3::Vector3 |
( |
const Vector3 & |
rkVector |
) |
[inline] |
| G3D::Vector3::Vector3 |
( |
class TextInput & |
t |
) |
|
Member Function Documentation
| float G3D::Vector3::average |
( |
|
) |
const [inline] |
| Vector3 G3D::Vector3::clamp |
( |
float |
low, |
|
|
float |
high | |
|
) |
| | const [inline] |
| static Vector3 G3D::Vector3::cosRandom |
( |
const Vector3 & |
normal |
) |
[static] |
Random unit vector, distributed so that the probability of V is proportional to max(V dot Normal, 0).
- Referenced Code:
- Henrik Wann Jensen, Realistic Image Synthesis using Photon Mapping eqn 2.24
| class Matrix3 G3D::Vector3::cross |
( |
|
) |
const |
Returns a matrix such that v.cross() * w = v.cross(w).
[ 0 -v.z v.y ]
[ v.z 0 -v.x ]
[ -v.y v.x 0 ]
| Vector3 G3D::Vector3::cross |
( |
const Vector3 & |
rkVector |
) |
const [inline] |
Cross product.
Note that two cross products in a row can be computed more cheaply: v1 x (v2 x v3) = (v1 dot v3) v2 - (v1 dot v2) v3.
| void G3D::Vector3::deserialize |
( |
class TextInput & |
t |
) |
|
| void G3D::Vector3::deserialize |
( |
class BinaryInput & |
b |
) |
|
| Vector3 G3D::Vector3::direction |
( |
|
) |
const [inline] |
The result is a nan vector if the length is almost zero.
| Vector3 G3D::Vector3::directionOrZero |
( |
|
) |
const [inline] |
Returns Vector3::zero() if the length is nearly zero, otherwise returns a unit vector.
| float G3D::Vector3::dot |
( |
const Vector3 & |
rkVector |
) |
const [inline] |
| Vector3 G3D::Vector3::fastDirection |
( |
|
) |
const [inline] |
| Vector3 G3D::Vector3::fastUnit |
( |
|
) |
const [inline] |
Returns a normalized vector.
May be computed with lower precision than unit
| bool G3D::Vector3::fuzzyEq |
( |
const Vector3 & |
other |
) |
const [inline] |
| bool G3D::Vector3::fuzzyNe |
( |
const Vector3 & |
other |
) |
const [inline] |
| static void G3D::Vector3::generateOrthonormalBasis |
( |
Vector3 & |
rkU, |
|
|
Vector3 & |
rkV, |
|
|
Vector3 & |
rkW, |
|
|
bool |
bUnitLengthW = true | |
|
) |
| | [static] |
| size_t G3D::Vector3::hashCode |
( |
|
) |
const |
| static Vector3 G3D::Vector3::hemiRandom |
( |
const Vector3 & |
normal |
) |
[static] |
Random vector distributed over the hemisphere about normal.
| static const Vector3& G3D::Vector3::inf |
( |
|
) |
[inline, static] |
| bool G3D::Vector3::isFinite |
( |
|
) |
const [inline] |
Returns true if this vector has finite length.
| bool G3D::Vector3::isUnit |
( |
|
) |
const [inline] |
Returns true if this vector has length ~= 1.
| bool G3D::Vector3::isZero |
( |
|
) |
const [inline] |
Returns true if this vector has length ~= 0.
| float G3D::Vector3::length |
( |
|
) |
const [inline] |
| Vector3 G3D::Vector3::lerp |
( |
const Vector3 & |
v, |
|
|
float |
alpha | |
|
) |
| | const [inline] |
| float G3D::Vector3::magnitude |
( |
|
) |
const [inline] |
| static const Vector3& G3D::Vector3::maxFinite |
( |
|
) |
[inline, static] |
Largest representable vector.
| static const Vector3& G3D::Vector3::minFinite |
( |
|
) |
[inline, static] |
Smallest (most negative) representable vector.
| static const Vector3& G3D::Vector3::nan |
( |
|
) |
[inline, static] |
| static const Vector3& G3D::Vector3::one |
( |
|
) |
[inline, static] |
| Vector3 G3D::Vector3::operator * |
( |
float |
s |
) |
const [inline] |
| Vector3 & G3D::Vector3::operator *= |
( |
float |
s |
) |
[inline] |
| G3D::Vector3::operator const float * |
( |
|
) |
const [inline] |
| G3D::Vector3::operator float * |
( |
|
) |
[inline] |
| bool G3D::Vector3::operator!= |
( |
const Vector3 & |
rkVector |
) |
const [inline] |
| Vector3 G3D::Vector3::operator- |
( |
|
) |
const [inline] |
| Vector3 G3D::Vector3::operator/ |
( |
float |
s |
) |
const |
| Vector3& G3D::Vector3::operator/= |
( |
float |
s |
) |
|
| Vector3 & G3D::Vector3::operator= |
( |
const Vector3 & |
rkVector |
) |
[inline] |
| bool G3D::Vector3::operator== |
( |
const Vector3 & |
rkVector |
) |
const [inline] |
| float & G3D::Vector3::operator[] |
( |
int |
i |
) |
[inline] |
| const float & G3D::Vector3::operator[] |
( |
int |
i |
) |
const [inline] |
| static void G3D::Vector3::orthonormalize |
( |
Vector3 |
akVector[3] |
) |
[static] |
Gram-Schmidt orthonormalization.
| Axis G3D::Vector3::primaryAxis |
( |
|
) |
const |
Returns the largest dimension.
Particularly convenient for determining which plane to project a triangle onto for point-in-polygon tests.
| static Vector3 G3D::Vector3::random |
( |
|
) |
[static] |
Random unit vector, uniformly distributed.
| Vector3 G3D::Vector3::reflectionDirection |
( |
const Vector3 & |
normal |
) |
const |
| Vector3 G3D::Vector3::refractionDirection |
( |
const Vector3 & |
normal, |
|
|
float |
iInside, |
|
|
float |
iOutside | |
|
) |
| | const |
Returns the direction of a refracted ray, where iExit is the index of refraction for the previous material and iEnter is the index of refraction for the new material.
Like Vector3::reflectionDirection, the result has length 1 and is pointed away from the intersection.
Returns Vector3::zero() in the case of total internal refraction.
- Parameters:
-
| iOutside | The index of refraction (eta) outside (on the positive normal side) of the surface. |
| iInside | The index of refraction (eta) inside (on the negative normal side) of the surface. |
See also G3D::Ray::refract.
N V
^ /
| /
|'-
__--
V'<--
| void G3D::Vector3::serialize |
( |
class TextOutput & |
t |
) |
const |
Format is "(%f, %f, %f)".
| void G3D::Vector3::serialize |
( |
class BinaryOutput & |
b |
) |
const |
Format is three float32's.
| float G3D::Vector3::squaredLength |
( |
|
) |
const [inline] |
Same as squaredMagnitude.
| float G3D::Vector3::squaredMagnitude |
( |
|
) |
const [inline] |
| float G3D::Vector3::sum |
( |
|
) |
const [inline] |
| std::string G3D::Vector3::toString |
( |
|
) |
const |
| Vector3 G3D::Vector3::unit |
( |
|
) |
const [inline] |
| Vector3 G3D::Vector3::unitCross |
( |
const Vector3 & |
rkVector |
) |
const [inline] |
| float G3D::Vector3::unitize |
( |
float |
tolerance = 1e-06 |
) |
|
| static const Vector3& G3D::Vector3::unitX |
( |
|
) |
[inline, static] |
| static const Vector3& G3D::Vector3::unitY |
( |
|
) |
[inline, static] |
| static const Vector3& G3D::Vector3::unitZ |
( |
|
) |
[inline, static] |
| Vector3 G3D::Vector3::xxx |
( |
|
) |
const |
| Vector4 G3D::Vector3::xxxx |
( |
|
) |
const |
| Vector4 G3D::Vector3::xxxy |
( |
|
) |
const |
| Vector4 G3D::Vector3::xxxz |
( |
|
) |
const |
| Vector3 G3D::Vector3::xxy |
( |
|
) |
const |
| Vector4 G3D::Vector3::xxyx |
( |
|
) |
const |
| Vector4 G3D::Vector3::xxyy |
( |
|
) |
const |
| Vector4 G3D::Vector3::xxyz |
( |
|
) |
const |
| Vector3 G3D::Vector3::xxz |
( |
|
) |
const |
| Vector4 G3D::Vector3::xxzx |
( |
|
) |
const |
| Vector4 G3D::Vector3::xxzy |
( |
|
) |
const |
| Vector4 G3D::Vector3::xxzz |
( |
|
) |
const |
|