Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

SFVec2f Class Reference

Encapsulates a SFVec2f value. More...

Inheritance diagram for SFVec2f:

FieldValue List of all members.

Public Types

typedef const float (&ConstArrayReference)[2]
typedef float(* ArrayPointer )[2]
typedef const float(* ConstArrayPointer )[2]

Public Methods

typedef float (&ArrayReference)[2]
 SFVec2f () throw ()
 Construct a SFVec2f with the default values, (0, 0).

 SFVec2f (ConstArrayReference vec) throw ()
 Construct a SFVec2f.

 SFVec2f (float x, float y) throw ()
 Construct a SFVec2f.

virtual ~SFVec2f () throw ()
 Destructor.

float operator[] (size_t index) const throw ()
 Array element dereference operator (const version).

float & operator[] (size_t index) throw ()
 Array element dereference operator (non-const version).

float getX () const throw ()
 Get the x-component.

void setX (float) throw ()
 Set the x-component.

float getY () const throw ()
 Get the y-component.

void setY (float) throw ()
 Set the y-component.

ConstArrayReference get () const throw ()
 Get the value of this vector.

void set (ConstArrayReference vec) throw ()
 Set the value of this vector.

const SFVec2f add (const SFVec2f &vec) const throw ()
 Add two vectors.

const SFVec2f divide (float number) const throw ()
 Divide this vector by a scalar.

double dot (const SFVec2f &vec) const throw ()
 Dot product.

double length () const throw ()
 Geometric length.

const SFVec2f multiply (float number) const throw ()
 Multiply by a scalar.

const SFVec2f negate () const throw ()
 Negate.

const SFVec2f normalize () const throw ()
 Normalize.

const SFVec2f subtract (const SFVec2f &vec) const throw ()
 Take the difference of two vectors.

virtual std::auto_ptr< FieldValueclone () const throw (std::bad_alloc)
 Virtual copy constructor.

virtual FieldValueassign (const FieldValue &value) throw (std::bad_cast)
 Virtual assignment.

virtual Type type () const throw ()
 Get the FieldValue::Type associated with this class.


Private Methods

virtual void print (std::ostream &) const
 Print to an output stream.


Private Attributes

float value [2]

Detailed Description

Encapsulates a SFVec2f value.


Constructor & Destructor Documentation

SFVec2f   throw ()
 

Construct a SFVec2f with the default values, (0, 0).

SFVec2f ConstArrayReference    vec throw () [explicit]
 

Construct a SFVec2f.

Parameters:
vec a 2-element array.

SFVec2f float    x,
float    y
throw ()
 

Construct a SFVec2f.

Parameters:
x the x-component.
y the y-component.

~SFVec2f   throw () [virtual]
 

Destructor.


Member Function Documentation

const SFVec2f add const SFVec2f &    vec const throw ()
 

Add two vectors.

Parameters:
vec the vector to add to this one.
Returns:
a SFVec2f with a value that is the passed SFVec2f added, componentwise, to this object.

FieldValue & assign const FieldValue   value throw (std::bad_cast) [virtual]
 

Virtual assignment.

Parameters:
value the new value to give the object.
Returns:
a reference to the object.
Exceptions:
std::bad_cast if value is not an SFVec2f.

Implements FieldValue.

std::auto_ptr< FieldValue > clone   const throw (std::bad_alloc) [virtual]
 

Virtual copy constructor.

Returns:
a pointer to a copy of the object.
Exceptions:
std::bad_alloc if memory allocation fails.

Implements FieldValue.

const SFVec2f divide float    number const throw ()
 

Divide this vector by a scalar.

Parameters:
number a scalar value.
Returns:
a SFVec2f with a value that is the object divided by the passed numeric value.

double dot const SFVec2f &    vec const throw ()
 

Dot product.

Parameters:
vec a SFVec2f value.
Returns:
the dot product of this vector and vec.

SFVec2f::ConstArrayReference get   const throw ()
 

Get the value of this vector.

Returns:
a reference to a 2-element array.

float getX   const throw ()
 

Get the x-component.

Returns:
the x-component.

float getY   const throw ()
 

Get the y-component.

Returns:
the y-component.

double length   const throw ()
 

Geometric length.

Returns:
the length of this vector.

const SFVec2f multiply float    number const throw ()
 

Multiply by a scalar.

Parameters:
number a scalar value.
Returns:
a SFVec2f with a value that is the object multiplied by the passed numeric value.

const SFVec2f negate   const throw ()
 

Negate.

Returns:
a SFVec2f that the result of negating this vector.

const SFVec2f normalize   const throw ()
 

Normalize.

Returns:
a SFVec2f that is this vector normalized.

float & operator[] size_t    index throw ()
 

Array element dereference operator (non-const version).

Parameters:
index a value from 0 - 1. 0 corresponds to the x-component, and 1 corresponds to the y-component.

float operator[] size_t    index const throw ()
 

Array element dereference operator (const version).

Parameters:
index a value from 0 - 1. 0 corresponds to the x-component, and 1 corresponds to the y-component.

void print std::ostream &    out const [private, virtual]
 

Print to an output stream.

Parameters:
out an output stream.

Implements FieldValue.

void set ConstArrayReference    vec throw ()
 

Set the value of this vector.

Parameters:
vec a 2-element array.

void setX float    value throw ()
 

Set the x-component.

Parameters:
value the new x-component value.

void setY float    value throw ()
 

Set the y-component.

Parameters:
value the new y-component value.

const SFVec2f subtract const SFVec2f &    vec const throw ()
 

Take the difference of two vectors.

Parameters:
vec the vector to subtract from this one.
Returns:
a SFVec2f that is the difference between this vector and vec.

FieldValue::Type type   const throw () [virtual]
 

Get the FieldValue::Type associated with this class.

Returns:
FieldValue::sfvec2f.

Implements FieldValue.