Follow this link to skip to the main content

claraty::Unit_Vector< T > Class Template Reference

#include <unit_vector.h>

Collaboration diagram for claraty::Unit_Vector< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Unit_Vector ()
 Unit_Vector (const Vector< T > &vals)
 Unit_Vector (const T val0, const T val1, const T val2)
 operator Vector () const
 operator Point () const
const T & operator[] (int n) const
x () const
y () const
z () const
Unit_Vector< T > & set (const Vector< T > &vals)
Unit_Vector< T > & set (const T &val0, const T &val1, const T &val2)
Unit_Vector< T > & operator= (const Unit_Vector< T > &rhs)
Vector< T > operator+ (const Unit_Vector< T > &rhs) const
Vector< T > operator- (const Unit_Vector< T > &rhs) const
Vector< T > cross (const Unit_Vector< T > &rhs) const
operator * (const Unit_Vector< T > &rhs) const
bool io (FDM_Array a)

Private Attributes

data [3]

Detailed Description

template<class T>
class claraty::Unit_Vector< T >

Definition at line 48 of file unit_vector.h.


Constructor & Destructor Documentation

template<class T>
claraty::Unit_Vector< T >::Unit_Vector (  )  [inline]

Definition at line 55 of file unit_vector.h.

References claraty::Unit_Vector< T >::data.

00055                 { 
00056     data[0] = 1.0;
00057     data[1] = 0.0;
00058     data[2] = 0.0;
00059   }

template<class T>
claraty::Unit_Vector< T >::Unit_Vector ( const Vector< T > &  vals  )  [inline]

Definition at line 61 of file unit_vector.h.

References claraty::Unit_Vector< T >::set().

00061                                      {
00062     set(vals);
00063   }

Here is the call graph for this function:

template<class T>
claraty::Unit_Vector< T >::Unit_Vector ( const T  val0,
const T  val1,
const T  val2 
) [inline]

Definition at line 65 of file unit_vector.h.

References claraty::Unit_Vector< T >::set().

00065                                                         {
00066     set(val0, val1, val2);
00067   }

Here is the call graph for this function:


Member Function Documentation

template<class T>
claraty::Unit_Vector< T >::operator Vector (  )  const [inline]

Definition at line 69 of file unit_vector.h.

References claraty::Unit_Vector< T >::data.

00069                              {
00070     return Vector<T>(3, data);
00071   }

template<class T>
claraty::Unit_Vector< T >::operator Point (  )  const [inline]

Definition at line 73 of file unit_vector.h.

References claraty::Unit_Vector< T >::data.

00073                             {
00074     return Point<T>(data[0], data[1], data[2]);
00075   }

template<class T>
const T& claraty::Unit_Vector< T >::operator[] ( int  n  )  const [inline]

Definition at line 77 of file unit_vector.h.

References claraty::Unit_Vector< T >::data.

00077 { return data[n]; }

template<class T>
T claraty::Unit_Vector< T >::x (  )  const [inline]

Definition at line 79 of file unit_vector.h.

References claraty::Unit_Vector< T >::data.

Referenced by claraty::io_object().

00079 { return data[0]; }

template<class T>
T claraty::Unit_Vector< T >::y (  )  const [inline]

Definition at line 80 of file unit_vector.h.

References claraty::Unit_Vector< T >::data.

Referenced by claraty::io_object().

00080 { return data[1]; }

template<class T>
T claraty::Unit_Vector< T >::z (  )  const [inline]

Definition at line 81 of file unit_vector.h.

References claraty::Unit_Vector< T >::data.

Referenced by claraty::io_object().

00081 { return data[2]; }

template<class T>
Unit_Vector<T>& claraty::Unit_Vector< T >::set ( const Vector< T > &  vals  )  [inline]

Definition at line 83 of file unit_vector.h.

References claraty::Unit_Vector< T >::data, and claraty::Vector< T >::get_num_of_cols().

Referenced by claraty::io_object(), and claraty::Unit_Vector< T >::Unit_Vector().

