Support Forum       G3D Web Page     
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
G3D::Vector3 Class Reference


3x1 or 1x3 vector using float32 representation. More...

Public Types

enum  Axis {
  X_AXIS =0,
  Y_AXIS =1,
  Z_AXIS =2,
  DETECT_AXIS =-1
}
 

Public Member Functions

 Vector3 ()
 Initializes to zero. More...
 
 Vector3 (DoNotInitialize dni)
 
 Vector3 (const Any &any)
 
 Vector3 (const Vector4int8 &)
 
 Vector3 (const Vector3uint8 &)
 
 Vector3 (const class Vector2 &v, float z)
 
 Vector3 (const class Vector3int32 &v)
 
 Vector3 (class BinaryInput &b)
 
 Vector3 (float _x, float _y, float _z)
 
 Vector3 (float coordinate[3])
 
 Vector3 (double coordinate[3])
 
 Vector3 (const class Vector3int16 &v)
 
 Vector3 (class TextInput &t)
 
 Vector3 (const class Color3 &c)
 
float average () const
 
Vector3 clamp (const Vector3 &low, const Vector3 &high) const
 
Vector3 clamp (float low, float high) const
 
Vector3 cross (const Vector3 &rkVector) const
 Cross product. More...
 
class Matrix3 cross () const
 
Returns a matrix such that v.cross() * w = v.cross(w). More...
 
void deserialize (class BinaryInput &b)
 
void deserialize (class TextInput &t)
 
Vector3 direction () const
 
Returns a unit-length version of this vector. More...
 
Vector3 directionOrZero () const
 
Returns Vector3::zero() if the length is nearly zero, otherwise returns a unit vector. More...
 
float dot (const Vector3 &rkVector) const
 
Vector3 fastDirection () const
 
Potentially less accurate but faster than direction(). More...
 
Vector3 fastUnit () const
 Returns a normalized vector. More...
 
Vector3 floor () const
 
bool fuzzyEq (const Vector3 &other) const
 
bool fuzzyNe (const Vector3 &other) const
 
void getTangents (Vector3 &X, Vector3 &Y) const
 Creates two orthonormal tangent vectors X and Y such that if Z = this, X x Y = Z. More...
 
size_t hashCode () const
 
bool isFinite () const
 Returns true if this vector has finite length. More...
 
bool isNaN () const
 True if any field is nan. More...
 
bool isUnit () const
 Returns true if this vector has length ~= 1. More...
 
bool isZero () const
 Returns true if this vector has length ~= 0. More...
 
float length () const
 Same as magnitude. More...
 
Vector3 lerp (const Vector3 &v, float alpha) const
 
Linear interpolation More...
 
float magnitude () const
 
Vector3 max (const Vector3 &v) const
 
float max () const
 Largest element. More...
 
Vector3 min (const Vector3 &v) const
 
float min () const
 Smallest element. More...
 
Vector3 movedTowards (const Vector3 &goal, float maxTranslation) const
 Returns a vector that is this translated towards goal with a maximum translation of maxTranslation. More...
 
void moveTowards (const Vector3 &goal, float maxTranslation)
 
bool nonZero () const
 
bool operator!= (const Vector3 &rkVector) const
 
Vector3 operator* (float s) const
 
Vector3 operator* (const Vector3 &v) const
 
Vector3operator*= (float s)
 
Vector3operator*= (const Vector3 &v)
 
Vector3 operator+ (const Vector3 &v) const
 
Vector3operator+= (const Vector3 &v)
 
Vector3 operator- (const Vector3 &v) const
 
Vector3 operator- () const
 
Vector3operator-= (const Vector3 &v)
 
Vector3 operator/ (float s) const
 
Vector3 operator/ (const Vector3 &v) const
 
Vector3operator/= (float s)
 
Vector3operator/= (const Vector3 &v)
 
Vector3operator= (const Vector3 &rkVector)
 
Vector3operator= (const Any &a)
 
bool operator== (const Vector3 &rkVector) const
 
const float & operator[] (int i) const
 
float & operator[] (int i)
 
Vector3 pow (float p) const
 Raise each component of this vector to a power. More...
 
Axis primaryAxis () const
 
Returns the largest dimension. More...
 
Vector3 reflectAbout (const Vector3 &normal) const
 
Reflect this vector about the (not necessarily unit) normal. More...
 
Vector3 reflectionDirection (const Vector3 &normal) const
 
See also G3D::Ray::reflect. More...
 
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. More...
 
Vector3 refractionDirection (const Vector3 &normal, float iRatio) const
 
Vector3 round () const
 
