Support Forum       Library Source       SourceForge Page       G3D Web Page     
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
G3D::Vector2 Class Reference

Do not subclass– this implementation makes assumptions about the memory layout. More...

Public Member Functions

 Vector2 (const Any &any)
 
 Vector2 ()
 Creates the zero vector.
 
 Vector2 (class TextInput &t)
 
 Vector2 (class BinaryInput &b)
 
 Vector2 (float x, float y)
 
 Vector2 (float coordinate[2])
 
 Vector2 (double coordinate[2])
 
 Vector2 (const Vector2 &other)
 
 Vector2 (const Vector2int16 &other)
 
 Vector2 (const Vector2unorm16 &other)
 
Vector2 abs () const
 Componentwise absolute value.
 
Vector2 clamp (const Vector2 &low, const Vector2 &high) const
 
Vector2 clamp (float low, float high) const
 
void deserialize (class BinaryInput &b)
 
void deserialize (class TextInput &t)
 
Vector2 direction () const
 Returns a unit-length version of this vector.
 
Vector2 directionOrZero () const
 Returns Vector2::zero() is magnitude is almost zero, otherwise returns unit-length vector.
 
float dot (const Vector2 &s) const
 
Vector2 fastDirection () const
 Potentially less accurate but faster than direction().
 
bool fuzzyEq (const Vector2 &other) const
 
bool fuzzyNe (const Vector2 &other) const
 
size_t hashCode () const
 
bool isFinite () const
 Returns true if this vector has finite length.
 
bool isNaN () const
 True if any field is NaN.
 
bool isUnit () const
 Returns true if this vector has length == 1.
 
bool isZero () const
 Returns true if this vector has length == 0.
 
float length () const
 Magnitude of the vector.
 
Vector2 lerp (const Vector2 &v, float alpha) const
 Linear interpolation.
 
Vector2 max (const Vector2 &v) const
 Component-wise maximum.
 
Vector2 maxAbs (const Vector2 &v) const
 Component-wise argmax(abs(), v.abs()).
 
Vector2 min (const Vector2 &v) const
 Component-wise minimum.
 
Vector2 minAbs (const Vector2 &v) const
 Component-wise argmin(abs(), v.abs()).
 
bool operator!= (const Vector2 &other) const
 
Vector2 operator* (float s) const
 
Vector2 operator* (const Vector2 &v) const
 Array (pointwise) multiplication.
 
Vector2operator*= (float)
 
Vector2operator*= (const Vector2 &)
 
Vector2 operator+ (const Vector2 &v) const
 
Vector2operator+= (const Vector2 &)
 
Vector2 operator- (const Vector2 &v) const
 
Vector2 operator- () const
 Unary minus.
 
Vector2operator-= (const Vector2 &)
 
Vector2 operator/ (const Vector2 &v) const
 Array division.
 
Vector2 operator/ (float s) const
 
Vector2operator/= (float)
 
Vector2operator/= (const Vector2 &)
 
Vector2operator= (const Any &a)
 
Vector2operator= (const Vector2 &other)
 
bool operator== (const Vector2 &other) const
 
float & operator[] (int i)
 
const float & operator[] (int i) const
 
Vector2 pow (float p) const
 Raise each component of this vector to a power.
 
void serialize (class BinaryOutput &b) const
 
void serialize (class TextOutput &t) const
 
float squaredLength () const
 
float sum () const
 x + y
 
Any toAny () const
 Converts the Vector2 to an Any.
 
std::string toString () const
 
Vector2 xx () const
 
Vector3 xxx () const
 
Vector4 xxxx () const
 
Vector4 xxxy () const
 
Vector3 xxy () const
 
Vector4 xxyx () const
 
Vector4 xxyy () const
 
Vector2 xy () const
 
Vector3 xyx () const
 
Vector4 xyxx () const
 
Vector4 xyxy () const
 
Vector3 xyy () const
 
Vector4 xyyx () const
 
Vector4 xyyy () const
 
Vector2 yx () const
 
Vector3 yxx () const
 
Vector4 yxxx () const
 
Vector4 yxxy () const
 
Vector3 yxy () const
 
Vector4 yxyx () const
 
Vector4 yxyy () const
 
Vector2 yy () const
 
Vector3 yyx () const
 
Vector4 yyxx () const
 
Vector4 yyxy () const
 
Vector3 yyy () const
 
Vector4 yyyx () const
 