00083                                              {
00084     assert(vals.get_num_of_cols() == 3);
00085     T magnitude = vals(0)*vals(0) + vals(1)*vals(1) + vals(2)*vals(2);
00086     magnitude = sqrt(magnitude);
00087     data[0] = vals(0) / magnitude;
00088     data[1] = vals(1) / magnitude;
00089     data[2] = vals(2) / magnitude;
00090     return *this;
00091   }

Here is the call graph for this function:

template<class T>
Unit_Vector<T>& claraty::Unit_Vector< T >::set ( const T &  val0,
const T &  val1,
const T &  val2 
) [inline]

Definition at line 93 of file unit_vector.h.

References claraty::Unit_Vector< T >::data.

00093                                                                    {
00094     T magnitude = val0 * val0 + val1 * val1 + val2 * val2;
00095     magnitude = sqrt(magnitude);
00096     data[0] = val0 / magnitude;
00097     data[1] = val1 / magnitude;
00098     data[2] = val2 / magnitude;
00099     return *this;
00100   }

template<class T>
Unit_Vector<T>& claraty::Unit_Vector< T >::operator= ( const Unit_Vector< T > &  rhs  )  [inline]

Definition at line 103 of file unit_vector.h.

References claraty::Unit_Vector< T >::data.

00103                                                        {
00104     data[0] = rhs.data[0];
00105     data[1] = rhs.data[1];
00106     data[2] = rhs.data[2];
00107     return *this;
00108   }

template<class T>
Vector<T> claraty::Unit_Vector< T >::operator+ ( const Unit_Vector< T > &  rhs  )  const [inline]

Definition at line 113 of file unit_vector.h.

References claraty::Unit_Vector< T >::data.

00113                                                        {
00114     Vector<T> result(3);
00115     result(0) = data[0] + rhs.data[0];
00116     result(1) = data[1] + rhs.data[1];
00117     result(2) = data[2] + rhs.data[2];
00118     return result;
00119   }

template<class T>
Vector<T> claraty::Unit_Vector< T >::operator- ( const Unit_Vector< T > &  rhs  )  const [inline]

Definition at line 122 of file unit_vector.h.

References claraty::Unit_Vector< T >::data.

00122                                                        {
00123     Vector<T> result(3);
00124     result(0) = data[0] - rhs.data[0];
00125     result(1) = data[1] - rhs.data[1];
00126     result(2) = data[2] - rhs.data[2];
00127     return result;
00128   }

template<class T>
Vector<T> claraty::Unit_Vector< T >::cross ( const Unit_Vector< T > &  rhs  )  const [inline]

Definition at line 131 of file unit_vector.h.

References claraty::Unit_Vector< T >::data.

00131                                                    {
00132     Vector<T> v(3);
00133     // Cross product is the determinant of
00134     //  [   i      j      k    ]
00135     //  [ lhs[0] lhs[1] lhs[2] ]
00136     //  [ rhs[0] rhs[1] rhs[2] ]
00137     v(0) = data[1]*rhs[2] - data[2]*rhs[1];
00138     v(1) = data[2]*rhs[0] - data[0]*rhs[2];
00139     v(2) = data[0]*rhs[1] - data[1]*rhs[0];
00140     return v;
00141   }

template<class T>
T claraty::Unit_Vector< T >::operator * ( const Unit_Vector< T > &  rhs  )  const [inline]

Definition at line 144 of file unit_vector.h.

References claraty::Unit_Vector< T >::data.

00144                                                {
00145     return data[0]*rhs[0] + data[1]*rhs[1] + data[2]*rhs[2];
00146   }

template<class T>
bool claraty::Unit_Vector< T >::io ( FDM_Array  a  )  [inline]

Definition at line 148 of file unit_vector.h.

References claraty::Unit_Vector< T >::data, and claraty::FDM_Array::element().

00148                        {
00149     bool ok= a.element(data[0]);
00150     ok &= a.element(data[1]);
00151     ok &= a.element(data[2]);
00152     return ok;
00153   }

Here is the call graph for this function:


Member Data Documentation


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