openvrml::vec3d Struct Reference

A POD-struct comprising a three-component double-precision vector. More...

#include <openvrml/basetypes.h>

List of all members.


Public Member Functions

vec3doperator*= (const vec3d &vec) throw ()
 Cross multiply.
vec3doperator*= (const mat4f &mat) throw ()
 Multiply by a matrix.
vec3doperator*= (double scalar) throw ()
 Multiply by a scalar.
vec3doperator/= (double scalar) throw ()
 Divide by a scalar.
vec3doperator+= (const vec3d &vec) throw ()
 Add a vector.
vec3doperator-= (const vec3d &vec) throw ()
 Subtract a vector.
const vec3d operator- () const throw ()
 Negate.
const double & operator[] (std::size_t index) const throw ()
 Index-based component access.
double x () const throw ()
 Get the x component.
void x (double value) throw ()
 Set the x component.
double y () const throw ()
 Get the y component.
void y (double value) throw ()
 Set the y component.
double z () const throw ()
 Get the z component.
void z (double value) throw ()
 Set the z component.
double dot (const vec3d &vec) const throw ()
 Dot product.
double length () const throw ()
 Geometric length.
const vec3d normalize () const throw ()
 Normalize.

Public Attributes

double vec [3]
 Vector components.

Related Functions

(Note that these are not member functions.)

const openvrml::vec3d make_vec3d () throw()
 Create a vec3d.
const openvrml::vec3d make_vec3d (const double(&vec)[3]) throw()
 Create a vec3d from an array.
const openvrml::vec3d make_vec3d (const double x, const double y, const double z) throw()
 Create a vec3d from x, y, and z components.
const openvrml::vec3d operator* (const vec3d &lhs, const vec3d &rhs) throw()
 Cross multiply two vectors.
const openvrml::vec3d operator* (const vec3d &vec, const mat4f &mat) throw()
 Multiply a vector by a matrix.
const openvrml::vec3d operator* (const mat4f &mat, const vec3d &vec) throw()
 Multiply a matrix by a vector.
const openvrml::vec3d operator* (const vec3d &lhs, const double rhs) throw()
 Multiply a vector by a scalar.
const openvrml::vec3d operator* (const double lhs, const vec3d &rhs) throw()
 Multiply a vector by a scalar.
const openvrml::vec3d operator/ (const vec3d &lhs, const double rhs) throw()
 Divide a vector by a scalar.
const openvrml::vec3d operator+ (const vec3d &lhs, const vec3d &rhs) throw()
 Add two vectors.
const openvrml::vec3d operator- (const vec3d &lhs, const vec3d &rhs) throw()
 Subtract two vectors.
bool operator== (const vec3d &lhs, const vec3d &rhs) throw()
 Compare for equality.
bool operator!= (const vec3d &lhs, const vec3d &rhs) throw()
 Compare for inequality.
std::istream & operator>> (std::istream &in, vec3d &v)
 Stream input.
std::ostream & operator<< (std::ostream &out, const vec3d &v)
 Stream output.

Detailed Description

A POD-struct comprising a three-component double-precision vector.

Member Function Documentation

openvrml::vec3d & openvrml::vec3d::operator*= ( const vec3d vec  )  throw ()

Cross multiply.

Parameters:
[in] vec vector by which to multiply.
Returns:
a reference to the object.

openvrml::vec3d & openvrml::vec3d::operator*= ( const mat4f mat  )  throw ()

Multiply by a matrix.

Parameters:
[in] mat matrix by which to multiply.
Returns:
a reference to the object.

openvrml::vec3d & openvrml::vec3d::operator*= ( double  scalar  )  throw ()

Multiply by a scalar.

Parameters:
[in] scalar factor by which to multiply.
Returns:
a reference to the object.

openvrml::vec3d & openvrml::vec3d::operator/= ( double  scalar  )  throw ()

Divide by a scalar.

Precondition:
scalar is nonzero.
Parameters:
[in] scalar divisor.
Returns:
a reference to the object.

openvrml::vec3d & openvrml::vec3d::operator+= ( const vec3d vec  )  throw ()

Add a vector.

Parameters:
[in] vec the vector to add.
Returns:
a reference to the object.

openvrml::vec3d & openvrml::vec3d::operator-= ( const vec3d vec  )  throw ()

Subtract a vector.

Parameters:
[in] vec the vector to subtract.
Returns:
a reference to the object.

const openvrml::vec3d openvrml::vec3d::operator- (  )  const throw ()

Negate.

Returns:
the additive inverse of the vector.

const double & openvrml::vec3d::operator[] ( std::size_t  index  )  const throw () [inline]

Index-based component access.

Parameters:
[in] index 0 corresponds to the x component; 1 corresponds to the y component; 2 corresponds to the z component.
Returns:
a const reference to the component corresponding to index.
Precondition:
index is less than 3.

double openvrml::vec3d::x (  )  const throw () [inline]

Get the x component.

Returns:
the x component.

void openvrml::vec3d::x ( double  value  )  throw () [inline]

Set the x component.