void serialize (class BinaryOutput &b) const
 Format is three float32's. More...
 
void serialize (class TextOutput &t) const
 Format is "(%f, %f, %f)". More...
 
float squaredLength () const
 Same as squaredMagnitude. More...
 
float squaredMagnitude () const
 
float sum () const
 
Any toAny (const String &name) const
 Converts the Vector3 to an Any, using the specified name instead of "Vector3". More...
 
Any toAny () const
 Converts the Vector3 to an Any. More...
 
String toString () const
 
Vector3 unit () const
 Synonym for direction. More...
 
Vector3 unitCross (const Vector3 &rkVector) const
 
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 void cosHemiPlusCosPowHemiHemiRandom (const Vector3 &v, const Vector3 &n, const float k, float P_cosPow, Random &rng, Vector3 &w, float &pdfValue)
 Useful for sampling "lambertian + glossy" style BSDFs, even if they don't exactly match this PDF. More...
 
static Vector3 cosHemiRandom (const Vector3 &n, Random &r=Random::common())
 Random unit vector, distributed according to $\max(\cos \theta,0)$. More...
 
static void cosHemiRandom (const Vector3 &v, Random &rng, Vector3 &w, float &pdfValue)
 Random unit vector, distributed proportional to $\max(\hat{\omega} \cdot \hat{n},0)$. More...
 
static void cosPowHemiHemiRandom (const Vector3 &v, const Vector3 &n, const float k, Random &r, Vector3 &w, float &pdfValue)
 Random unit vector, distributed proportional to $\max(|\hat{\omega} \cdot \hat{v}|^k, 0) \cdot (\hat{\omega} \cdot \hat{n} \geq 0)$. More...
 
static Vector3 cosPowHemiRandom (const Vector3 &v, const float k, Random &r=Random::common())
 Random unit vector, distributed proportional to $\max(|\hat{\omega} \cdot \hat{v}|^k, 0)$. More...
 
static void cosPowHemiRandom (const Vector3 &v, const float k, Random &r, Vector3 &w, float &pdfValue)
 Random unit vector, distributed proportional to $\max(|\hat{\omega} \cdot \hat{v}|^k, 0)$. More...
 
static Vector3 cosSphereRandom (const Vector3 &n, Random &r=Random::common())
 
static void cosSphereRandom (const Vector3 &n, Random &rng, Vector3 &w, float &pdfValue)
 Random unit vector, distributed proportional to $ |\hat{\omega} \cdot \hat{n}|$. More...
 
static Vector3 hemiRandom (const Vector3 &normal, Random &r=Random::common())
 
Random vector distributed over the hemisphere about normal. More...
 
static void hemiRandom (const Vector3 &v, Random &r, Vector3 &w, float &pdfValue)
 
Random vector distributed over the hemisphere about v. More...
 
static const Vector3inf ()
 
static const Vector3maxFinite ()
 Largest representable vector. More...
 
static const Vector3minFinite ()
 Smallest (most negative) representable vector. More...
 
static const Vector3nan ()
 
static const Vector3one ()
 
static void orthonormalize (Vector3 akVector[3])
 Gram-Schmidt orthonormalization. More...
 
static Vector3 random (Random &r=Random::common())
 Random unit vector, uniformly distributed on the sphere. More...
 
static void sphericalCapHemiRandom (const Vector3 &v, const Vector3 &n, const float cosHalfAngle, Random &r, Vector3 &w, float &pdfValue)
 
Samples w from a pdf proportional to the spherical cap that lies within the cone about v whose apex half-angle has cosine cosHalfAngle, while restricting w to the hemisphere about n. More...
 
static const Vector3unitX ()
 
static const Vector3unitY ()
 
static const Vector3unitZ ()
 
static const Vector3zero ()
 

Public Attributes

float x
 
float y
 
float z
 

Static Public Attributes

static Vector3 ignore
 For use with default output arguments. More...
 

Detailed Description


3x1 or 1x3 vector using float32 representation.

Typedefs use this class for Point as well.

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

◆ Axis

Enumerator
X_AXIS 
Y_AXIS 
Z_AXIS 
DETECT_AXIS 

Constructor & Destructor Documentation

◆ Vector3() [1/14]

G3D::Vector3::Vector3 ( )
inline

◆ Vector3() [2/14]

G3D::Vector3::Vector3 ( DoNotInitialize  dni)
inline

◆ Vector3() [3/14]

