Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Public Attributes | Static 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 (DoNotInitialize dni)
 
 Vector2 ()
 Creates the zero vector. More...
 
 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 (const Vector2int32 &other)
 
Vector2 abs () const
 Componentwise absolute value. More...
 
Vector2 ceil () const
 
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. More...
 
Vector2 directionOrZero () const
 Returns Vector2::zero() is magnitude is almost zero, otherwise returns unit-length vector. More...
 
float dot (const Vector2 &s) const
 
Vector2 fastDirection () const
 
Potentially less accurate but faster than direction(). More...
 
Vector2 floor () const
 
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. 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
 Magnitude of the vector. More...
 
Vector2 lerp (const Vector2 &v, float alpha) const
 
Linear interpolation More...
 
Vector2 max (const Vector2 &v) const
 Component-wise maximum. More...
 
Vector2 maxAbs (const Vector2 &v) const
 Component-wise argmax(abs(), v.abs()). More...
 
Vector2 min (const Vector2 &v) const
 Component-wise minimum. More...
 
Vector2 minAbs (const Vector2 &v) const
 Component-wise argmin(abs(), v.abs()). More...
 
Vector2 mod1 () const
 Fast implementation of wrap(1.0f) More...
 
bool operator!= (const Vector2 &other) const
 
Vector2 operator* (float s) const
 
Vector2 operator* (const Vector2 &v) const
 Array (pointwise) multiplication. More...
 
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. More...
 
Vector2operator-= (const Vector2 &)
 
Vector2 operator/ (const Vector2 &v) const
 Array division. More...
 
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. More...
 
void serialize (class BinaryOutput &b) const
 
void serialize (class TextOutput &t) const
 
float squaredLength () const
 
float sum () const
 x + y More...
 
Any toAny () const
 Converts the Vector2 to an Any. More...
 
String toString () const
 
Vector2 wrap (const Vector2 &v) const
 
Vector2 wrap (float f) 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 Vector2 hammersleySequence2D (int rayIndex, int raysPerPixel)
 
static const Vector2inf ()
 
static const Vector2maxFinite ()
 Largest representable vector. More...
 
static const Vector2minFinite ()
 smallest (most negative) representable vector More...
 
static const Vector2nan ()
 
static const Vector2one ()
 
static Vector2 random (Random &r=Random::common())
 Uniformly distributed random vector on the unit sphere. More...
 
static const Vector2unitX ()
 
static const Vector2unitY ()
 
static const Vector2zero ()
 

Public Attributes

float x
 
float y
 

Static Public Attributes

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

Detailed Description


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

Constructor & Destructor Documentation

◆ Vector2() [1/12]

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

◆ Vector2() [2/12]

G3D::Vector2::Vector2 ( DoNotInitialize  dni)
inline

◆ Vector2() [3/12]

G3D::Vector2::Vector2 ( )
inline

◆ Vector2() [4/12]

G3D::Vector2::Vector2 ( class TextInput t)

◆ Vector2() [5/12]

G3D::Vector2::Vector2 ( class BinaryInput b)

◆ Vector2() [6/12]

G3D::Vector2::Vector2 ( float  x,
float  y 
)
inline

◆ Vector2() [7/12]

G3D::Vector2::Vector2 ( float  coordinate[2])
inline

◆ Vector2() [8/12]

G3D::Vector2::Vector2 ( double  coordinate[2])
inline

◆ Vector2() [9/12]

G3D::Vector2::Vector2 ( const Vector2 other)
inline

◆ Vector2() [10/12]

G3D::Vector2::Vector2 ( const Vector2int16 other)
inline

◆ Vector2() [11/12]

G3D::Vector2::Vector2 ( const Vector2unorm16 other)
inline

◆ Vector2() [12/12]

G3D::Vector2::Vector2 ( const Vector2int32 other)
explicit

Member Function Documentation

◆ abs()

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

Componentwise absolute value.

◆ ceil()

Vector2 G3D::Vector2::ceil ( ) const
inline

◆ clamp() [1/2]

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

Referenced by G3D::clamp().

◆ clamp() [2/2]

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

◆ deserialize() [1/2]

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

◆ deserialize() [2/2]

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

◆ direction()

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().

◆ directionOrZero()

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

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

Referenced by G3D::squareMagnitude().

◆ dot()

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

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

◆ fastDirection()

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


Potentially less accurate but faster than direction().

Only works if System::hasSSE is true.

◆ floor()

Vector2 G3D::Vector2::floor ( ) const
inline

◆ fuzzyEq()

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

◆ fuzzyNe()

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

◆ hammersleySequence2D()

static Vector2 G3D::Vector2::hammersleySequence2D ( int  rayIndex,
int  raysPerPixel 
)
inlinestatic

◆ hashCode()

size_t G3D::Vector2::hashCode ( ) const

◆ inf()

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

◆ isFinite()

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

Returns true if this vector has finite length.

◆ isNaN()

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

True if any field is NaN.

Referenced by G3D::EventCoordinateMapper::ready().

◆ isUnit()

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

Returns true if this vector has length == 1.

◆ isZero()

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

