Home | Download | Screen shots | Discussion | Documentation
--- | --- | --- | --- | ---

Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members | Related Pages

# openvrml::vec3f Class Reference
[Base Types]

List of all members.

## Detailed Description

Three-component single precision vector.

## Public Member Functions
| vec3f () throw ()
| Construct.
| vec3f (const float(&vec)[3]) throw ()
| Construct from an array.
| vec3f (float x, float y, float z) throw ()
| Construct from `x`, `y`, and `z` components.
vec3f & | operator *= (const vec3f &vec) throw ()
| Cross multiply.
vec3f & | operator *= (const mat4f &mat) throw ()
| Multiply by a matrix.
vec3f & | operator *= (float scalar) throw ()
| Multiply by a scalar.
vec3f & | operator/= (float scalar) throw ()
| Divide by a scalar.
vec3f & | operator+= (const vec3f &vec) throw ()
| Add a vector.
vec3f & | operator-= (const vec3f &vec) throw ()
| Subtract a vector.
const vec3f | operator- () const throw ()
| Negate.
const float & | operator[] (size_t index) const throw ()
| Index-based component access.
float | x () const throw ()
| Get the x component.
float | y () const throw ()
| Get the y component.
float | z () const throw ()
| Get the z component.
void | x (float value) throw ()
| Set the x component.
void | y (float value) throw ()
| Set the y 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.
## Private Attributes
float | vec [3]
| Vector components.
## Related Functions
(Note that these are not member functions.)
const vec3f | operator * (const vec3f &lhs, const vec3f &rhs) throw()
| Cross multiply two vectors.
const vec3f | operator * (const vec3f &vec, const mat4f &mat) throw()
| Multiply a vector by a matrix.
const vec3f | operator * (const mat4f &mat, const vec3f &vec) throw()
| Multiply a matrix by a vector.
const vec3f | operator * (const vec3f &lhs, const float rhs) throw()
| Multiply a vector by a scalar.
const vec3f | operator * (const float lhs, const vec3f &rhs) throw()
| Multiply a vector by a scalar.
const vec3f | operator/ (const vec3f &lhs, const float rhs) throw()
| Divide a vector by a scalar.
const vec3f | operator+ (const vec3f &lhs, const vec3f &rhs) throw()
| Add two vectors.
const 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::ostream & | operator<< (std::ostream &out, const vec3f &v)
| Stream output.

## Constructor & Destructor Documentation

openvrml::vec3f::vec3f | ( |  | ) | throw ()

| Construct.

openvrml::vec3f::vec3f | ( | const float & | vec[3] | ) | throw ()`[explicit]`

  | Construct from an array. Precondition: Elements of `vec` are valid numeric values (i.e., not NaN). Parameters:
  | vec | an array comprising the vector components.

openvrml::vec3f::vec3f | ( | float | x,
|  | float | y,
|  | float | z
| ) | throw ()

  | Construct from `x`, `y`, and `z` components. Precondition: `x`, `y`, and `z` are valid numeric values (i.e., not NaN). Parameters:
  | x | x component.
  | y | y component.
  | z | z component.

## Member Function Documentation

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

  | Cross multiply. Parameters:
  | vec | vector by which to multiply.
Returns: a reference to the object.

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

  | Multiply by a matrix. Parameters:
  | mat | matrix by which to multiply.
Returns: a reference to the object.

vec3f & openvrml::vec3f::operator *= | ( | float | scalar | ) | throw ()

  | Multiply by a scalar. Parameters:
  | scalar | factor by which to multiply.
Returns: a reference to the object.

vec3f & openvrml::vec3f::operator/= | ( | float | scalar | ) | throw ()

  | Divide by a scalar. Precondition: `scalar` is nonzero. Parameters:
  | scalar | divisor.
Returns: a reference to the object.

vec3f & openvrml::vec3f::operator+= | ( | const vec3f & | vec | ) | throw ()

  | Add a vector. Parameters:
  | vec | the vector to add.
Returns: a reference to the object.

vec3f & openvrml::vec3f::operator-= | ( | const vec3f & | vec | ) | throw ()

  | Subtract a vector. Parameters:
  | vec | the vector to subtract.
Returns: a reference to the object.

const vec3f openvrml::vec3f::operator- | ( |  | ) | const throw ()