G3D::Vector3::Vector3 ( const Any any)
explicit
Parameters
anyMust either Vector3(#, #, #) or Vector3 {x = #, y = #, z = #}. Because Point3 is a typedef for Vector3 in the current implementation, this constructor accepts Point3(#, #, #), etc. as well.

◆ Vector3() [4/14]

G3D::Vector3::Vector3 ( const Vector4int8 )
explicit

◆ Vector3() [5/14]

G3D::Vector3::Vector3 ( const Vector3uint8 )

◆ Vector3() [6/14]

G3D::Vector3::Vector3 ( const class Vector2 v,
float  z 
)

◆ Vector3() [7/14]

G3D::Vector3::Vector3 ( const class Vector3int32 v)

◆ Vector3() [8/14]

G3D::Vector3::Vector3 ( class BinaryInput b)
explicit

◆ Vector3() [9/14]

G3D::Vector3::Vector3 ( float  _x,
float  _y,
float  _z 
)
inline

◆ Vector3() [10/14]

G3D::Vector3::Vector3 ( float  coordinate[3])
inlineexplicit

◆ Vector3() [11/14]

G3D::Vector3::Vector3 ( double  coordinate[3])
inlineexplicit

◆ Vector3() [12/14]

G3D::Vector3::Vector3 ( const class Vector3int16 v)

◆ Vector3() [13/14]

G3D::Vector3::Vector3 ( class TextInput t)
explicit

◆ Vector3() [14/14]

G3D::Vector3::Vector3 ( const class Color3 c)
explicit

Member Function Documentation

◆ average()

float G3D::Vector3::average ( ) const
inline

◆ clamp() [1/2]

Vector3 G3D::Vector3::clamp ( const Vector3 low,
const Vector3 high 
) const
inline

◆ clamp() [2/2]

Vector3 G3D::Vector3::clamp ( float  low,
float  high 
) const
inline

◆ cosHemiPlusCosPowHemiHemiRandom()

static void G3D::Vector3::cosHemiPlusCosPowHemiHemiRandom ( const Vector3 v,
const Vector3 n,
const float  k,
float  P_cosPow,
Random rng,
Vector3 w,
float &  pdfValue 
)
static

Useful for sampling "lambertian + glossy" style BSDFs, even if they don't exactly match this PDF.

Parameters
vThe lobe about which to sample the cosine-power lobe (typically w_o.reflectAbout(n))
nThe normal whose hemisphere each sub-PDF is restricted to, and the vector about which to sample the cosine lobe
P_cosPowProbability of sampling the cosPowHemi lobe about the reflection vector (1 - P_cosPow is the probability of sampling the regular cosine lobe)
kExponent on the cosPowHemi lobe

Assumes that P_cos + P_cosPow = 1.0

◆ cosHemiRandom() [1/2]

static Vector3 G3D::Vector3::cosHemiRandom ( const Vector3 n,
Random r = Random::common() 
)
static

Random unit vector, distributed according to $\max(\cos \theta,0)$.

That is, so that the probability of $\vec{V}$ is proportional to $\max(\vec{v} \cdot \vec{n}, 0)$. Useful in photon mapping for Lambertian scattering.

Distribution rendered by G3D::DirectionHistogram:

vector3-coshemirandom.png
Parameters
nUnit vector at the center of the distribution.
Referenced Code: Henrik Wann Jensen, Realistic Image Synthesis using Photon Mapping eqn 2.24

◆ cosHemiRandom() [2/2]

static void G3D::Vector3::cosHemiRandom ( const Vector3 v,
Random rng,
Vector3 w,
float &  pdfValue 
)
static

Random unit vector, distributed proportional to $\max(\hat{\omega} \cdot \hat{n},0)$.

That is, so that the probability of $\vec{V}$ is proportional to $\max(\vec{w} \cdot \vec{v}, 0)$. Useful in photon mapping for Lambertian scattering.

Distribution rendered by G3D::DirectionHistogram:

vector3-coshemirandom.png
Parameters
nUnit vector at the center of the distribution.
Referenced Code: Henrik Wann Jensen, Realistic Image Synthesis using Photon Mapping eqn 2.24

◆ cosPowHemiHemiRandom()

static void G3D::Vector3::cosPowHemiHemiRandom ( const Vector3 v,
const Vector3 n,
const float  k,
Random r,
Vector3 w,
float &  pdfValue 
)
static

Random unit vector, distributed proportional to $\max(|\hat{\omega} \cdot \hat{v}|^k, 0) \cdot (\hat{\omega} \cdot \hat{n} \geq 0)$.

Parameters
kPower lobe
vUnit vector at the center of the distribution.
nUnit vector defining the hemisphere to restrict the result vector to
w$ \hat{\omega} $
pdfValueThe value of the cosPowHemiHemiRandom pdf at w
See also
cosPowHemiRandom, hemiRandom, cosHemiRandom

◆ cosPowHemiRandom() [1/2]

static Vector3 G3D::Vector3::cosPowHemiRandom ( const Vector3 v,
const float  k,
Random r = Random::common() 
)
static

Random unit vector, distributed proportional to $\max(|\hat{\omega} \cdot \hat{v}|^k, 0)$.

Parameters
kPower lobe
vUnit vector at the center of the distribution.
Referenced Code: Ashikhmin and Shirley, An anisotropic Phong BRDF model, Journal of Graphics Tools, 2002
See also
cosPowHemiHemiRandom, hemiRandom, cosHemiRandom

◆ cosPowHemiRandom() [2/2]

static void G3D::Vector3::cosPowHemiRandom ( const Vector3 v,
const float  k,
Random r,
Vector3 w,
float &  pdfValue 
)
static

Random unit vector, distributed proportional to $\max(|\hat{\omega} \cdot \hat{v}|^k, 0)$.

Parameters
kPower lobe
vUnit vector at the center of the distribution.
w$ \hat{\omega} $
pdfValueThe value of the cosPowHemiRandom pdf at w
Referenced Code: Ashikhmin and Shirley, An anisotropic Phong BRDF model, Journal of Graphics Tools, 2002
See also
cosPowHemiHemiRandom, hemiRandom, cosHemiRandom

◆ cosSphereRandom() [1/2]

static Vector3 G3D::Vector3::cosSphereRandom ( const Vector3 n,
Random r = Random::common() 
)
static

◆ cosSphereRandom() [2/2]

static void G3D::Vector3::cosSphereRandom ( const Vector3 n,
Random rng,
Vector3 w,
float &  pdfValue 
)
static

Random unit vector, distributed proportional to $ |\hat{\omega} \cdot \hat{n}|$.

Parameters
nUnit vector at the center of the distribution.
Referenced Code: Henrik Wann Jensen, Realistic Image Synthesis using Photon Mapping eqn 2.24

◆ cross() [1/2]

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.

Referenced by G3D::cross(), G3D::Tri::nonUnitNormal(), and G3D::Tri::tangent2().

◆ cross() [2/2]

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  ]