Returns true if this vector has length == 0.

◆ length()

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

Magnitude of the vector.

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

◆ lerp()

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


Linear interpolation

Referenced by G3D::lerp().

◆ max()

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

Component-wise maximum.

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

◆ maxAbs()

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

◆ maxFinite()

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

Largest representable vector.

◆ min()

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

Component-wise minimum.

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

◆ minAbs()

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

◆ minFinite()

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

smallest (most negative) representable vector

◆ mod1()

Vector2 G3D::Vector2::mod1 ( ) const
inline

Fast implementation of wrap(1.0f)

◆ nan()

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

◆ one()

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

◆ operator!=()

bool G3D::Vector2::operator!= ( const Vector2 other) const
inline

◆ operator*() [1/2]

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

◆ operator*() [2/2]

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

Array (pointwise) multiplication.

◆ operator*=() [1/2]

Vector2 & G3D::Vector2::operator*= ( float  fScalar)
inline

◆ operator*=() [2/2]

Vector2 & G3D::Vector2::operator*= ( const Vector2 rkVector)
inline

◆ operator+()

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

◆ operator+=()

Vector2 & G3D::Vector2::operator+= ( const Vector2 rkVector)
inline

◆ operator-() [1/2]

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

◆ operator-() [2/2]

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

Unary minus.

◆ operator-=()

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

◆ operator/() [1/2]

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

Array division.

◆ operator/() [2/2]

Vector2 G3D::Vector2::operator/ ( float  s) const

◆ operator/=() [1/2]

Vector2& G3D::Vector2::operator/= ( float  )

◆ operator/=() [2/2]

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

Vector2 & G3D::Vector2::operator= ( const Vector2 other)
inline

◆ operator==()

bool G3D::Vector2::operator== ( const Vector2 other) const
inline

◆ operator[]() [1/2]

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

◆ operator[]() [2/2]

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

◆ pow()

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

Raise each component of this vector to a power.

◆ random()

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

Uniformly distributed random vector on the unit sphere.

◆ serialize() [1/2]

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

◆ serialize() [2/2]

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

◆ squaredLength()

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

◆ sum()

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

x + y

◆ toAny()

Any G3D::Vector2::toAny ( ) const

Converts the Vector2 to an Any.

◆ toString()

String G3D::Vector2::toString ( ) const

◆ unitX()

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

◆ unitY()

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

◆ wrap() [1/2]

Vector2 G3D::Vector2::wrap ( const Vector2 v) const
inline
See also
mod1()

Referenced by wrap().

◆ wrap() [2/2]

Vector2 G3D::Vector2::wrap ( float  f) const
inline
See also
mod1()

◆ xx()

Vector2 G3D::Vector2::xx ( ) const

◆ xxx()

Vector3 G3D::Vector2::xxx ( ) const

◆ xxxx()

Vector4 G3D::Vector2::xxxx ( ) const

◆ xxxy()

Vector4 G3D::Vector2::xxxy ( ) const

◆ xxy()

Vector3 G3D::Vector2::xxy ( ) const

◆ xxyx()

Vector4 G3D::Vector2::xxyx ( ) const

◆ xxyy()

Vector4 G3D::Vector2::xxyy ( ) const

◆ xy()

Vector2 G3D::Vector2::xy ( ) const

◆ xyx()

Vector3 G3D::Vector2::xyx ( ) const

◆ xyxx()

Vector4 G3D::Vector2::xyxx ( ) const

◆ xyxy()

Vector4 G3D::Vector2::xyxy ( ) const

◆ xyy()

Vector3 G3D::Vector2::xyy ( ) const

◆ xyyx()

Vector4 G3D::Vector2::xyyx ( ) const

◆ xyyy()

Vector4 G3D::Vector2::xyyy ( ) const

◆ yx()

Vector2 G3D::Vector2::yx ( ) const

◆ yxx()

Vector3 G3D::Vector2::yxx ( ) const

◆ yxxx()

Vector4 G3D::Vector2::yxxx ( ) const

◆ yxxy()

Vector4 G3D::Vector2::yxxy ( ) const

◆ yxy()

Vector3 G3D::Vector2::yxy ( ) const

◆ yxyx()

Vector4 G3D::Vector2::yxyx ( ) const

◆ yxyy()

Vector4 G3D::Vector2::yxyy ( ) const

◆ yy()

Vector2 G3D::Vector2::yy ( ) const

◆ yyx()

Vector3 G3D::Vector2::yyx ( ) const

◆ yyxx()

Vector4 G3D::Vector2::yyxx ( ) const

◆ yyxy()

Vector4 G3D::Vector2::yyxy ( ) const

◆ yyy()

Vector3 G3D::Vector2::yyy ( ) const

◆ yyyx()

Vector4 G3D::Vector2::yyyx ( ) const

◆ yyyy()

Vector4 G3D::Vector2::yyyy ( ) const

◆ zero()

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

Member Data Documentation

◆ ignore

Vector2 G3D::Vector2::ignore
static

For use with default output arguments.

The value is always undefined.

◆ x

float G3D::Vector2::x

◆ y

float G3D::Vector2::y

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