Home | Download | Screen shots | Discussion | Documentation |
---|
Two-component double-precision vector. More...
#include <openvrml/basetypes.h>
Public Member Functions | |
vec2d & | operator*= (double scalar) throw () |
Multiply by a scalar. | |
vec2d & | operator/= (double scalar) throw () |
Divide by a scalar. | |
vec2d & | operator+= (const vec2d &vec) throw () |
Add a vector. | |
vec2d & | operator-= (const vec2d &vec) throw () |
Subtract a vector. | |
const vec2d | 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 | dot (const vec2d &vec) const throw () |
Dot product. | |
double | length () const throw () |
Geometric length. | |
const vec2d | normalize () const throw () |
Normalize. | |
Public Attributes | |
double | vec [2] |
Vector components. | |
Related Functions | |
(Note that these are not member functions.) | |
const openvrml::vec2d | make_vec2d () throw() |
Create a vec2d . | |
const openvrml::vec2d | make_vec2d (const double(&vec)[2]) throw() |
Create a vec2d from an array. | |
const openvrml::vec2d | make_vec2d (const double x, const double y) throw() |
Create a vec2d from x and y components. | |
const openvrml::vec2d | operator* (const vec2d &lhs, const double rhs) throw() |
Multiply a vector by a scalar. | |
const openvrml::vec2d | operator* (const double lhs, const vec2d &rhs) throw() |
Multiply a vector by a scalar. | |
const openvrml::vec2d | operator/ (const vec2d &lhs, const double rhs) throw() |
Divide a vector by a scalar. | |
const openvrml::vec2d | operator+ (const vec2d &lhs, const vec2d &rhs) throw() |
Add two vectors. | |
const openvrml::vec2d | operator- (const vec2d &lhs, const vec2d &rhs) throw() |
Subtract two vectors. | |
bool | operator== (const vec2d &lhs, const vec2d &rhs) throw() |
Compare for equality. | |
bool | operator!= (const vec2d &lhs, const vec2d &rhs) throw() |
Compare for inequality. | |
std::istream & | operator>> (std::istream &in, vec2d &v) |
Stream input. | |
std::ostream & | operator<< (std::ostream &out, const vec2d &v) |
Stream output. |
Two-component double-precision vector.
openvrml::vec2d & openvrml::vec2d::operator*= | ( | double | scalar | ) | throw () |
Multiply by a scalar.
[in] | scalar | factor by which to multiply. |
openvrml::vec2d & openvrml::vec2d::operator/= | ( | double | scalar | ) | throw () |
Divide by a scalar.
scalar
is nonzero.[in] | scalar | divisor. |
openvrml::vec2d & openvrml::vec2d::operator+= | ( | const vec2d & | vec | ) | throw () |
Add a vector.
[in] | vec | the vector to add. |
openvrml::vec2d & openvrml::vec2d::operator-= | ( | const vec2d & | vec | ) | throw () |
Subtract a vector.
[in] | vec | the vector to subtract. |
const openvrml::vec2d openvrml::vec2d::operator- | ( | ) | const throw () |
Negate.
const double & openvrml::vec2d::operator[] | ( | std::size_t | index | ) | const throw () [inline] |
Index-based component access.
[in] | index | 0 corresponds to the x component; 1 corresponds to the y component. |
index
.index
is less than 2. double openvrml::vec2d::x | ( | ) | const throw () [inline] |
Get the x component.
void openvrml::vec2d::x | ( | double | value | ) | throw () [inline] |
Set the x component.
value
is a valid numeric value (i.e., not NaN).[in] | value | new x component value. |
double openvrml::vec2d::y | ( | ) | const throw () [inline] |
Get the y component.
void openvrml::vec2d::y | ( | double | value | ) | throw () [inline] |
Set the y component.
value
is a valid numeric value (i.e., not NaN).[in] | value | new y component value. |
double openvrml::vec2d::dot | ( | const vec2d & | vec | ) | const throw () |
Dot product.
[in] | vec |
vec
. double openvrml::vec2d::length | ( | ) | const throw () |
Geometric length.
const openvrml::vec2d openvrml::vec2d::normalize | ( | ) | const throw () |
Normalize.
const openvrml::vec2d make_vec2d | ( | ) | throw() [related] |
const openvrml::vec2d make_vec2d | ( | const double(&) | vec[2] | ) | throw() [related] |
Create a vec2d
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.
vec
are valid numeric values (i.e., not NaN).[in] | vec | an array comprising the vector components. |
vec2d
with the values in vec
. const openvrml::vec2d make_vec2d | ( | const double | x, |
const double | y | ||
) | throw() [related] |
Create a vec2d
from x
and y
components.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
x
and y
are valid numeric values (i.e., not NaN).[in] | x | x component. |
[in] | y | y component. |
vec2d
with the values x
and y
. const openvrml::vec2d operator* | ( | const vec2d & | lhs, |
const double | rhs | ||
) | throw() [related] |
Multiply a vector by a scalar.
[in] | lhs | left-hand operand (the vector). |
[in] | rhs | right-hand operand (the scalar). |
const openvrml::vec2d operator* | ( | const double | lhs, |
const vec2d & | rhs | ||
) | throw() [related] |
Multiply a vector by a scalar.
[in] | lhs | left-hand operand (the scalar). |
[in] | rhs | right-hand operand (the vector). |
const openvrml::vec2d operator/ | ( | const vec2d & | lhs, |
const double | rhs | ||
) | throw() [related] |
Divide a vector by a scalar.
rhs
is nonzero.[in] | lhs | left-hand operand (the vector). |
[in] | rhs | right-hand operand (the scalar). |
const openvrml::vec2d operator+ | ( | const vec2d & | lhs, |
const vec2d & | rhs | ||
) | throw() [related] |
Add two vectors.
[in] | lhs | left-hand operand. |
[in] | rhs | right-hand operand. |
const openvrml::vec2d operator- | ( | const vec2d & | lhs, |
const vec2d & | rhs | ||
) | throw() [related] |
Subtract two vectors.
[in] | lhs | left-hand operand. |
[in] | rhs | right-hand operand. |
Compare for equality.
[in] | lhs | left-hand operand. |
[in] | rhs | right-hand operand. |
true
if lhs
and rhs
have the same value; false
otherwise. Compare for inequality.
[in] | lhs | left-hand operand. |
[in] | rhs | right-hand operand. |
true
if lhs
and rhs
dot not have the same value; false
otherwise. std::istream & operator>> | ( | std::istream & | in, |
vec2d & | v | ||
) | [related] |
Stream input.
Consistent with the VRML97 convention, commas (“,”) in the input are treated as whitespace.
[in,out] | in | input stream. |
[out] | v | a vec2d . |
in
. std::ostream & operator<< | ( | std::ostream & | out, |
const vec2d & | v | ||
) | [related] |
Stream output.
[in,out] | out | output stream. |
[in] | v | a 2-component vector. |
out
. double openvrml::vec2d::vec[2] |
Vector components.