Vertex Class Reference

#include <Vertex.hpp>

Inheritance diagram for Vertex:

Inheritance graph
[legend]
Collaboration diagram for Vertex:

Collaboration graph
[legend]

List of all members.

Public Types

enum  
typedef real_t ValueType
 The type of values stored in the TinyVector.

Public Member Functions

bool operator== (const Vertex &V) const
const Vertexoperator= (const Vertex &V)
real_t & x ()
real_t & y ()
real_t & z ()
const real_t & x () const
const real_t & y () const
const real_t & z () const
size_t & reference ()
const size_t & reference () const
 Vertex ()
 Vertex (const real_t &x, const real_t &y, const real_t &z, const size_t &reference=0)
 Vertex (const TinyVector< 3, real_t > &v, const size_t &reference=0)
 Vertex (const Vertex &v)
 ~Vertex ()
real_t distance (const TinyVector< 3, real_t > &V) const
real_t distance2 (const TinyVector< 3, real_t > &V) const
size_t size () const
real_t & operator[] (const size_t &i)
const real_t & operator[] (const size_t &i) const
TinyVector< N, real_t > operator* (const real_t &t) const
real_t operator* (const TinyVector< N, real_t > &V) const
const TinyVector< N, real_t > & operator*= (const real_t &t)
const TinyVector< N, real_t > & operator/= (const real_t &t)
TinyVector< N, real_t > operator- (const TinyVector< N, real_t > &V) const
const TinyVector< N, real_t > & operator-= (const TinyVector< N, real_t > &V)
TinyVector< N, real_t > operator^ (const TinyVector< N, real_t > &V) const
TinyVector< N, real_t > operator+ (const TinyVector< N, real_t > &V) const
TinyVector< N, real_t > & operator+= (const TinyVector< N, real_t > &V)
bool operator== (const TinyVector< N, real_t > &V) const
bool operator!= (const TinyVector< N, real_t > &V) const
bool operator< (const TinyVector< N, real_t > &V) const

Protected Attributes

real_t __x [N]
 stored data

Private Attributes

size_t __reference

Friends

std::ostream & operator<< (std::ostream &os, const Vertex &V)
TinyVector< N, real_t > operator* (const real_t &a, const TinyVector< N, real_t > &V)
TinyVector< N, real_t > sqrt (const TinyVector< N, real_t > &V)
real_t Norm (const TinyVector< N, real_t > &V)
std::ostream & operator<< (std::ostream &os, const TinyVector< N, real_t > &V)


Detailed Description

Definition at line 37 of file Vertex.hpp.


Member Typedef Documentation

typedef real_t TinyVector< N, real_t >::ValueType [inherited]

The type of values stored in the TinyVector.

Definition at line 46 of file TinyVector.hpp.


Member Enumeration Documentation

anonymous enum [inherited]

Definition at line 48 of file TinyVector.hpp.

00048        {
00049     Dimension = N               
00050   };


Constructor & Destructor Documentation

Vertex::Vertex (  )  [inline]

Default constructor. Coordinates and references are set to 0

Definition at line 164 of file Vertex.hpp.

00165     : TinyVector<3, real_t>(0,0,0),
00166       __reference(0)
00167   {
00168     ;
00169   }

Vertex::Vertex ( const real_t &  x,
const real_t &  y,
const real_t &  z,
const size_t &  reference = 0 
) [inline]

Constructor

Parameters:
x first coordinate
y second coordinate
z third coordinate
reference the reference
Note:
reference is optionnal, if omitted it is 0

Definition at line 181 of file Vertex.hpp.

00185     : TinyVector<3, real_t>(x,y,z),
00186       __reference(reference)
00187   {
00188     ;
00189   }

Vertex::Vertex ( const TinyVector< 3, real_t > &  v,
const size_t &  reference = 0 
) [inline]

Constructor

Parameters:
v coordinates
reference the reference
Note:
reference is optionnal, if omitted it is 0

Definition at line 199 of file Vertex.hpp.

00201     : TinyVector<3, real_t>(v),
00202       __reference(reference)
00203   {
00204     ;
00205   }

Vertex::Vertex ( const Vertex v  )  [inline]

Copy constructor

Parameters:
v a given vertex

Definition at line 213 of file Vertex.hpp.

00214     : TinyVector<3, real_t>(v),
00215       __reference(v.__reference)
00216   {
00217     ;
00218   }

Vertex::~Vertex (  )  [inline]

Destructor

Definition at line 224 of file Vertex.hpp.

00225   {
00226     ;
00227   }


Member Function Documentation

bool Vertex::operator== ( const Vertex V  )  const [inline]

Compares two vertices. Result is false if vertices are not the same variable in memory.