Referenced by getTangents().

◆ deserialize() [1/2]

void G3D::Vector3::deserialize ( class BinaryInput b)

◆ deserialize() [2/2]

void G3D::Vector3::deserialize ( class TextInput t)

◆ direction()

Vector3 G3D::Vector3::direction ( ) const
inline


Returns a unit-length version of this vector.

Returns nan if length is almost zero.

Referenced by G3D::Box::axis(), G3D::CollisionDetection::collisionTimeForMovingPointFixedTriangle(), G3D::Line::Line(), unit(), and unitCross().

◆ directionOrZero()

Vector3 G3D::Vector3::directionOrZero ( ) const
inline


Returns Vector3::zero() if the length is nearly zero, otherwise returns a unit vector.

Referenced by G3D::ArticulatedModel::Geometry::Face::Face(), G3D::Tri::normal(), and G3D::squareMagnitude().

◆ dot()

float G3D::Vector3::dot ( const Vector3 rkVector) const
inline

◆ fastDirection()

Vector3 G3D::Vector3::fastDirection ( ) const
inline


Potentially less accurate but faster than direction().

Only works if System::hasSSE is true.

Referenced by fastUnit().

◆ fastUnit()

Vector3 G3D::Vector3::fastUnit ( ) const
inline

Returns a normalized vector.

May be computed with lower precision than unit

◆ floor()

Vector3 G3D::Vector3::floor ( ) const
inline

◆ fuzzyEq()

bool G3D::Vector3::fuzzyEq ( const Vector3 other) const
inline

◆ fuzzyNe()

bool G3D::Vector3::fuzzyNe ( const Vector3 other) const
inline

◆ getTangents()

void G3D::Vector3::getTangents ( Vector3 X,
Vector3 Y 
) const
inline

Creates two orthonormal tangent vectors X and Y such that if Z = this, X x Y = Z.

◆ hashCode()

size_t G3D::Vector3::hashCode ( ) const

◆ hemiRandom() [1/2]

static Vector3 G3D::Vector3::hemiRandom ( const Vector3 normal,
Random r = Random::common() 
)
static


Random vector distributed over the hemisphere about normal.

Distribution rendered by G3D::DirectionHistogram:

vector3-hemirandom.png

◆ hemiRandom() [2/2]

