Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes

ml7::Vector3 Class Reference

#include <Vector3.h>

List of all members.

Public Member Functions

 Vector3 (void)
 Vector3 (const Vector3 &v)
Vector3operator= (const Vector3 &v)
void swap (Vector3 &v)
 ~Vector3 (void)
 Vector3 (const float x, const float y, const float z)
 Vector3 (const float c)
const float length () const
const float lensqr () const
const Vector3 normalized () const
const Vector3 abs () const
const float operator[] (unsigned index) const
float & operator[] (unsigned index)
const Vector3 operator- () const
const Vector3 operator+ (const Vector3 &v) const
const Vector3 operator- (const Vector3 &v) const
const Vector3 operator* (const float s) const
const Vector3 operator* (const Vector3 &v) const
const float dot (const Vector3 &v) const
const float dotsqr (const Vector3 &v) const
const Vector3 cross (const Vector3 &v) const
const float comp (const Vector3 &v) const
const Vector3 proj (const Vector3 &v) const
const Vector3 x__ () const
const Vector3 _y_ () const
const Vector3 __z () const
const Vector3 xy_ () const
const Vector3 x_z () const
const Vector3 _yz () const
const Vector3 xxx () const
const Vector3 yyy () const
const Vector3 zzz () const
Vector3operator+= (const Vector3 &v)
Vector3operator-= (const Vector3 &v)
Vector3operator*= (const float s)
Vector3operator*= (const Vector3 &v)
Vector3clear ()
Vector3invert ()
Vector3normalize ()
Vector3add (const Vector3 &v, const float s)
Vector3mad (const float s, const Vector3 &v)
Vector3mul (const Vector3 &v)
const bool operator== (const Vector3 &v) const
const bool operator!= (const Vector3 &v) const
const bool operator< (const Vector3 &v) const
const bool operator> (const Vector3 &v) const
const bool operator<= (const Vector3 &v) const
const bool operator>= (const Vector3 &v) const
 operator const float *const () const
 operator float *const ()

Static Public Member Functions

static Vector3 abs1 (const Vector3 &v)
static Vector3 min2 (const Vector3 &a, const Vector3 &b)
static Vector3 max2 (const Vector3 &a, const Vector3 &b)

Public Attributes

union {
   struct {
      float   x
      float   y
      float   z
   } 
   float   data [3]
}; 

Static Public Attributes

static const Vector3 X = Vector3( 1, 0, 0 )
static const Vector3 Y = Vector3( 0, 1, 0 )
static const Vector3 Z = Vector3( 0, 0, 1 )

Detailed Description

Represents a vector with three dimensions x, y and z. Used for 3d-physics and -graphics.


Constructor & Destructor Documentation

ml7::Vector3::Vector3 ( void   )  [inline]

Default constructor. Creates a new vector with x = y = z = 0.

ml7::Vector3::Vector3 ( const Vector3 v  )  [inline]

Copy constructor. Creates a new vector with x = v.x, ... , z = v.z.

ml7::Vector3::~Vector3 ( void   )  [inline]

Destructor.

ml7::Vector3::Vector3 ( const float  x,
const float  y,
const float  z 
) [inline]

Explicit constructor with parameters for x, y and z.

ml7::Vector3::Vector3 ( const float  c  )  [inline, explicit]

Explicit constructor with one parameter for all components x, y and z.


Member Function Documentation

const Vector3 ml7::Vector3::__z (  )  const [inline]

Returns a new vector with the z component of this (x = y = 0).

const Vector3 ml7::Vector3::_y_ (  )  const [inline]

Returns a new vector with the y component of this (x = z = 0).

const Vector3 ml7::Vector3::_yz (  )  const [inline]

Returns a new vector with the z component of this (x = y = 0).

const Vector3 ml7::Vector3::abs (  )  const [inline]

Returns this vector having positive components.

static Vector3 ml7::Vector3::abs1 ( const Vector3 v  )  [inline, static]

Returns a copy of a given vector having positive components.

Vector3& ml7::Vector3::add ( const Vector3 v,
const float  s 
) [inline]

Adds a given vector v scaled by a given scalar s to this.

Vector3& ml7::Vector3::clear (  )  [inline]

Sets x = y = z = 0.

const float ml7::Vector3::comp ( const Vector3 v  )  const [inline]

Returns the scalar projection of a given vector v onto this.

const Vector3 ml7::Vector3::cross ( const Vector3 v  )  const [inline]

Returns the cross product of this and a given vector v.

const float ml7::Vector3::dot ( const Vector3 v  )  const [inline]

Returns the dot product of this and a given vector v.

const float ml7::Vector3::dotsqr ( const Vector3 v  )  const [inline]

Returns the squared dot product of this and a given vector v.

Vector3& ml7::Vector3::invert (  )  [inline]

Inverts the sign of the components of this vector.

const float ml7::Vector3::length (  )  const [inline]