| Negate. Returns: the additive inverse of the vector.

const float & openvrml::vec3f::operator[] | ( | size_t | index | ) | const throw ()`[inline]`

  | Index-based component access. Parameters:
  | 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.

float openvrml::vec3f::x | ( |  | ) | const throw ()`[inline]`

| Get the x component. Returns: the x component.

float openvrml::vec3f::y | ( |  | ) | const throw ()`[inline]`

| Get the y component. Returns: the y component.

float openvrml::vec3f::z | ( |  | ) | const throw ()`[inline]`

| Get the z component. Returns: the z 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:
  | value | new x component value.

void openvrml::vec3f::y | ( | float | value | ) | throw ()`[inline]`

  | Set the y component. Precondition: `value` is a valid numeric value (i.e., not NaN). Parameters:
  | value | new y component value.

void openvrml::vec3f::z | ( | float | value | ) | throw ()`[inline]`

  | Set the z component. Precondition: `value` is a valid numeric value (i.e., not NaN). Parameters:
  | value | new z component value.

float openvrml::vec3f::dot | ( | const vec3f & | vec | ) | const throw ()

  | Dot product. Parameters:
  | 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 vec3f openvrml::vec3f::normalize | ( |  | ) | const throw ()

| Normalize. Returns: a vec3f that is the vector normalized.

## Friends And Related Function Documentation

const vec3f operator * | ( | const vec3f & | lhs,
|  | const vec3f & | rhs
| ) | throw()`[related]`

  | Cross multiply two vectors. Parameters:
  | lhs | left-hand operand.
  | rhs | right-hand operand.
Returns: the result vector.

const vec3f operator * | ( | const vec3f & | vec,
|  | const mat4f & | mat
| ) | throw()`[related]`

  | Multiply a vector by a matrix. Parameters:
  | vec | a 3-component vector.
  | mat | a matrix.
Returns: the result vector.

const vec3f operator * | ( | const mat4f & | mat,
|  | const vec3f & | vec
| ) | throw()`[related]`

  | Multiply a matrix by a vector. Parameters:
  | mat | a matrix.
  | vec | a 3-component vector.
Returns: the result vector.

const vec3f operator * | ( | const vec3f & | lhs,
|  | const float | rhs
| ) | throw()`[related]`

  | Multiply a vector by a scalar. Parameters:
  | lhs | left-hand operand (the vector).
  | rhs | right-hand operand (the scalar).
Returns: the result vector.

const vec3f operator * | ( | const float | lhs,
|  | const vec3f & | rhs
| ) | throw()`[related]`

  | Multiply a vector by a scalar. Parameters:
  | lhs | left-hand operand (the scalar).
  | rhs | right-hand operand (the vector).
Returns: the result vector.

const vec3f operator/ | ( | const vec3f & | lhs,
|  | const float | rhs
| ) | throw()`[related]`

  | Divide a vector by a scalar. Precondition: `rhs` is nonzero. Parameters:
  | lhs | left-hand operand (the vector).
  | rhs | right-hand operand (the scalar).
Returns: the result vector.

const vec3f operator+ | ( | const vec3f & | lhs,
|  | const vec3f & | rhs
| ) | throw()`[related]`

  | Add two vectors. Parameters:
  | lhs | left-hand operand.
  | rhs | right-hand operand.
Returns: the result vector.

const vec3f operator- | ( | const vec3f & | lhs,
|  | const vec3f & | rhs
| ) | throw()`[related]`

  | Subtract two vectors. Parameters:
  | lhs | left-hand operand.
  | rhs | right-hand operand.
Returns: the result vector.

bool operator== | ( | const vec3f & | lhs,
|  | const vec3f & | rhs
| ) | throw()`[related]`

  | Compare for equality. Parameters:
  | lhs | left-hand operand.
  | rhs | right-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:
  | lhs | left-hand operand.
  | rhs | right-hand operand.
Returns: `true` if `lhs` and `rhs` dot not have the same value; `false` otherwise.

std::ostream & operator<< | ( | std::ostream & | out,
|  | const vec3f & | v
| ) | `[related]`

  | Stream output. Parameters:
  | out | output stream.
  | v | a 3-component vector.
Returns: `out`.

## Member Data Documentation

float openvrml::vec3f::vec[3]`[private]`

| Vector components. For internal use only.