Parameters:
V the vertex to compare with
Returns:
true if the two vertices are the same

Definition at line 52 of file Vertex.hpp.

00053   {
00054     return (&V == this);
00055   }

const Vertex& Vertex::operator= ( const Vertex V  )  [inline]

Sets the vertex equal to a given one

Parameters:
V the model vertex
Returns:
the modified $ U := V $ vertex

Definition at line 64 of file Vertex.hpp.

References __reference, and TinyVector< N, T >::operator=().

00065   {
00066     TinyVector<3, real_t>::operator = (V);
00067     __reference = V.__reference;
00068     return (*this);
00069   }

Here is the call graph for this function:

real_t& Vertex::x (  )  [inline]

Access to the first coordinate of the vertex

Returns:
$f U_1 $

Definition at line 77 of file Vertex.hpp.

Referenced by Cube::__inShape(), distance(), distance2(), Triangulation::export_mesh(), operator<<(), SpectralMesh::SpectralMesh(), Structured3DMesh::Structured3DMesh(), Structured3DMesh::vertexIndex(), and SpectralMesh::vertexIndex().

00078   {
00079     return (*this)[0];
00080   }

real_t& Vertex::y (  )  [inline]

Access to the second coordinate of the vertex

Returns:
$f U_2 $

Definition at line 88 of file Vertex.hpp.

Referenced by Cube::__inShape(), distance(), distance2(), operator<<(), SpectralMesh::SpectralMesh(), Structured3DMesh::Structured3DMesh(), Structured3DMesh::vertexIndex(), and SpectralMesh::vertexIndex().

00089   {
00090     return (*this)[1];
00091   }

real_t& Vertex::z (  )  [inline]

Access to the third coordinate of the vertex

Returns:
$f U_3 $

Definition at line 100 of file Vertex.hpp.

Referenced by Cube::__inShape(), distance(), distance2(), operator<<(), SpectralMesh::SpectralMesh(), Structured3DMesh::Structured3DMesh(), Structured3DMesh::vertexIndex(), and SpectralMesh::vertexIndex().

00101   {
00102     return (*this)[2];
00103   }

const real_t& Vertex::x (  )  const [inline]

Read-only access to the first coordinate of the vertex

Returns:
$f U_1 $

Definition at line 111 of file Vertex.hpp.

00112   {
00113     return (*this)[0];
00114   }

const real_t& Vertex::y (  )  const [inline]

Read-only access to the second coordinate of the vertex

Returns:
$f U_2 $

Definition at line 122 of file Vertex.hpp.

00123   {
00124     return (*this)[1];
00125   }

const real_t& Vertex::z (  )  const [inline]

Read-only access to the third coordinate of the vertex

Returns:
$f U_3 $

Definition at line 133 of file Vertex.hpp.

00134   {
00135     return (*this)[2];
00136   }

size_t& Vertex::reference (  )  [inline]

Access to the reference of the vertex

Returns:
the reference

Definition at line 144 of file Vertex.hpp.

References __reference.

Referenced by SurfaceMeshGenerator::Internals::__createSurface(), MeshTransformer::__transformSurface(), MeshTransformer::__transformVolume(), and FunctionExpressionMeshReferences::execute().

00145   {
00146     return __reference;
00147   }

const size_t& Vertex::reference (  )  const [inline]

Read-only access to the reference of the vertex

Returns:
the reference

Definition at line 155 of file Vertex.hpp.

References __reference.

00156   {
00157     return __reference;
00158   }

real_t Vertex::distance ( const TinyVector< 3, real_t > &  V  )  const [inline]

Computes the of the distance to another point

Parameters:
V the point to compute the distance with
Returns:
$ ||U-V||^2 $

Definition at line 236 of file Vertex.hpp.

References x(), y(), and z().

00237   {
00238     return std::sqrt((V[0]-x())*(V[0]-x())
00239                      +(V[1]-y())*(V[1]-y())
00240                      +(V[2]-z())*(V[2]-z()));
00241   }

Here is the call graph for this function:

real_t Vertex::distance2 ( const TinyVector< 3, real_t > &  V  )  const [inline]

Computes the square of the distance to another point

Parameters:
V the vertex to compute the distance with
Returns:
$ ||U-V||^2 $

Definition at line 250 of file Vertex.hpp.

References x(), y(), and z().

Referenced by Sphere::__inShape().

00251   {
00252     return ((V[0]-x())*(V[0]-x())
00253             +(V[1]-y())*(V[1]-y())
00254             +(V[2]-z())*(V[2]-z()));
00255   }

Here is the call graph for this function:

size_t TinyVector< N, real_t >::size (  )  const [inline, inherited]

Read-only access to the dimension of the TinyVector.