static void G3D::Vector3::hemiRandom ( const Vector3 v,
Random r,
Vector3 w,
float &  pdfValue 
)
static


Random vector distributed over the hemisphere about v.

Parameters
pdfValueset to 1/pi on return, the value of a uniform PDF over the hemisphere.

Distribution rendered by G3D::DirectionHistogram:

vector3-hemirandom.png

◆ inf()

static const Vector3& G3D::Vector3::inf ( )
static

◆ isFinite()

bool G3D::Vector3::isFinite ( ) const
inline

Returns true if this vector has finite length.

Referenced by G3D::Plane::halfSpaceContainsFinite().

◆ isNaN()

bool G3D::Vector3::isNaN ( ) const

True if any field is nan.

Referenced by G3D::AABox::isEmpty().

◆ isUnit()

bool G3D::Vector3::isUnit ( ) const
inline

Returns true if this vector has length ~= 1.

◆ isZero()

bool G3D::Vector3::isZero ( ) const
inline

Returns true if this vector has length ~= 0.

◆ length()

float G3D::Vector3::length ( ) const
inline

Same as magnitude.

Referenced by G3D::ArrowShape::boundingSphere(), G3D::Box::extent(), and getTangents().

◆ lerp()

Vector3 G3D::Vector3::lerp ( const Vector3 v,
float  alpha 
) const
inline


Linear interpolation

Referenced by G3D::lerp().

◆ magnitude()

float G3D::Vector3::magnitude ( ) const
inline

◆ max() [1/2]

Vector3 G3D::Vector3::max ( const Vector3 v) const
inline

◆ max() [2/2]

float G3D::Vector3::max ( ) const
inline

Largest element.

◆ maxFinite()

static const Vector3& G3D::Vector3::maxFinite ( )
static

◆ min() [1/2]

Vector3 G3D::Vector3::min ( const Vector3 v) const
inline

◆ min() [2/2]

float G3D::Vector3::min ( ) const
inline

Smallest element.

◆ minFinite()

static const Vector3& G3D::Vector3::minFinite ( )
static

Smallest (most negative) representable vector.

Referenced by G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::balance(), and G3D::Plane::halfSpaceContains().

◆ movedTowards()

Vector3 G3D::Vector3::movedTowards ( const Vector3 goal,
float  maxTranslation 
) const

Returns a vector that is this translated towards goal with a maximum translation of maxTranslation.

◆ moveTowards()

void G3D::Vector3::moveTowards ( const Vector3 goal,
float  maxTranslation 
)

◆ nan()

static const Vector3& G3D::Vector3::nan ( )
static

◆ nonZero()

bool G3D::Vector3::nonZero ( ) const
inline

◆ one()

static const Vector3& G3D::Vector3::one ( )
static

◆ operator!=()

bool G3D::Vector3::operator!= ( const Vector3 rkVector) const
inline

◆ operator*() [1/2]

Vector3 G3D::Vector3::operator* ( float  s) const
inline

◆ operator*() [2/2]

Vector3 G3D::Vector3::operator* ( const Vector3 v) const
inline

◆ operator*=() [1/2]

Vector3 & G3D::Vector3::operator*= ( float  s)
inline

◆ operator*=() [2/2]

Vector3 & G3D::Vector3::operator*= ( const Vector3 v)
inline

◆ operator+()

Vector3 G3D::Vector3::operator+ ( const Vector3 v) const
inline

◆ operator+=()

Vector3 & G3D::Vector3::operator+= ( const Vector3 v)
inline

◆ operator-() [1/2]

Vector3 G3D::Vector3::operator- ( const Vector3 v) const
inline

◆ operator-() [2/2]

Vector3 G3D::Vector3::operator- ( ) const
inline

◆ operator-=()

Vector3 & G3D::Vector3::operator-= ( const Vector3 v)
inline

◆ operator/() [1/2]

Vector3 G3D::Vector3::operator/ ( float  s) const
inline

◆ operator/() [2/2]

Vector3 G3D::Vector3::operator/ ( const Vector3 v) const
inline

◆ operator/=() [1/2]

Vector3& G3D::Vector3::operator/= ( float  s)
inline

◆ operator/=() [2/2]

Vector3 & G3D::Vector3::operator/= ( const Vector3 v)
inline

◆ operator=() [1/2]

Vector3 & G3D::Vector3::operator= ( const Vector3 rkVector)
inline

◆ operator=() [2/2]

Vector3& G3D::Vector3::operator= ( const Any a)

◆ operator==()

bool G3D::Vector3::operator== ( const Vector3 rkVector) const
inline

◆ operator[]() [1/2]

