Frz::vertex Struct Reference

A 3D vertex. More...

#include <frz_vertex.hpp>

Inheritance diagram for Frz::vertex:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 vertex (float _x=0.f, float _y=0.f, float _z=0.f, float _t=1.0f)
 Default constructor.
 vertex (const vertex &v)
 Copy constructor.
 vertex (uint32_t _a, uint32_t _b, uint32_t _c, uint32_t _s)
 Integer constructor.
 vertex (vector float v)
 Altivec vector conversion constructor.
void set (vector float v)
 Sets a vertex value from an Altivec vector.
vertex operator- (const vertex &a) const
 vertex subtraction operator.
vertex operator+ (const vertex &a) const
 vertex addition operator.
vertex operator* (const vertex &b) const
 vertex cross product operator.
vertex operator* (float f) const
 Scale all coefficients with a scalar value.
void normalize (void)
 Normalizes the vertex.
float norm2 (void)
 Computes the square norm of the vertex.
float norm (void)
 Computes the norm of the vertex.
void update_norm (const vertex &a, const vertex &b, const vertex &c)
 Updates the normal vector in vertex b of triangle (a,b, c).
vector float v () const
 Converts the vertex to an Altivec vector.

Public Attributes

union {
   float   x
 First vertex coordinate in floating point format.
   uint32_t   a
 First vertex coordinate in 32-bit integer format.
}; 
union {
   float   y
 Second vertex coordinate in floating point format.
   uint32_t   b
 Second vertex coordinate in 32-bit integer format.
}; 
union {
   float   z
 Third vertex coordinate in floating point format.
   uint32_t   c
 Third vertex coordinate in 32-bit integer format.
}; 
union {
   float   t
 Fourth vertex coordinate in floating point format.
   uint32_t   s
 Fourth vertex coordinate in 32-bit integer format.
}; 

Friends

std::ostream & operator<< (std::ostream &os, const vertex &v)
 Outputs the vertex in human-readable fashion.

Detailed Description

A 3D vertex.

This class generally is used for storing a set of 3D coordinates, but also may embed extra data. Its main purpose is to be packed into Scene::Triangle objects, for communication with the SPE's. In this case, a vertex will be loaded into a 16-byte vector on SPU side.

The fourth vertex element is generally ignored by the arithmetics and normalization methods. It is used for storage and 16-byte alignment only.


Constructor & Destructor Documentation

Frz::vertex::vertex ( float  _x = 0.f,
float  _y = 0.f,
float  _z = 0.f,
float  _t = 1.0f 
) [inline]

Default constructor.

Parameters:
_x the first vertex coordinate
_y the second vertex coordinate
_z the third vertex coordinate
_t the fourth vertex coordinate
Frz::vertex::vertex ( const vertex v  )  [inline]

Copy constructor.

Parameters:
v the vertex to be copied
Frz::vertex::vertex ( uint32_t  _a,
uint32_t  _b,
uint32_t  _c,
uint32_t  _s 
) [inline]

Integer constructor.

Parameters:
_a the first vertex coordinate
_b the second vertex coordinate
_c the third vertex coordinate
_s the fourth vertex coordinate
Frz::vertex::vertex ( vector float  v  )  [inline]

Altivec vector conversion constructor.

Parameters:
v the Altivec vector variable to be converted

Member Function Documentation

float Frz::vertex::norm ( void   ) 

Computes the norm of the vertex.

Returns:
the vertex's norm
float Frz::vertex::norm2 ( void   ) 

Computes the square norm of the vertex.

Returns:
the square of the vertex's norm
void Frz::vertex::normalize ( void   ) 

Normalizes the vertex.

All terms of the vertex are divided by the vertex's norm.

vertex Frz::vertex::operator* ( float  f  )  const [inline]

Scale all coefficients with a scalar value.

Parameters:
f the scalar value to be multiplied with all the vertex coordinates
Returns:
the result of the operation
vertex Frz::vertex::operator* ( const vertex b  )  const [inline]

vertex cross product operator.

Parameters:
b the vertex to be the right hand operand to the cross product
Returns:
the result of the operation
vertex Frz::vertex::operator+ ( const vertex a  )  const [inline]

vertex addition operator.

Parameters:
a the vertex to be added to this
Returns:
the result of the operation
vertex Frz::vertex::operator- ( const vertex a  )  const [inline]

vertex subtraction operator.

Parameters:
a the vertex to be subtracted to this
Returns:
the result of the operation
void Frz::vertex::set ( vector float  v  )  [inline]

Sets a vertex value from an Altivec vector.

Parameters:
v the Altivec vector
void Frz::vertex::update_norm ( const vertex a,
const vertex b,
const vertex c 
)

Updates the normal vector in vertex b of triangle (a,b, c).

This corresponds to adding the normalized ab * bc cross product, multiplied by the angle in b

vector float Frz::vertex::v (  )  const [inline]

Converts the vertex to an Altivec vector.

Returns:
the converted Altivec vector

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const vertex v 
) [friend]

Outputs the vertex in human-readable fashion.

Parameters:
os the output stream
v the vertex to be displayed
Returns:
the output stream

The documentation for this struct was generated from the following file:
 All Classes Functions Variables Friends
Generated on Thu Jun 10 17:37:47 2010 for freezer-0.1.0 by  doxygen 1.6.3