Returns:
N

Definition at line 63 of file TinyVector.hpp.

00064   {
00065     return N;
00066   }

real_t & TinyVector< N, real_t >::operator[] ( const size_t &  i  )  [inline, inherited]

Access to the i th coordinate.

Parameters:
i the component number
Returns:
ith component

Definition at line 75 of file TinyVector.hpp.

00076   {
00077     ASSERT (i<N);
00078     return __x[i];
00079   }

const real_t & TinyVector< N, real_t >::operator[] ( const size_t &  i  )  const [inline, inherited]

Read-only access to the i th component.

Parameters:
i the component number
Returns:
ith component

Definition at line 88 of file TinyVector.hpp.

00089   {
00090     ASSERT (i<N);
00091     return __x[i];
00092   }

TinyVector<N, real_t > TinyVector< N, real_t >::operator* ( const real_t &  t  )  const [inline, inherited]

Returns multiplication by a T from the right ...

Parameters:
t the value
Returns:
$ t U $ where $ U$ is the current vector

Definition at line 129 of file TinyVector.hpp.

00130   {
00131     TinyVector<N, T> W;
00132     for (size_t i=0; i<N; i++)
00133       W.__x[i] = __x[i] * t;
00134     return W;
00135   }

real_t TinyVector< N, real_t >::operator* ( const TinyVector< N, real_t > &  V  )  const [inline, inherited]

Computes the scalar product with another vector

Parameters:
V the other vector
Returns:
$ U\cdot V$

Definition at line 144 of file TinyVector.hpp.

00145   {
00146     ASSERT(typeid(T) == typeid(real_t));
00147     real_t s=0;
00148     for (size_t i=0; i<N; i++)
00149       s += __x[i] * V.__x[i];
00150     return s;
00151   }

const TinyVector<N, real_t >& TinyVector< N, real_t >::operator*= ( const real_t &  t  )  [inline, inherited]

Multiplies the TinyVector by a T

Parameters:
t the given value
Returns:
$ U := t U$

Definition at line 160 of file TinyVector.hpp.

00161   {
00162     for (size_t i=0; i<N; i++)
00163       __x[i] *= t;
00164     return (*this);
00165   }

const TinyVector<N, real_t >& TinyVector< N, real_t >::operator/= ( const real_t &  t  )  [inline, inherited]

Multiplies the TinyVector by the inverse of a T

Parameters:
t the given value
Returns:
$ U := t^{-1} U$

Definition at line 174 of file TinyVector.hpp.

00175   {
00176     const T temp = 1./t;
00177     this->operator*=(temp);
00178     return (*this);
00179   }

TinyVector<N, real_t > TinyVector< N, real_t >::operator- ( const TinyVector< N, real_t > &  V  )  const [inline, inherited]

Computes the difference with an other vector

Parameters:
V the other vector
Returns:
$ U - V $

Definition at line 188 of file TinyVector.hpp.

00189   {
00190     TinyVector<N, T> v = 0;
00191     for (size_t i=0; i<N; i++)
00192       v[i] = __x[i] - V.__x[i];
00193     return v;
00194   }

const TinyVector<N, real_t >& TinyVector< N, real_t >::operator-= ( const TinyVector< N, real_t > &  V  )  [inline, inherited]

Substracts a vector.

Parameters:
V the vector to remove
Returns:
$ U := U - V$

Definition at line 203 of file TinyVector.hpp.

00204   {
00205     for (size_t i=0; i<N; i++)
00206       __x[i] -= V.__x[i];
00207     return (*this);
00208   }

TinyVector<N, real_t > TinyVector< N, real_t >::operator^ ( const TinyVector< N, real_t > &  V  )  const [inline, inherited]

Computes the vectorial product with a vector

Parameters:
V the given vector
Returns:
$ U \land V $

Definition at line 217 of file TinyVector.hpp.

00218   {
00219     TinyVector<N, T> W=0;
00220     for (size_t i=0; i<N; i++)
00221       W[i] += __x[(i+1)%N] * V.__x[(i+2)%N] - __x[(i+2)%N] * V.__x[(i+1)%N];
00222     return W;
00223   }

TinyVector<N, real_t > TinyVector< N, real_t >::operator+ ( const TinyVector< N, real_t > &  V  )  const [inline, inherited]

Computes the sum with another vector

Parameters:
V the other vector
Returns:
$ U+V $

Definition at line 232 of file TinyVector.hpp.

00233   {
00234     TinyVector<N, T> W(*this);
00235     for (size_t i=0; i<N; i++)
00236       W.__x[i] += V.__x[i];
00237     return W;
00238   }

TinyVector<N, real_t >& TinyVector< N, real_t >::operator+= ( const TinyVector< N, real_t > &  V  )  [inline, inherited]