Precondition:
value is a valid numeric value (i.e., not NaN).
Parameters:
[in] value new x component value.

double openvrml::vec3d::y (  )  const throw () [inline]

Get the y component.

Returns:
the y component.

void openvrml::vec3d::y ( double  value  )  throw () [inline]

Set the y component.

Precondition:
value is a valid numeric value (i.e., not NaN).
Parameters:
[in] value new y component value.

double openvrml::vec3d::z (  )  const throw () [inline]

Get the z component.

Returns:
the z component.

void openvrml::vec3d::z ( double  value  )  throw () [inline]

Set the z component.

Precondition:
value is a valid numeric value (i.e., not NaN).
Parameters:
[in] value new z component value.

double openvrml::vec3d::dot ( const vec3d vec  )  const throw ()

Dot product.

Parameters:
[in] vec 
Returns:
the dot product of the vector and vec.

double openvrml::vec3d::length (  )  const throw ()

Geometric length.

Returns:
the length of the vector.

const openvrml::vec3d openvrml::vec3d::normalize (  )  const throw ()

Normalize.

Returns:
the vector normalized.


Friends And Related Function Documentation

const openvrml::vec3d make_vec3d (  )  throw() [related]

Create a vec3d.

Returns:
a zero-initialized vec3d.

const openvrml::vec3d make_vec3d ( const double(&)  vec[3]  )  throw() [related]

Create a vec3d from an array.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Precondition:
Elements of vec are valid numeric values (i.e., not NaN).
Parameters:
[in] vec an array comprising the vector components.
Returns:
a vec3d with the values in vec.

const openvrml::vec3d make_vec3d ( const double  x,
const double  y,
const double  z 
) throw() [related]

Create a vec3d from x, y, and z components.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Precondition:
x, y and z are valid numeric values (i.e., not NaN).
Parameters:
[in] x x component.
[in] y y component.
[in] z z component.
Returns:
a vec3d with the values x, y, and z.

const openvrml::vec3d operator* ( const vec3d lhs,
const vec3d rhs 
) throw() [related]

Cross multiply two vectors.

Parameters:
[in] lhs left-hand operand.
[in] rhs right-hand operand.
Returns:
the result vector.

const openvrml::vec3d operator* ( const vec3d vec,
const mat4f mat 
) throw() [related]

Multiply a vector by a matrix.

Parameters:
[in] vec a vector.
[in] mat a matrix.
Returns:
the result vector.

const openvrml::vec3d operator* ( const mat4f mat,
const vec3d vec 
) throw() [related]

Multiply a matrix by a vector.

Parameters:
[in] mat a matrix.
[in] vec a 3-component vector.
Returns:
the result vector.

const openvrml::vec3d operator* ( const vec3d lhs,
const double  rhs 
) throw() [related]

Multiply a vector by a scalar.

Parameters:
[in] lhs left-hand operand (the vector).
[in] rhs right-hand operand (the scalar).
Returns:
the result vector.

const openvrml::vec3d operator* ( const double  lhs,
const vec3d rhs 
) throw() [related]

Multiply a vector by a scalar.

Parameters:
[in] lhs left-hand operand (the scalar).
[in] rhs right-hand operand (the vector).
Returns:
the result vector.

const openvrml::vec3d operator/ ( const vec3d lhs,
const double  rhs 
) throw() [related]

Divide a vector by a scalar.

Precondition:
rhs is nonzero.
Parameters:
[in] lhs left-hand operand (the vector).
[in] rhs right-hand operand (the scalar).
Returns:
the result vector.

const openvrml::vec3d operator+ ( const vec3d lhs,
const vec3d rhs 
) throw() [related]

Add two vectors.

Parameters:
[in] lhs left-hand operand.
[in] rhs right-hand operand.
Returns:
the result vector.

const openvrml::vec3d operator- ( const vec3d lhs,
const vec3d rhs 
) throw() [related]

Subtract two vectors.

Parameters:
[in] lhs left-hand operand.
[in] rhs right-hand operand.
Returns:
the result vector.

bool operator== ( const vec3d lhs,
const vec3d rhs 
) throw() [related]

Compare for equality.

Parameters:
[in] lhs left-hand operand.
[in] rhs right-hand operand.
Returns:
true if lhs and rhs have the same value; false otherwise.

bool operator!= ( const vec3d lhs,
const vec3d rhs 
) throw() [related]

Compare for inequality.

Parameters:
[in] lhs left-hand operand.
[in] rhs right-hand operand.
Returns:
true if lhs and rhs dot not have the same value; false otherwise.

std::istream & operator>> ( std::istream &  in,
vec3d v 
) [related]

Stream input.

Consistent with the VRML97 convention, commas (“,”) in the input are treated as whitespace.

Parameters:
[in,out] in input stream.
[out] v a vec3d.
Returns:
in.

std::ostream & operator<< ( std::ostream &  out,
const vec3d v 
) [related]

Stream output.

Parameters:
[in,out] out output stream.
[in] v a 3-component vector.
Returns:
out.


Member Data Documentation

Vector components.