openvrml::vec3f Struct Reference

Three-component single-precision vector. More...

#include <openvrml/basetypes.h>

List of all members.

Public Member Functions

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

Public Attributes

float vec [3]
 Vector components.

Related Functions

(Note that these are not member functions.)

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

Detailed Description

Three-component single-precision vector.


Member Function Documentation

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

Cross multiply.

Parameters:
[in]vecvector by which to multiply.
Returns:
a reference to the object.
openvrml::vec3f & openvrml::vec3f::operator*= ( const mat4f mat) throw ()

Multiply by a matrix.

Parameters:
[in]matmatrix by which to multiply.
Returns:
a reference to the object.
openvrml::vec3f & openvrml::vec3f::operator*= ( float  scalar) throw ()

Multiply by a scalar.

Parameters:
[in]scalarfactor by which to multiply.
Returns:
a reference to the object.
openvrml::vec3f & openvrml::vec3f::operator/= ( float  scalar) throw ()

Divide by a scalar.

Precondition:
scalar is nonzero.
Parameters:
[in]scalardivisor.
Returns:
a reference to the object.
openvrml::vec3f & openvrml::vec3f::operator+= ( const vec3f vec) throw ()

Add a vector.

Parameters:
[in]vecthe vector to add.
Returns:
a reference to the object.
openvrml::vec3f & openvrml::vec3f::operator-= ( const vec3f vec) throw ()

Subtract a vector.

Parameters:
[in]vecthe vector to subtract.
Returns:
a reference to the object.
const openvrml::vec3f openvrml::vec3f::operator- ( ) const throw ()

Negate.

Returns:
the additive inverse of the vector.
const float & openvrml::vec3f::operator[] ( std::size_t  index) const throw () [inline]

Index-based component access.

Parameters:
[in]index0 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.
float openvrml::vec3f::x ( ) const throw () [inline]

Get the x component.

Returns:
the x component.
void openvrml::vec3f::x ( float  value) throw () [inline]

Set the x component.

Precondition:
value is a valid numeric value (i.e., not NaN).
Parameters:
[in]valuenew x component value.
float openvrml::vec3f::y ( ) const throw () [inline]

Get the y component.

Returns:
the y component.
void openvrml::vec3f::y ( float  value) throw () [inline]

Set the y component.

Precondition:
value is a valid numeric value (i.e., not NaN).
Parameters:
[in]valuenew y component value.
float openvrml::vec3f::z ( ) const throw () [inline]

Get the z component.

Returns:
the z component.
void openvrml::vec3f::z ( float  value) throw () [inline]

Set the z component.

Precondition:
value is a valid numeric value (i.e., not NaN).
Parameters:
[in]valuenew z component value.
float openvrml::vec3f::dot ( const vec3f vec) const throw ()

Dot product.

Parameters:
[in]vec
Returns:
the dot product of the vector and vec.
float openvrml::vec3f::length ( ) const throw ()

Geometric length.

Returns:
the length of the vector.
const openvrml::vec3f openvrml::vec3f::normalize ( ) const throw ()

Normalize.

Returns:
the vector normalized.

Friends And Related Function Documentation

const openvrml::vec3f make_vec3f ( ) throw() [related]

Create a vec3f.

Returns:
a zero-initialized vec3f.
const openvrml::vec3f make_vec3f ( const float(&)  vec[3]) throw() [related]

Create a vec3f 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]vecan array comprising the vector components.
Returns:
a vec3f with the values in vec.
const openvrml::vec3f make_vec3f ( const float  x,
const float  y,
const float  z 
) throw() [related]

Create a vec3f 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]xx component.
[in]yy component.
[in]zz component.
Returns:
a vec3f with the values x, y, and z.
const openvrml::vec3f operator* ( const vec3f lhs,
const vec3f rhs 
) throw() [related]

Cross multiply two vectors.

Parameters:
[in]lhsleft-hand operand.
[in]rhsright-hand operand.
Returns:
the result vector.
const openvrml::vec3f operator* ( const vec3f vec,
const mat4f mat 
) throw() [related]

Multiply a vector by a matrix.

Parameters:
[in]veca vector.
[in]mata matrix.
Returns:
the result vector.
const openvrml::vec3f operator* ( const mat4f mat,
const vec3f vec 
) throw() [related]

Multiply a matrix by a vector.

Parameters:
[in]mata matrix.
[in]veca 3-component vector.
Returns:
the result vector.
const openvrml::vec3f operator* ( const vec3f lhs,
const float  rhs 
) throw() [related]

Multiply a vector by a scalar.

Parameters:
[in]lhsleft-hand operand (the vector).
[in]rhsright-hand operand (the scalar).
Returns:
the result vector.
const openvrml::vec3f operator* ( const float  lhs,
const vec3f rhs 
) throw() [related]

Multiply a vector by a scalar.

Parameters:
[in]lhsleft-hand operand (the scalar).
[in]rhsright-hand operand (the vector).
Returns:
the result vector.
const openvrml::vec3f operator/ ( const vec3f lhs,
const float  rhs 
) throw() [related]

Divide a vector by a scalar.

Precondition:
rhs is nonzero.
Parameters:
[in]lhsleft-hand operand (the vector).
[in]rhsright-hand operand (the scalar).
Returns:
the result vector.
const openvrml::vec3f operator+ ( const vec3f lhs,
const vec3f rhs 
) throw() [related]

Add two vectors.

Parameters:
[in]lhsleft-hand operand.
[in]rhsright-hand operand.
Returns:
the result vector.
const openvrml::vec3f operator- ( const vec3f lhs,
const vec3f rhs 
) throw() [related]

Subtract two vectors.

Parameters:
[in]lhsleft-hand operand.
[in]rhsright-hand operand.
Returns:
the result vector.
bool operator== ( const vec3f lhs,
const vec3f rhs 
) throw() [related]

Compare for equality.

Parameters:
[in]lhsleft-hand operand.
[in]rhsright-hand operand.
Returns:
true if lhs and rhs have the same value; false otherwise.
bool operator!= ( const vec3f lhs,
const vec3f rhs 
) throw() [related]

Compare for inequality.

Parameters:
[in]lhsleft-hand operand.
[in]rhsright-hand operand.
Returns:
true if lhs and rhs dot not have the same value; false otherwise.
std::istream & operator>> ( std::istream &  in,
vec3f v 
) [related]

Stream input.

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

Parameters:
[in,out]ininput stream.
[out]va vec3f.
Returns:
in.
std::ostream & operator<< ( std::ostream &  out,
const vec3f v 
) [related]

Stream output.

Parameters:
[in,out]outoutput stream.
[in]va 3-component vector.
Returns:
out.

Member Data Documentation

Vector components.