Adds a vector

Parameters:
V the vector to add
Returns:
$ U := U+V$

Definition at line 247 of file TinyVector.hpp.

00247                                                                    {
00248     for (size_t i=0; i<N; i++)
00249       __x[i] += V.__x[i];
00250     return (*this);
00251   }

bool TinyVector< N, real_t >::operator== ( const TinyVector< N, real_t > &  V  )  const [inline, inherited]

Compares two vectors

Parameters:
V the vector to compare with
Returns:
true if vector matches
Note:
Use this function only for special purpose when vectors can really match (not if results of numerical computations).

Definition at line 263 of file TinyVector.hpp.

00264   {
00265     for (size_t i=0; i<N; i++) {
00266       if (__x[i] != V.__x[i]) {
00267         return false;
00268       }
00269     }
00270     return true;
00271   }

bool TinyVector< N, real_t >::operator!= ( const TinyVector< N, real_t > &  V  )  const [inline, inherited]

Compares 2 vectors. true if they are not exactly the same

Parameters:
V the vector to compare with
Returns:
true if vector do not match

Definition at line 280 of file TinyVector.hpp.

00281   {
00282     for (size_t i=0; i<N; i++) {
00283       if (__x[i] != V.__x[i]) {
00284         return true;
00285       }
00286     }
00287     return false;
00288   }

bool TinyVector< N, real_t >::operator< ( const TinyVector< N, real_t > &  V  )  const [inline, inherited]

Compares two vectors

Parameters:
V the vector to compare with
Returns:
true is the vector is smaller than the given one
Note:
this function uses an arbitrary order

Definition at line 299 of file TinyVector.hpp.

00300   {
00301     for (size_t i=0; i<N; ++i) {
00302       if(__x[i] != V.__x[i]) {
00303         return (__x[i] < V.__x[i]);
00304       }
00305     }
00306     return false;
00307   }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Vertex V 
) [friend]

Prints a given vertex to a stream

Parameters:
os the given stream
V the vertex
Returns:
the modified stream

Definition at line 30 of file Vertex.cpp.

00032 {
00033   os << '<' << V.x() << ", " << V.y() << ", " << V.z() << '>';
00034   return os;
00035 }

TinyVector<N, real_t > operator* ( const real_t &  a,
const TinyVector< N, real_t > &  V 
) [friend, inherited]

Returns the multiplication of a TinyVector by a T on the left.

Parameters:
a the multiplicative constant
V the vector to multiply
Returns:
$ a V $

Definition at line 352 of file TinyVector.hpp.

00353   {
00354     return (V*a);
00355   }

TinyVector<N, real_t > sqrt ( const TinyVector< N, real_t > &  V  )  [friend, inherited]

Returns the square root of a vector. (ie: it returns the vector whoose componnents are square roots of arg)

Parameters:
V the given vector
Returns:
$ \left( V_0^{\frac{1}{2}}, \ldots , V_N^{\frac{1}{2}} \right) $

Definition at line 317 of file TinyVector.hpp.

00318   {
00319     using namespace std;
00320     TinyVector<N, T> W;
00321     for (size_t i=0; i<N; i++)
00322       W.__x[i] = sqrt(V.__x[i]);
00323     return W;
00324   }

real_t Norm ( const TinyVector< N, real_t > &  V  )  [friend, inherited]

Returns the Euclidean norm of the vector.

Parameters:
V the vector which norm is to compute
Returns:
$ ||V||_2 $

Definition at line 333 of file TinyVector.hpp.

00334   {
00335     T t = 0;
00336     for (size_t i=0; i<N; i++) {
00337       t += V.__x[i]*V.__x[i];
00338     }
00339 
00340     using namespace std;
00341     return sqrt(t);
00342   }

std::ostream& operator<< ( std::ostream &  os,
const TinyVector< N, real_t > &  V 
) [friend, inherited]

Prints out the transposed of a vector in a stream

Parameters:
os the given stream
V the vector
Returns:
the modified stream

Definition at line 365 of file TinyVector.hpp.

00367   {
00368     ASSERT (N>0);
00369     os << '(';
00370     for (size_t i=0; i<N-1; i++)
00371       os << V[i] << ", ";
00372     os << V[N-1] << ')';
00373     return os;
00374   }


Member Data Documentation

size_t Vertex::__reference [private]

The reference of the vertex

Definition at line 41 of file Vertex.hpp.

Referenced by operator=(), and reference().

real_t TinyVector< N, real_t >::__x[N] [protected, inherited]

stored data

Definition at line 54 of file TinyVector.hpp.


The documentation for this class was generated from the following file:

Generated on Wed Nov 19 00:18:03 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6