const float & G3D::Vector3::operator[] ( int  i) const
inline

◆ operator[]() [2/2]

float & G3D::Vector3::operator[] ( int  i)
inline

◆ orthonormalize()

static void G3D::Vector3::orthonormalize ( Vector3  akVector[3])
static

Gram-Schmidt orthonormalization.

◆ pow()

Vector3 G3D::Vector3::pow ( float  p) const
inline

Raise each component of this vector to a power.

◆ primaryAxis()

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.

Referenced by G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::makeNode().

◆ random()

static Vector3 G3D::Vector3::random ( Random r = Random::common())
static

Random unit vector, uniformly distributed on the sphere.

Distribution rendered by G3D::DirectionHistogram:

vector3-random.png

◆ reflectAbout()

Vector3 G3D::Vector3::reflectAbout ( const Vector3 normal) const


Reflect this vector about the (not necessarily unit) normal.

Assumes that both the before and after vectors point away from the base of the normal.

Note that if used for a collision or ray reflection you must negate the resulting vector to get a direction pointing away from the collision.

  V'    N      V
    r   ^   -,
     \  |  /
       |/

See also Vector3::reflectionDirection

◆ reflectionDirection()

Vector3 G3D::Vector3::reflectionDirection ( const Vector3 normal) const


See also G3D::Ray::reflect.

The length is 1.

  V'    N       V
    r   ^    /
     \  |  /
       |'-

◆ refractionDirection() [1/2]

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
iOutsideThe index of refraction (eta) outside (on the positive normal side) of the surface.
iInsideThe index of refraction (eta) inside (on the negative normal side) of the surface.

See also G3D::Ray::refract.

         N      V
         ^    /
         |  /
         |'-
     __–
V'<–

◆ refractionDirection() [2/2]

Vector3 G3D::Vector3::refractionDirection ( const Vector3 normal,
float  iRatio 
) const

◆ round()

Vector3 G3D::Vector3::round ( ) const
inline

◆ serialize() [1/2]

void G3D::Vector3::serialize ( class BinaryOutput b) const

Format is three float32's.

◆ serialize() [2/2]

void G3D::Vector3::serialize ( class TextOutput t) const

Format is "(%f, %f, %f)".

◆ sphericalCapHemiRandom()

static void G3D::Vector3::sphericalCapHemiRandom ( const Vector3 v,
const Vector3 n,
const float  cosHalfAngle,
Random r,
Vector3 w,
float &  pdfValue 
)
static


Samples w from a pdf proportional to the spherical cap that lies within the cone about v whose apex half-angle has cosine cosHalfAngle, while restricting w to the hemisphere about n.

◆ squaredLength()

float G3D::Vector3::squaredLength ( ) const
inline

Same as squaredMagnitude.

Referenced by G3D::squareMagnitude().

◆ squaredMagnitude()

float G3D::Vector3::squaredMagnitude ( ) const
inline

◆ sum()

float G3D::Vector3::sum ( ) const
inline

Referenced by average().

◆ toAny() [1/2]

Any G3D::Vector3::toAny ( const String name) const

Converts the Vector3 to an Any, using the specified name instead of "Vector3".

◆ toAny() [2/2]

Any G3D::Vector3::toAny ( ) const

Converts the Vector3 to an Any.

◆ toString()

String G3D::Vector3::toString ( ) const

◆ unit()

Vector3 G3D::Vector3::unit ( ) const
inline

Synonym for direction.

◆ unitCross()

Vector3 G3D::Vector3::unitCross ( const Vector3 rkVector) const
inline

◆ unitX()

static const Vector3& G3D::Vector3::unitX ( )
static

◆ unitY()

static const Vector3& G3D::Vector3::unitY ( )
static

◆ unitZ()

static const Vector3& G3D::Vector3::unitZ ( )
static

◆ xx()

Vector2 G3D::Vector3::xx ( ) const

◆ xxx()

Vector3 G3D::Vector3::xxx ( ) const

◆ xxxx()

Vector4 G3D::Vector3::xxxx ( ) const

◆ xxxy()

Vector4 G3D::Vector3::xxxy ( ) const

◆ xxxz()

Vector4 G3D::Vector3::xxxz ( ) const

◆ xxy()

Vector3 G3D::Vector3::xxy ( ) const

◆ xxyx()

Vector4 G3D::Vector3::xxyx ( ) const

◆ xxyy()

Vector4 G3D::Vector3::xxyy ( ) const

◆ xxyz()

Vector4 G3D::Vector3::xxyz ( ) const

◆ xxz()

Vector3 G3D::Vector3::xxz ( ) const