Returns the magnitude of the vector.

const float ml7::Vector3::lensqr (  )  const [inline]

Returns the squared magnitude of the vector.

Vector3& ml7::Vector3::mad ( const float  s,
const Vector3 v 
) [inline]

Scales this vector by a given scalar s and then adds a given vector v to this.

static Vector3 ml7::Vector3::max2 ( const Vector3 a,
const Vector3 b 
) [inline, static]

Returns a vector having the maximum components of two given vectors.

static Vector3 ml7::Vector3::min2 ( const Vector3 a,
const Vector3 b 
) [inline, static]

Returns a vector having the minimum components of two given vectors.

Vector3& ml7::Vector3::mul ( const Vector3 v  )  [inline]

Scales this vector component-wise by a given vector v.

Vector3& ml7::Vector3::normalize (  )  [inline]

Normalizes this vector that it has a magnitude of 1.

const Vector3 ml7::Vector3::normalized (  )  const [inline]

Returns a copy of this vector normalized.

ml7::Vector3::operator const float *const (  )  const [inline]
ml7::Vector3::operator float *const (  )  [inline]
const bool ml7::Vector3::operator!= ( const Vector3 v  )  const [inline]

Checks if a given vector v and this have non-identical components.

const Vector3 ml7::Vector3::operator* ( const Vector3 v  )  const [inline]

Returns a given vector scaled component-wise by this.

const Vector3 ml7::Vector3::operator* ( const float  s  )  const [inline]

Returns a copy of this vector scaled by a given scalar s.

Vector3& ml7::Vector3::operator*= ( const float  s  )  [inline]

Scales this vector by a given scalar s.

Vector3& ml7::Vector3::operator*= ( const Vector3 v  )  [inline]

Scales this vector component-wise by a given vector v.

const Vector3 ml7::Vector3::operator+ ( const Vector3 v  )  const [inline]

Returns a given vector v added to this.

Vector3& ml7::Vector3::operator+= ( const Vector3 v  )  [inline]

Adds a given vector v to this.

const Vector3 ml7::Vector3::operator- ( const Vector3 v  )  const [inline]

Returns a given vector v subtracted from this.

const Vector3 ml7::Vector3::operator- (  )  const [inline]

Returns a copy of this vector with the components having signs flipped.

Vector3& ml7::Vector3::operator-= ( const Vector3 v  )  [inline]

Subtracts a given vector v from this.

const bool ml7::Vector3::operator< ( const Vector3 v  )  const [inline]

Checks if this vector is component-by-component less than a given vector v.

const bool ml7::Vector3::operator<= ( const Vector3 v  )  const [inline]

Checks if this vector is component-by-component less than or equal to a given vector v.

Vector3& ml7::Vector3::operator= ( const Vector3 v  )  [inline]

Copy assignment operator. Sets x = v.x, ... , z = v.z.

const bool ml7::Vector3::operator== ( const Vector3 v  )  const [inline]

Checks if a given vector v and this have identical components.

const bool ml7::Vector3::operator> ( const Vector3 v  )  const [inline]

Checks if this vector is component-by-component greater than a given vector v.

const bool ml7::Vector3::operator>= ( const Vector3 v  )  const [inline]

Checks if this vector is component-by-component greater than or equal to a given vector v.

float& ml7::Vector3::operator[] ( unsigned  index  )  [inline]

Indexed component access.

const float ml7::Vector3::operator[] ( unsigned  index  )  const [inline]

Indexed component access.

const Vector3 ml7::Vector3::proj ( const Vector3 v  )  const [inline]

Returns the vector projection of a given vector v onto this.

void ml7::Vector3::swap ( Vector3 v  )  [inline]

Swap operation. Swaps the elements of a vector v with this.

const Vector3 ml7::Vector3::x__ (  )  const [inline]

Returns a new vector with the x component of this (y = z = 0).

const Vector3 ml7::Vector3::x_z (  )  const [inline]

Returns a new vector with the y component of this (x = z = 0).

const Vector3 ml7::Vector3::xxx (  )  const [inline]

Returns a new vector with all of its components set to the x value of this.

const Vector3 ml7::Vector3::xy_ (  )  const [inline]

Returns a new vector with the x component of this (y = z = 0).

const Vector3 ml7::Vector3::yyy (  )  const [inline]

Returns a new vector with all of its components set to the y value of this.

const Vector3 ml7::Vector3::zzz (  )  const [inline]

Returns a new vector with all of its components set to the y value of this.


Member Data Documentation

union { ... }

Array of all three componets.

The vector's x value.

const Vector3 ml7::Vector3::X = Vector3( 1, 0, 0 ) [static]

The vector's y value.

const Vector3 ml7::Vector3::Y = Vector3( 0, 1, 0 ) [static]

The vector's z value.

const Vector3 ml7::Vector3::Z = Vector3( 0, 0, 1 ) [static]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines