vector Class Reference

#include <vector.hpp>

Inheritance diagram for vector:

Inheritance graph
[legend]
Collaboration diagram for vector:

Collaboration graph
[legend]

List of all members.


Detailed Description

A vector for storing homogenous coordinates.

In this implementation the homogenous coordinate is always 1.0, so the first three values may be used for 3-d coordinates.

Definition at line 53 of file vector.hpp.


Public Member Functions

vector cross (const vector &) const
gsgl::real_t dot (const vector &) const
void from_stream (io::text_stream &s)
gsgl::real_tget_w ()
const gsgl::real_tget_w () const
gsgl::real_tget_x ()
const gsgl::real_tget_x () const
gsgl::real_tget_y ()
const gsgl::real_tget_y () const
gsgl::real_tget_z ()
const gsgl::real_tget_z () const
T & item (int i, int j)
const T & item (int i, int j) const
gsgl::real_t mag () const
 Returns the magnitide of the vector.
gsgl::real_t mag2 () const
 Returns the magnitude squared of the vector.
void normalize ()
 Normalize the 3d vector (make its length equal to 1).
void normalize_h ()
 Makes sure the homogenous coordinate is 1.0 (does not make the length equal to 1).
vector operator* (const gsgl::real_t)
vectoroperator*= (const gsgl::real_t)
vector operator+ (const vector &) const
vectoroperator+ ()
vectoroperator+= (const vector &)
vector operator- (const vector &) const
vector operator- () const
vectoroperator-= (const vector &)
vectoroperator= (const matrix< 4, 1, gsgl::real_t > &)
vectoroperator= (const vector &)
bool operator== (const matrix< R, C, T > &m) const
T * ptr ()
const T * ptr () const
 Returns an array containing the matrix's data, in column-major order.
void to_stream (io::text_stream &s) const
 vector (const gsgl::string &)
 vector (const gsgl::real_t *)
 vector (const matrix< 4, 1, gsgl::real_t > &)
 vector (const vector &)
 vector (gsgl::real_t x=0, gsgl::real_t y=0, gsgl::real_t z=0)
virtual ~vector ()

Static Public Member Functions

static vector interpolate (const vector &start, const vector &end, const gsgl::real_t &percent)
static vector parse (const gsgl::string &)

Static Public Attributes

static const vector NEG_X_AXIS
static const vector NEG_Y_AXIS
static const vector NEG_Z_AXIS
static const vector X_AXIS
static const vector Y_AXIS
static const vector Z_AXIS
static const vector ZERO

Protected Attributes

data [R *C]

Constructor & Destructor Documentation

vector ( gsgl::real_t  x = 0,
gsgl::real_t  y = 0,
gsgl::real_t  z = 0 
)

Definition at line 56 of file vector.cpp.

References matrix::data.

Referenced by vector::cross(), vector::operator*(), vector::operator+(), and vector::operator-().

vector ( const vector v  ) 

Definition at line 70 of file vector.cpp.

vector ( const matrix< 4, 1, gsgl::real_t > &  v  ) 

Definition at line 75 of file vector.cpp.

References matrix::data, and vector::normalize_h().

vector ( const gsgl::real_t ptr  )  [explicit]

Definition at line 65 of file vector.cpp.

vector ( const gsgl::string s  )  [explicit]

Definition at line 98 of file vector.cpp.

References matrix::data, iterable::iter(), and string::split().

~vector (  )  [virtual]

Definition at line 94 of file vector.cpp.


Member Function Documentation

vector cross ( const vector v  )  const

Definition at line 218 of file vector.cpp.

References matrix::data, and vector::vector().

Referenced by gsgl::scenegraph::utils::draw_billboard().

gsgl::real_t dot ( const vector v  )  const

void from_stream ( io::text_stream s  )  [inline, inherited]

Definition at line 145 of file matrix.hpp.

References matrix::item().

gsgl::real_t& get_w (  )  [inline]

Definition at line 76 of file vector.hpp.

const gsgl::real_t& get_w (  )  const [inline]

gsgl::real_t& get_x (  )  [inline]

Definition at line 73 of file vector.hpp.

const gsgl::real_t& get_x (  )  const [inline]

gsgl::real_t& get_y (  )  [inline]

Definition at line 74 of file vector.hpp.

const gsgl::real_t& get_y (  )  const [inline]

gsgl::real_t& get_z (  )  [inline]

Definition at line 75 of file vector.hpp.

const gsgl::real_t& get_z (  )  const [inline]

vector interpolate ( const vector start,
const vector end,
const gsgl::real_t percent 
) [static]

Definition at line 226 of file vector.cpp.

T& item ( int  i,
int  j 
) [inline, inherited]

Definition at line 67 of file matrix.hpp.

const T& item ( int  i,
int  j 
) const [inline, inherited]

gsgl::real_t mag (  )  const

gsgl::real_t mag2 (  )  const

Returns the magnitude squared of the vector.

Returns the square of the magnitude of the 3-d vector (more efficient than vector::mag()).

Definition at line 147 of file vector.cpp.

References matrix::data.

Referenced by test_frame::get_priority(), planet_system::get_priority(), large_rocky_body::get_priority(), celestial_body::get_priority(), and freeview::handle_event().

void normalize (  ) 

void normalize_h (  ) 

Makes sure the homogenous coordinate is 1.0 (does not make the length equal to 1).

Definition at line 125 of file vector.cpp.

References matrix::data.

Referenced by transform::operator*(), and vector::vector().

vector operator* ( const gsgl::real_t  n  ) 

Note:
Does not multiply the homogeneous element.

Definition at line 204 of file vector.cpp.

References matrix::data, and vector::vector().

vector & operator*= ( const gsgl::real_t  n  ) 

Note:
Does not multiply the homogeneous element.

Definition at line 194 of file vector.cpp.

References matrix::data.

vector operator+ ( const vector v  )  const

Note:
This does not add the homogeneous element.

Definition at line 163 of file vector.cpp.

References matrix::data, and vector::vector().

vector& operator+ (  )  [inline]

Definition at line 87 of file vector.hpp.

vector & operator+= ( const vector v  ) 

Note:
Does not add the homogeneous element.

Definition at line 176 of file vector.cpp.

References matrix::data.

vector operator- ( const vector v  )  const

Note:
This does not subtract the homogeneous element.

Definition at line 169 of file vector.cpp.

References matrix::data, and vector::vector().

vector operator- (  )  const

Note:
This does not negate the homogeneous element.

Definition at line 157 of file vector.cpp.

References matrix::data, and vector::vector().

vector & operator-= ( const vector v  ) 

Note:
Does not add the homogeneous element.

Definition at line 185 of file vector.cpp.

References matrix::data.

vector & operator= ( const matrix< 4, 1, gsgl::real_t > &  m  ) 

Definition at line 88 of file vector.cpp.

References matrix::data, and matrix::ptr().

vector & operator= ( const vector v  ) 

Definition at line 82 of file vector.cpp.

References matrix::data.

bool operator== ( const matrix< R, C, T > &  m  )  const [inline, inherited]

Definition at line 118 of file matrix.hpp.

References matrix::data.

vector parse ( const gsgl::string str  )  [static]

T* ptr (  )  [inline, inherited]

Definition at line 71 of file matrix.hpp.

const T* ptr (  )  const [inline, inherited]

void to_stream ( io::text_stream s  )  const [inline, inherited]

Definition at line 130 of file matrix.hpp.

References matrix::item().


Member Data Documentation

T data[R *C] [protected, inherited]

const vector NEG_X_AXIS [static]

Definition at line 109 of file vector.hpp.

const vector NEG_Y_AXIS [static]

Definition at line 110 of file vector.hpp.

const vector NEG_Z_AXIS [static]

const vector X_AXIS [static]

Definition at line 106 of file vector.hpp.

Referenced by test_frame::recalc(), freeview::rot_absolute(), and freeview::rot_relative().

const vector Y_AXIS [static]

const vector Z_AXIS [static]

const vector ZERO [static]

Definition at line 105 of file vector.hpp.

Referenced by light::bind(), node::draw_scene(), vector::parse(), and freeview::reset().


The documentation for this class was generated from the following files:

Generated on Sat Mar 1 13:50:06 2008 for Periapsis Project by  doxygen 1.5.5