◆ xxzx()

Vector4 G3D::Vector3::xxzx ( ) const

◆ xxzy()

Vector4 G3D::Vector3::xxzy ( ) const

◆ xxzz()

Vector4 G3D::Vector3::xxzz ( ) const

◆ xy()

Vector2 G3D::Vector3::xy ( ) const

◆ xyx()

Vector3 G3D::Vector3::xyx ( ) const

◆ xyxx()

Vector4 G3D::Vector3::xyxx ( ) const

◆ xyxy()

Vector4 G3D::Vector3::xyxy ( ) const

◆ xyxz()

Vector4 G3D::Vector3::xyxz ( ) const

◆ xyy()

Vector3 G3D::Vector3::xyy ( ) const

◆ xyyx()

Vector4 G3D::Vector3::xyyx ( ) const

◆ xyyy()

Vector4 G3D::Vector3::xyyy ( ) const

◆ xyyz()

Vector4 G3D::Vector3::xyyz ( ) const

◆ xyz()

Vector3 G3D::Vector3::xyz ( ) const

Referenced by G3D::PointShape::center().

◆ xyzx()

Vector4 G3D::Vector3::xyzx ( ) const

◆ xyzy()

Vector4 G3D::Vector3::xyzy ( ) const

◆ xyzz()

Vector4 G3D::Vector3::xyzz ( ) const

◆ xz()

Vector2 G3D::Vector3::xz ( ) const

◆ xzx()

Vector3 G3D::Vector3::xzx ( ) const

◆ xzxx()

Vector4 G3D::Vector3::xzxx ( ) const

◆ xzxy()

Vector4 G3D::Vector3::xzxy ( ) const

◆ xzxz()

Vector4 G3D::Vector3::xzxz ( ) const

◆ xzy()

Vector3 G3D::Vector3::xzy ( ) const

◆ xzyx()

Vector4 G3D::Vector3::xzyx ( ) const

◆ xzyy()

Vector4 G3D::Vector3::xzyy ( ) const

◆ xzyz()

Vector4 G3D::Vector3::xzyz ( ) const

◆ xzz()

Vector3 G3D::Vector3::xzz ( ) const

◆ xzzx()

Vector4 G3D::Vector3::xzzx ( ) const

◆ xzzy()

Vector4 G3D::Vector3::xzzy ( ) const

◆ xzzz()

Vector4 G3D::Vector3::xzzz ( ) const

◆ yx()

Vector2 G3D::Vector3::yx ( ) const

◆ yxx()

Vector3 G3D::Vector3::yxx ( ) const

◆ yxxx()

Vector4 G3D::Vector3::yxxx ( ) const

◆ yxxy()

Vector4 G3D::Vector3::yxxy ( ) const

◆ yxxz()

Vector4 G3D::Vector3::yxxz ( ) const

◆ yxy()

Vector3 G3D::Vector3::yxy ( ) const

◆ yxyx()

Vector4 G3D::Vector3::yxyx ( ) const

◆ yxyy()

Vector4 G3D::Vector3::yxyy ( ) const

◆ yxyz()

Vector4 G3D::Vector3::yxyz ( ) const

◆ yxz()

Vector3 G3D::Vector3::yxz ( ) const

◆ yxzx()

Vector4 G3D::Vector3::yxzx ( ) const

◆ yxzy()

Vector4 G3D::Vector3::yxzy ( ) const

◆ yxzz()

Vector4 G3D::Vector3::yxzz ( ) const

◆ yy()

Vector2 G3D::Vector3::yy ( ) const

◆ yyx()

Vector3 G3D::Vector3::yyx ( ) const

◆ yyxx()

Vector4 G3D::Vector3::yyxx ( ) const

◆ yyxy()

Vector4 G3D::Vector3::yyxy ( ) const

◆ yyxz()

Vector4 G3D::Vector3::yyxz ( ) const

◆ yyy()

Vector3 G3D::Vector3::yyy ( ) const

◆ yyyx()

Vector4 G3D::Vector3::yyyx ( ) const

◆ yyyy()

Vector4 G3D::Vector3::yyyy ( ) const

◆ yyyz()

Vector4 G3D::Vector3::yyyz ( ) const

◆ yyz()

Vector3 G3D::Vector3::yyz ( ) const

◆ yyzx()

Vector4 G3D::Vector3::yyzx ( ) const

◆ yyzy()

Vector4 G3D::Vector3::yyzy ( ) const

◆ yyzz()

Vector4 G3D::Vector3::yyzz ( ) const

◆ yz()

Vector2 G3D::Vector3::yz ( ) const