Vector4 yyyy () const
 

Static Public Member Functions

static const Vector2inf ()
 
static const Vector2maxFinite ()
 Largest representable vector.
 
static const Vector2minFinite ()
 smallest (most negative) representable vector
 
static const Vector2nan ()
 
static const Vector2one ()
 
static Vector2 random (Random &r=Random::common())
 Uniformly distributed random vector on the unit sphere.
 
static const Vector2unitX ()
 
static const Vector2unitY ()
 
static const Vector2zero ()
 

Public Attributes

float x
 
float y
 

Detailed Description

Do not subclass– this implementation makes assumptions about the memory layout.

Constructor & Destructor Documentation

G3D::Vector2::Vector2 ( const Any any)
explicit
Parameters
anyMust either Vector2(#, #) or Vector2 {x = #, y = #}
G3D::Vector2::Vector2 ( )
inline

Creates the zero vector.

Referenced by abs(), clamp(), max(), maxAbs(), min(), minAbs(), operator*(), operator+(), operator-(), operator/(), and pow().

G3D::Vector2::Vector2 ( class TextInput t)
G3D::Vector2::Vector2 ( class BinaryInput b)
G3D::Vector2::Vector2 ( float  x,
float  y 
)
inline
G3D::Vector2::Vector2 ( float  coordinate[2])
inline
G3D::Vector2::Vector2 ( double  coordinate[2])
inline
G3D::Vector2::Vector2 ( const Vector2 other)
inline
G3D::Vector2::Vector2 ( const Vector2int16 other)
inline
G3D::Vector2::Vector2 ( const Vector2unorm16 other)
inline

Member Function Documentation

Vector2 G3D::Vector2::abs ( ) const
inline

Componentwise absolute value.

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

Referenced by G3D::clamp().

Vector2 G3D::Vector2::clamp ( float  low,
float  high 
) const
inline
void G3D::Vector2::deserialize ( class BinaryInput b)
void G3D::Vector2::deserialize ( class TextInput t)
Vector2 G3D::Vector2::direction ( ) const
inline

Returns a unit-length version of this vector.

Returns nan if length is almost zero.

Referenced by fastDirection(), and G3D::Line2D::Line2D().

Vector2 G3D::Vector2::directionOrZero ( ) const
inline

Returns Vector2::zero() is magnitude is almost zero, otherwise returns unit-length vector.

float G3D::Vector2::dot ( const Vector2 s) const
inline

Referenced by G3D::Box2D::contains(), and G3D::dot().

Vector2 G3D::Vector2::fastDirection ( ) const
inline

Potentially less accurate but faster than direction().

Only works if System::hasSSE is true.

bool G3D::Vector2::fuzzyEq ( const Vector2 other) const
inline
bool G3D::Vector2::fuzzyNe ( const Vector2 other) const
inline
size_t G3D::Vector2::hashCode ( ) const
static const Vector2& G3D::Vector2::inf ( )
static
bool G3D::Vector2::isFinite ( ) const
inline

Returns true if this vector has finite length.

Referenced by G3D::Rect2D::isFinite().

bool G3D::Vector2::isNaN ( ) const
inline

True if any field is NaN.

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

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

Returns true if this vector has length == 1.

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

Returns true if this vector has length == 0.

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

Magnitude of the vector.

Referenced by directionOrZero(), G3D::length(), and G3D::normalize().

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

Linear interpolation.

Referenced by G3D::lerp(), and G3D::Rect2D::lerp().

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

Component-wise maximum.

Referenced by G3D::Rect2D::intersect(), G3D::max(), G3D::Rect2D::merge(), and G3D::Rect2D::xyxy().

Vector2 G3D::Vector2::maxAbs ( const Vector2 v) const
inline

Component-wise argmax(abs(), v.abs()).

For the larger magnitude vector, simply use (a.squaredMagnitude() > b.squaredMagnitude) ? a : b.

See Also
max
static const Vector2& G3D::Vector2::maxFinite ( )
static

Largest representable vector.

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

Component-wise minimum.

Referenced by G3D::Rect2D::intersect(), G3D::Rect2D::merge(), G3D::min(), and G3D::Rect2D::xyxy().

Vector2 G3D::Vector2::minAbs ( const Vector2 v) const
inline

Component-wise argmin(abs(), v.abs()).

For the smaller magnitude vector, simply use (a.squaredMagnitude() < b.squaredMagnitude) ? a : b.

See Also
max
static const Vector2& G3D::Vector2::minFinite ( )
static

smallest (most negative) representable vector

static const Vector2& G3D::Vector2::nan ( )
static
static const Vector2& G3D::Vector2::one ( )
static
bool G3D::Vector2::operator!= ( const Vector2 other) const
inline
Vector2 G3D::Vector2::operator* ( float  s) const
inline
Vector2 G3D::Vector2::operator* ( const Vector2 v) const
inline

Array (pointwise) multiplication.

Vector2 & G3D::Vector2::operator*= ( float  fScalar)
inline
Vector2 & G3D::Vector2::operator*= ( const Vector2 rkVector)
inline
Vector2 G3D::Vector2::operator+ ( const Vector2 v) const
inline
Vector2 & G3D::Vector2::operator+= ( const Vector2 rkVector)
inline
Vector2 G3D::Vector2::operator- ( const Vector2 v) const
inline
Vector2 G3D::Vector2::operator- ( ) const
inline

Unary minus.

Vector2 & G3D::Vector2::operator-= ( const Vector2 rkVector)
inline
Vector2 G3D::Vector2::operator/ ( const Vector2 v) const
inline

Array division.

Vector2 G3D::Vector2::operator/ ( float  s) const
Vector2& G3D::Vector2::operator/= ( float  )
Vector2 & G3D::Vector2::operator/= ( const Vector2 rkVector)
inline
Vector2& G3D::Vector2::operator= ( const Any a)
Vector2 & G3D::Vector2::operator= ( const Vector2 other)
inline
bool G3D::Vector2::operator== ( const Vector2 other) const
inline
float & G3D::Vector2::operator[] ( int  i)
inline
const float & G3D::Vector2::operator[] ( int  i) const
inline
Vector2 G3D::Vector2::pow ( float  p) const
inline

Raise each component of this vector to a power.

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

Uniformly distributed random vector on the unit sphere.

void G3D::Vector2::serialize ( class BinaryOutput b) const
void G3D::Vector2::serialize ( class TextOutput t) const
float G3D::Vector2::squaredLength ( ) const
inline

Referenced by fuzzyEq(), fuzzyNe(), and isUnit().

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

x + y

Any G3D::Vector2::toAny ( ) const

Converts the Vector2 to an Any.

std::string G3D::Vector2::toString ( ) const
static const Vector2& G3D::Vector2::unitX ( )
static
static const Vector2& G3D::Vector2::unitY ( )
static
Vector2 G3D::Vector2::xx ( ) const
Vector3 G3D::Vector2::xxx ( ) const
Vector4 G3D::Vector2::xxxx ( ) const
Vector4 G3D::Vector2::xxxy ( ) const
Vector3 G3D::Vector2::xxy ( ) const
Vector4 G3D::Vector2::xxyx ( ) const
Vector4 G3D::Vector2::xxyy ( ) const
Vector2 G3D::Vector2::xy ( ) const
Vector3 G3D::Vector2::xyx ( ) const
Vector4 G3D::Vector2::xyxx ( ) const
Vector4 G3D::Vector2::xyxy ( ) const
Vector3 G3D::Vector2::xyy ( ) const
Vector4 G3D::Vector2::xyyx ( ) const
Vector4 G3D::Vector2::xyyy ( ) const
Vector2 G3D::Vector2::yx ( ) const
Vector3 G3D::Vector2::yxx ( ) const
Vector4 G3D::Vector2::yxxx ( ) const
Vector4 G3D::Vector2::yxxy ( ) const
Vector3 G3D::Vector2::yxy ( ) const
Vector4 G3D::Vector2::yxyx ( ) const
Vector4 G3D::Vector2::yxyy ( ) const
Vector2 G3D::Vector2::yy ( ) const
Vector3 G3D::Vector2::yyx ( ) const
Vector4 G3D::Vector2::yyxx ( ) const
Vector4 G3D::Vector2::yyxy ( ) const
Vector3 G3D::Vector2::yyy ( ) const
Vector4 G3D::Vector2::yyyx ( ) const
Vector4 G3D::Vector2::yyyy ( ) const
static const Vector2& G3D::Vector2::zero ( )
static

Member Data Documentation

float G3D::Vector2::x
float G3D::Vector2::y

documentation generated on Sat Jan 12 2013 22:49:57 using doxygen 1.8.2