openvrml::vec2f Struct Reference
A POD-struct comprising a two-component single-precision vector.
More...
#include <openvrml/basetypes.h>
List of all members.
Public Member Functions |
vec2f & | operator*= (float scalar) throw () |
| Multiply by a scalar.
|
vec2f & | operator/= (float scalar) throw () |
| Divide by a scalar.
|
vec2f & | operator+= (const vec2f &vec) throw () |
| Add a vector.
|
vec2f & | operator-= (const vec2f &vec) throw () |
| Subtract a vector.
|
const vec2f | 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 | dot (const vec2f &vec) const throw () |
| Dot product.
|
float | length () const throw () |
| Geometric length.
|
const vec2f | normalize () const throw () |
| Normalize.
|
Public Attributes |
float | vec [2] |
| Vector components.
|
Related Functions |
(Note that these are not member functions.)
|
const openvrml::vec2f | make_vec2f () throw() |
| Create a vec2f .
|
const openvrml::vec2f | make_vec2f (const float(&vec)[2]) throw() |
| Create a vec2f from an array.
|
const openvrml::vec2f | make_vec2f (const float x, const float y) throw() |
| Create a vec2f from x and y components.
|
const openvrml::vec2f | operator* (const vec2f &lhs, const float rhs) throw() |
| Multiply a vector by a scalar.
|
const openvrml::vec2f | operator* (const float lhs, const vec2f &rhs) throw() |
| Multiply a vector by a scalar.
|
const openvrml::vec2f | operator/ (const vec2f &lhs, const float rhs) throw() |
| Divide a vector by a scalar.
|
const openvrml::vec2f | operator+ (const vec2f &lhs, const vec2f &rhs) throw() |
| Add two vectors.
|
const openvrml::vec2f | operator- (const vec2f &lhs, const vec2f &rhs) throw() |
| Subtract two vectors.
|
bool | operator== (const vec2f &lhs, const vec2f &rhs) throw() |
| Compare for equality.
|
bool | operator!= (const vec2f &lhs, const vec2f &rhs) throw() |
| Compare for inequality.
|
std::istream & | operator>> (std::istream &in, vec2f &v) |
| Stream input.
|
std::ostream & | operator<< (std::ostream &out, const vec2f &v) |
| Stream output.
|
Detailed Description
A POD-struct comprising a two-component single-precision vector.
Member Function Documentation
Multiply by a scalar.
- Parameters:
-
[in] | scalar | factor by which to multiply. |
- Returns:
- a reference to the object.
Divide by a scalar.
- Precondition:
scalar
is nonzero.
- Parameters:
-
- Returns:
- a reference to the object.
Add a vector.
- Parameters:
-
[in] | vec | the vector to add. |
- Returns:
- a reference to the object.
Subtract a vector.
- Parameters:
-
[in] | vec | the vector to subtract. |
- Returns:
- a reference to the object.
Negate.
- Returns:
- the additive inverse of the vector.
const float & openvrml::vec2f::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. |
- Returns:
- a const reference to the component corresponding to
index
.
- Precondition:
index
is less than 2.
float openvrml::vec2f::x |
( |
|
) |
const throw () [inline] |
Get the x component.
- Returns:
- the x component.
void openvrml::vec2f::x |
( |
float |
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. |
float openvrml::vec2f::y |
( |
|
) |
const throw () [inline] |
Get the y component.
- Returns:
- the y component.
void openvrml::vec2f::y |
( |
float |
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. |
float openvrml::vec2f::dot |
( |
const vec2f & |
vec |
) |
const throw () |
Dot product.
- Parameters:
-
- Returns:
- the dot product of the vector and
vec
.
float openvrml::vec2f::length |
( |
|
) |
const throw () |
Geometric length.
- Returns:
- the length of the vector.
Normalize.
- Returns:
- the vector normalized.
Friends And Related Function Documentation
const openvrml::vec2f make_vec2f |
( |
const float(&) |
vec[2] |
) |
throw() [related] |
Create a vec2f
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
vec2f
with the values in vec
.
const openvrml::vec2f make_vec2f |
( |
const float |
x, |
|
|
const float |
y | |
|
) |
| | throw() [related] |
Create a vec2f
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.
- Precondition:
x
and y
are valid numeric values (i.e., not NaN).
- Parameters:
-
[in] | x | x component. |
[in] | y | y component. |
- Returns:
- a
vec2f
with the values x
and y
.
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.
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.
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.
Add two vectors.
- Parameters:
-
[in] | lhs | left-hand operand. |
[in] | rhs | right-hand operand. |
- Returns:
- the result vector.
Subtract two vectors.
- Parameters:
-
[in] | lhs | left-hand operand. |
[in] | rhs | right-hand operand. |
- Returns:
- the result vector.
bool operator== |
( |
const vec2f & |
lhs, |
|
|
const vec2f & |
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 vec2f & |
lhs, |
|
|
const vec2f & |
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, |
|
|
vec2f & |
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 vec2f . |
- Returns:
in
.
std::ostream & operator<< |
( |
std::ostream & |
out, |
|
|
const vec2f & |
v | |
|
) |
| | [related] |
Stream output.
- Parameters:
-
[in,out] | out | output stream. |
[in] | v | a 2-component vector. |
- Returns:
out
.
Member Data Documentation