◆ yzx()

Vector3 G3D::Vector3::yzx ( ) const

◆ yzxx()

Vector4 G3D::Vector3::yzxx ( ) const

◆ yzxy()

Vector4 G3D::Vector3::yzxy ( ) const

◆ yzxz()

Vector4 G3D::Vector3::yzxz ( ) const

◆ yzy()

Vector3 G3D::Vector3::yzy ( ) const

◆ yzyx()

Vector4 G3D::Vector3::yzyx ( ) const

◆ yzyy()

Vector4 G3D::Vector3::yzyy ( ) const

◆ yzyz()

Vector4 G3D::Vector3::yzyz ( ) const

◆ yzz()

Vector3 G3D::Vector3::yzz ( ) const

◆ yzzx()

Vector4 G3D::Vector3::yzzx ( ) const

◆ yzzy()

Vector4 G3D::Vector3::yzzy ( ) const

◆ yzzz()

Vector4 G3D::Vector3::yzzz ( ) const

◆ zero()

static const Vector3& G3D::Vector3::zero ( )
static

◆ zx()

Vector2 G3D::Vector3::zx ( ) const

◆ zxx()

Vector3 G3D::Vector3::zxx ( ) const

◆ zxxx()

Vector4 G3D::Vector3::zxxx ( ) const

◆ zxxy()

Vector4 G3D::Vector3::zxxy ( ) const

◆ zxxz()

Vector4 G3D::Vector3::zxxz ( ) const

◆ zxy()

Vector3 G3D::Vector3::zxy ( ) const

◆ zxyx()

Vector4 G3D::Vector3::zxyx ( ) const

◆ zxyy()

Vector4 G3D::Vector3::zxyy ( ) const

◆ zxyz()

Vector4 G3D::Vector3::zxyz ( ) const

◆ zxz()

Vector3 G3D::Vector3::zxz ( ) const

◆ zxzx()

Vector4 G3D::Vector3::zxzx ( ) const

◆ zxzy()

Vector4 G3D::Vector3::zxzy ( ) const

◆ zxzz()

Vector4 G3D::Vector3::zxzz ( ) const

◆ zy()

Vector2 G3D::Vector3::zy ( ) const

◆ zyx()

Vector3 G3D::Vector3::zyx ( ) const

◆ zyxx()

Vector4 G3D::Vector3::zyxx ( ) const

◆ zyxy()

Vector4 G3D::Vector3::zyxy ( ) const

◆ zyxz()

Vector4 G3D::Vector3::zyxz ( ) const

◆ zyy()

Vector3 G3D::Vector3::zyy ( ) const

◆ zyyx()

Vector4 G3D::Vector3::zyyx ( ) const

◆ zyyy()

Vector4 G3D::Vector3::zyyy ( ) const

◆ zyyz()

Vector4 G3D::Vector3::zyyz ( ) const

◆ zyz()

Vector3 G3D::Vector3::zyz ( ) const

◆ zyzx()

Vector4 G3D::Vector3::zyzx ( ) const

◆ zyzy()

Vector4 G3D::Vector3::zyzy ( ) const

◆ zyzz()

Vector4 G3D::Vector3::zyzz ( ) const

◆ zz()

Vector2 G3D::Vector3::zz ( ) const

◆ zzx()

Vector3 G3D::Vector3::zzx ( ) const

◆ zzxx()

Vector4 G3D::Vector3::zzxx ( ) const

◆ zzxy()

Vector4 G3D::Vector3::zzxy ( ) const

◆ zzxz()

Vector4 G3D::Vector3::zzxz ( ) const

◆ zzy()

Vector3 G3D::Vector3::zzy ( ) const

◆ zzyx()

Vector4 G3D::Vector3::zzyx ( ) const

◆ zzyy()

Vector4 G3D::Vector3::zzyy ( ) const

◆ zzyz()

Vector4 G3D::Vector3::zzyz ( ) const

◆ zzz()

Vector3 G3D::Vector3::zzz ( ) const

◆ zzzx()

Vector4 G3D::Vector3::zzzx ( ) const

◆ zzzy()

Vector4 G3D::Vector3::zzzy ( ) const

◆ zzzz()

Vector4 G3D::Vector3::zzzz ( ) const

Member Data Documentation

◆ ignore

Vector3 G3D::Vector3::ignore
static

For use with default output arguments.

The value is always undefined.

◆ x

float G3D::Vector3::x

◆ y

float G3D::Vector3::y

◆ z

float G3D::Vector3::z

documentation generated on Wed Nov 24 2021 08:02:02 using doxygen 1.8.15