Follow this link to skip to the main content

claraty::Trans< T, Rotation_Type > Class Template Reference

#include <trans.h>

Inheritance diagram for claraty::Trans< T, Rotation_Type >:

Inheritance graph
[legend]
Collaboration diagram for claraty::Trans< T, Rotation_Type >:

Collaboration graph
[legend]
List of all members.

Mutators

static const Base_Trans< T,
Rotation_Type > 
identity
void set_x (T x)
void set_y (T y)
void set_z (T z)
void set_xy (T x, T y)
void set_xyz (T x, T y, T z)
void set_translation (const Point< T > &p)
void set_rotation (const RMatrix< T > &r)
void set_rotation (const Quaternion< T > &r)
bool io (FDM_Map map)

Public Member Functions

Operators
 operator Point () const
 operator Rotation_Type () const
Point< T > operator * (const Point< T > &rhs) const
Trans operator * (const Trans &t) const
Trans rotate_x (T angle) const
Trans rotate_y (T angle) const
Trans rotate_z (T angle) const
Trans rotate (T rx, T ry, T rz) const
Trans rotate (const Rotation_Type &r) const
Trans translate_x (T x) const
Trans translate_y (T y) const
Trans translate_z (T z) const
Trans translate (T x, T y=T(), T z=T()) const
Trans translate (const Point< T > &p) const
Trans transform (const Trans &t)
void set_identity ()
Observers
get_x () const
get_y () const
get_z () const
void get_xyz (T &x, T &y, T &z) const
Rotation_Type get_rotation () const
const Point< T > & get_translation () const
distance_from (const Trans &h) const
Trans relative_to (const Trans &h) const

Public Attributes

Point< T > _p
Rotation_Type _r

Friends

template<class T1, class Rotation_Type1>
Trans< T1, Rotation_Type1 > inverse (const Trans< T1, Rotation_Type1 > &q)
template<class T2, class Rotation_Type2>
std::ostream & operator<< (std::ostream &os, const Trans< T2, Rotation_Type2 > &tt)

Detailed Description

template<class T, class Rotation_Type>
class claraty::Trans< T, Rotation_Type >

Definition at line 67 of file trans.h.


Constructor & Destructor Documentation

template<class T, class Rotation_Type>
claraty::Trans< T, Rotation_Type >::Trans ( const Base_Trans< T, Rotation_Type > &  t  )  [inline]

Definition at line 80 of file trans.h.

00081     : Base_Trans<T, Rotation_Type>(t) {}

template<class T, class Rotation_Type>
claraty::Trans< T, Rotation_Type >::Trans ( const Point< T > &  p,
const Rotation_Type &  r 
) [inline]

Definition at line 83 of file trans.h.

00084     : Base_Trans<T, Rotation_Type>(p, r) {}

template<class T, class Rotation_Type>
claraty::Trans< T, Rotation_Type >::Trans ( const Rotation_Type &  r  )  [inline]

Definition at line 86 of file trans.h.

00087     : Base_Trans<T, Rotation_Type>(r) {}

template<class T, class Rotation_Type>
claraty::Trans< T, Rotation_Type >::Trans ( const Point< T > &  p  )  [inline, explicit]

Definition at line 89 of file trans.h.

00090     : Base_Trans<T, Rotation_Type>(p) {}

template<class T, class Rotation_Type>
claraty::Trans< T, Rotation_Type >::Trans (  )  [inline]

Definition at line 92 of file trans.h.

00092 : Base_Trans<T,Rotation_Type>(identity) {}

template<class T, class Rotation_Type>
claraty::Trans< T, Rotation_Type >::Trans ( const Base_Trans< T, Rotation_Type > &  t  )  [inline]

Definition at line 80 of file trans.h.

00081     : Base_Trans<T, Rotation_Type>(t) {}

template<class T, class Rotation_Type>
claraty::Trans< T, Rotation_Type >::Trans ( const Point< T > &  p,
const Rotation_Type &  r 
) [inline]

Definition at line 83 of file trans.h.

00084     : Base_Trans<T, Rotation_Type>(p, r) {}

template<class T, class Rotation_Type>
claraty::Trans< T, Rotation_Type >::Trans ( const Rotation_Type &  r  )  [inline]

Definition at line 86 of file trans.h.

00087     : Base_Trans<T, Rotation_Type>(r) {}

template<class T, class Rotation_Type>
claraty::Trans< T, Rotation_Type >::Trans ( const Point< T > &  p  )  [inline, explicit]

Definition at line 89 of file trans.h.

00090     : Base_Trans<T, Rotation_Type>(p) {}

template<class T, class Rotation_Type>
claraty::Trans< T, Rotation_Type >::Trans (  )  [inline]

Definition at line 92 of file trans.h.

00092 : Base_Trans<T,Rotation_Type>(identity) {}


Member Function Documentation

template<class T, class Rotation_Type>
claraty::Trans< T, Rotation_Type >::operator Point (  )  const [inline]

Definition at line 96 of file trans.h.

00096 { return get_translation(); }

template<class T, class Rotation_Type>
claraty::Trans< T, Rotation_Type >::operator Rotation_Type (  )  const [inline]

Definition at line 97 of file trans.h.

References claraty::Trans< T, Rotation_Type >::get_rotation().

00097 { return get_rotation(); }

Here is the call graph for this function:

template<class T, class Rotation_Type>
Point< T > claraty::Trans< T, Rotation_Type >::operator * ( const Point< T > &  rhs  )  const [inline]

Operator to multiply a Trans and a Point

Parameters:
[in] rhs Point to be multiplied
Returns:
Point resulting from operation

Reimplemented in claraty::HTrans< T >, and claraty::QTrans< T >.

Definition at line 253 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p, and claraty::Base_Trans< T, Rotation_Type >::_r.

00254 {
00255   Point<T> result;
00256   result  = this->_r * rhs;
00257   result += this->_p;
00258   return result;
00259 }

template<class T, class Rotation_Type>
Trans< T, Rotation_Type > claraty::Trans< T, Rotation_Type >::operator * ( const Trans< T, Rotation_Type > &  t  )  const [inline]

Operator to multiply a Trans and another Trans

Parameters:
[in] t Trans to be multiplied
Returns:
Trans resulting from the operation

Definition at line 271 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p, and claraty::Base_Trans< T, Rotation_Type >::_r.

00273 {
00274   Trans<T, Rotation_Type> result;
00275   result._r  = this->_r * t._r;
00276   result._p  = this->_r * t._p;
00277   result._p += this->_p;          
00278   return result;
00279 }

template<class T, class Rotation_Type>
Trans< T, Rotation_Type > claraty::Trans< T, Rotation_Type >::rotate_x ( angle  )  const [inline]

Operator to rotate the Trans by the specified angle about the X-axis

Parameters:
[in] angle Angle to rotate by
Returns:
Trans resulting from the rotation

Definition at line 291 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p, claraty::Base_Trans< T, Rotation_Type >::_r, and claraty::RX.

Referenced by claraty::Transform_IO::_extract_rot_x_attributes().

00292 {
00293   Rotation_Type r = this->_r * Rotation_Type(RX, angle);
00294   return Trans<T, Rotation_Type>(this->_p, r);
00295 }

template<class T, class Rotation_Type>
Trans< T, Rotation_Type > claraty::Trans< T, Rotation_Type >::rotate_y ( angle  )  const [inline]

Operator to rotate the Trans by the specified angle about the Y-axis

Parameters:
[in] angle Angle to rotate by
Returns:
Trans resulting from the rotation

Definition at line 307 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p, claraty::Base_Trans< T, Rotation_Type >::_r, and claraty::RY.

Referenced by claraty::Transform_IO::_extract_rot_y_attributes().

00308 {
00309   Rotation_Type r = this->_r * Rotation_Type(RY, angle);
00310   return Trans<T, Rotation_Type>(this->_p, r);
00311 }

template<class T, class Rotation_Type>
Trans< T, Rotation_Type > claraty::Trans< T, Rotation_Type >::rotate_z ( angle  )  const [inline]

Operator to rotate the Trans by the specified angle about the Z-axis

Parameters:
[in] angle Angle to rotate by
Returns:
Trans resulting from the rotation

Definition at line 323 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p, claraty::Base_Trans< T, Rotation_Type >::_r, and claraty::RZ.

Referenced by claraty::Transform_IO::_extract_rot_z_attributes(), and claraty::ME_Joint::get_transform().

00324 {
00325   Rotation_Type r = this->_r * Rotation_Type(RZ, angle);
00326   return Trans<T, Rotation_Type>(this->_p, r);
00327 }

template<class T, class Rotation_Type>
Trans< T, Rotation_Type > claraty::Trans< T, Rotation_Type >::rotate ( rx,
ry,
rz 
) const [inline]

Operator to rotate the Trans by the specified RPY angles

Parameters:
[in] rx Roll angle to rotate by
[in] ry Pitch angle to rotate by
[in] rz Yaw angle to rotate by
Returns:
Trans resulting from the rotation

Definition at line 341 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p, claraty::Base_Trans< T, Rotation_Type >::_r, and claraty::RPY.

Referenced by claraty::Transform_IO::_extract_three_angle_set_attributes().

00343 {
00344   Rotation_Type r = this->_r * Rotation_Type(RPY, rx, ry, rz);
00345   return Trans<T, Rotation_Type>(this->_p, r);
00346 }

template<class T, class Rotation_Type>
Trans< T, Rotation_Type > claraty::Trans< T, Rotation_Type >::rotate ( const Rotation_Type &  r  )  const [inline]

Operator to rotate the Trans by the rotation specified in the Rotation_Type

Parameters:
[in] r Rotation_Type to rotate by
Returns:
Trans resulting from the rotation

Definition at line 359 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p, and claraty::Base_Trans< T, Rotation_Type >::_r.

00361 {
00362   Rotation_Type rOut = this->_r * r;
00363   return Trans<T, Rotation_Type>(this->_p, rOut);
00364 }

template<class T, class Rotation_Type>
Trans< T, Rotation_Type > claraty::Trans< T, Rotation_Type >::translate_x ( x  )  const [inline]

Operator to translate by the specified distance along the X-axis

Parameters:
[in] x Distance to translate
Returns:
Trans resulting from the translation

Definition at line 376 of file trans.h.

References claraty::Trans< T, Rotation_Type >::translate().

00377 {
00378   return translate(Point<T>(x, 0.0, 0.0));
00379 }

Here is the call graph for this function:

template<class T, class Rotation_Type>
Trans< T, Rotation_Type > claraty::Trans< T, Rotation_Type >::translate_y ( y  )  const [inline]

Operator to translate by the specified distance along the Y-axis

Parameters:
[in] y Distance to translate
Returns:
Trans resulting from the translation

Definition at line 391 of file trans.h.

References claraty::Trans< T, Rotation_Type >::translate().

00392 {
00393   return translate(Point<T>(0.0, y, 0.0));
00394 }

Here is the call graph for this function:

template<class T, class Rotation_Type>
Trans< T, Rotation_Type > claraty::Trans< T, Rotation_Type >::translate_z ( z  )  const [inline]

Operator to translate by the specified distance along the Z-axis

Parameters:
[in] z Distance to translate
Returns:
Trans resulting from the translation

Definition at line 406 of file trans.h.

References claraty::Trans< T, Rotation_Type >::translate().

Referenced by claraty::Wheel_Model::get_ground_contact(), and claraty::ME_Joint::get_transform().

00407 {
00408   return translate(Point<T>(0.0, 0.0, z));
00409 }

Here is the call graph for this function:

template<class T, class Rotation_Type>
Trans< T, Rotation_Type > claraty::Trans< T, Rotation_Type >::translate ( x,
y = T(),
z = T() 
) const [inline]

Operator to translate by the specified distance along the X, Y, Z axes respectively.

Parameters:
[in] x Distance to translate along the X-axis
[in] y Distance to translate along the Y-axis
[in] z Distance to translate along the Z-axis
Returns:
Trans resulting from the translation

Definition at line 425 of file trans.h.

Referenced by claraty::Trans< T, Rotation_Type >::translate_x(), claraty::Trans< T, Rotation_Type >::translate_y(), and claraty::Trans< T, Rotation_Type >::translate_z().

00427 {
00428   return translate(Point<T>(x, y, z));
00429 }

template<class T, class Rotation_Type>
Trans< T, Rotation_Type > claraty::Trans< T, Rotation_Type >::translate ( const Point< T > &  p  )  const [inline]

Operator to translate by the distance specified in the Point

Parameters:
[in] p Point to translate
Returns:
Trans resulting from the translation

Definition at line 442 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p, and claraty::Base_Trans< T, Rotation_Type >::_r.

00443 {
00444   Trans<T, Rotation_Type> result(*this);
00445   result._p =  this->_r*p + this->_p;
00446   return result;
00447 }

template<class T, class Rotation_Type>
Trans< T, Rotation_Type > claraty::Trans< T, Rotation_Type >::transform ( const Trans< T, Rotation_Type > &  t  ) 

Transform the current transform by the arg. transform

Parameters:
[in] t Trans to use for transform
Returns:
Trans identity

Definition at line 741 of file trans.h.

00742 {
00743   return *this * t;
00744 }

template<class T, class Rotation_Type>
void claraty::Trans< T, Rotation_Type >::set_identity (  ) 

Convert this Trans to identity

Returns:
Trans identity

Definition at line 726 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p, and claraty::Base_Trans< T, Rotation_Type >::_r.

Referenced by claraty::ME_Body_IO::extract_from_parse_tree().

00727 {
00728   this->_p(0) = 0.0; this->_p(1) = 0.0; this->_p(2) = 0.0;
00729   this->_r.set_identity();
00730 }

template<class T, class Rotation_Type>
T claraty::Trans< T, Rotation_Type >::get_x (  )  const [inline]

Get the translation component along the X-axis

Returns:
Distance along the specified axis

Definition at line 458 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p.

00459 {
00460   return this->_p(0);
00461 }

template<class T, class Rotation_Type>
T claraty::Trans< T, Rotation_Type >::get_y (  )  const [inline]

Get the translation component along the Y-axis

Returns:
Distance along the specified axis

Definition at line 471 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p.

00472 {
00473   return this->_p(1);
00474 }

template<class T, class Rotation_Type>
T claraty::Trans< T, Rotation_Type >::get_z (  )  const [inline]

Get the translation component along the Z-axis

Returns:
Distance along the specified axis

Definition at line 486 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p.

00487 {
00488   return this->_p(2);
00489 }

template<class T, class Rotation_Type>
void claraty::Trans< T, Rotation_Type >::get_xyz ( T &  x,
T &  y,
T &  z 
) const [inline]

Get the translation components along the X,Y,Z-axes

Parameters:
[out] x Value of the translation along the X-axis
[out] y Value of the translation along the Y-axis
[out] z Value of the translation along the Z-axis

Definition at line 504 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p.

00505 {
00506   x = this->_p(0);
00507   y = this->_p(1);
00508   z = this->_p(2);
00509 }

template<class T, class Rotation_Type>
Rotation_Type claraty::Trans< T, Rotation_Type >::get_rotation (  )  const [inline]

template<class T, class Rotation_Type>
const Point< T > & claraty::Trans< T, Rotation_Type >::get_translation (  )  const [inline]

Get the translation component

Returns:
Point containing the translation

Definition at line 538 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p.

Referenced by claraty::N_2DOF_Planar_Arm::initialize(), and claraty::Trans< T, claraty::RMatrix< T > >::operator Point().

00539 {
00540   return this->_p;
00541 }

template<class T, class Rotation_Type>
T claraty::Trans< T, Rotation_Type >::distance_from ( const Trans< T, Rotation_Type > &  h  )  const [inline]

Return the T distance of this QTrans from the specified QTrans

Parameters:
[in] h Trans to be measured from
Returns:
Distance

Definition at line 696 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p.

Referenced by claraty::N_2DOF_Planar_Arm::initialize().

00697 {
00698   return this->_p.distance_from(h._p);
00699 }

template<class T, class Rotation_Type>
Trans< T, Rotation_Type > claraty::Trans< T, Rotation_Type >::relative_to ( const Trans< T, Rotation_Type > &  q  )  const [inline]

Return the Trans that specifies the relative position & orientation of this Trans from the specified QTrans.

Definition at line 710 of file trans.h.

References claraty::Trans< T, Rotation_Type >::inverse.

Referenced by claraty::Frame::get_relative_transform().

00712 {
00713   return inverse(q) * (*this);
00714 }

template<class T, class Rotation_Type>
void claraty::Trans< T, Rotation_Type >::set_x ( x  )  [inline]

Set the X-axis component of the translation

Parameters:
[in] x X-Axis value to set to

Definition at line 569 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p.

Referenced by claraty::Wheel_Locomotor_Model::convert_length_heading_direction_to_location().

00570 {
00571   this->_p(0) = x;
00572 }

template<class T, class Rotation_Type>
void claraty::Trans< T, Rotation_Type >::set_y ( y  )  [inline]

Set the Y-axis component of the translation

Parameters:
[in] y Y-axis value to set to

Definition at line 584 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p.

Referenced by claraty::Wheel_Locomotor_Model::convert_length_heading_direction_to_location().

00585 {
00586   this->_p(1) = y;
00587 }

template<class T, class Rotation_Type>
void claraty::Trans< T, Rotation_Type >::set_z ( z  )  [inline]

Set the Z-axis component of the translation

Parameters:
[in] z Z-axis component to set to

Definition at line 599 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p.

00600 {
00601   this->_p(2) = z;
00602 }

template<class T, class Rotation_Type>
void claraty::Trans< T, Rotation_Type >::set_xy ( x,
y 
) [inline]

Set the X,Y-axis component of the translation

Parameters:
[in] x X-axis value to set to
[in] y Y-axis value to set to

Definition at line 615 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p.

00616 {
00617   this->_p(0) = x; this->_p(1) = y;
00618 }

template<class T, class Rotation_Type>
void claraty::Trans< T, Rotation_Type >::set_xyz ( x,
y,
z 
) [inline]

Set the X,Y,Z-axis component of the translation

Parameters:
[in] x X-axis value to set to
[in] y Y-axis value to set to
[in] z Z-axis value to set to

Definition at line 632 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p.

Referenced by claraty::Transform_IO::_extract_position_attributes(), claraty::Transform_IO::convert_DH_to_transform(), and claraty::HTrans< T >::set().

00633 {
00634   this->_p(0) = x; this->_p(1) = y; this->_p(2) = z;
00635 }

template<class T, class Rotation_Type>
void claraty::Trans< T, Rotation_Type >::set_translation ( const Point< T > &  p  )  [inline]

Set the translation

Parameters:
[in] p Point containing the translation to set to

Definition at line 553 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p.

Referenced by claraty::Frame_IO::convert_to_internal_format(), and claraty::ME_Body::rotate_center_of_mass().

00554 {
00555   this->_p = p;
00556 }

template<class T, class Rotation_Type>
void claraty::Trans< T, Rotation_Type >::set_rotation ( const RMatrix< T > &  r  )  [inline]

template<class T, class Rotation_Type>
void claraty::Trans< T, Rotation_Type >::set_rotation ( const Quaternion< T > &  r  )  [inline]

Set the rotation component

Parameters:
[in] r Rotation_Type to set to

Definition at line 662 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_r.

00663 {
00664   this->_r = r;
00665 }

template<class T, class Rotation_Type>
bool claraty::Trans< T, Rotation_Type >::io ( FDM_Map  map  )  [inline]

Definition at line 675 of file trans.h.

References claraty::Base_Trans< T, Rotation_Type >::_p, and claraty::Base_Trans< T, Rotation_Type >::_r.

00676 {
00677   bool ok;
00678 
00679   ok = this->_p.io(map);
00680   ok &= this->_r.io(map);
00681 
00682   return ok;
00683 }


Friends And Related Function Documentation

template<class T, class Rotation_Type>
template<class T1, class Rotation_Type1>
Trans<T1, Rotation_Type1> inverse ( const Trans< T1, Rotation_Type1 > &  q  )  [friend]

friend inverse function

Parameters:
[in] q Transform that is to be inverted.
Returns:
Transfrom that has been inverted.

Definition at line 177 of file trans.h.

Referenced by claraty::Trans< T, Rotation_Type >::relative_to().

00178 {
00179   Trans<T1,Rotation_Type1> result(q);
00180   result._r = result._r.reverse();     
00181   result._p = result._r * q._p;
00182   
00183   // Negate the position, done this way for efficiency
00184   //
00185   result._p(0) = -result._p(0);
00186   result._p(1) = -result._p(1);
00187   result._p(2) = -result._p(2);
00188   return result;
00189 }

template<class T, class Rotation_Type>
template<class T2, class Rotation_Type2>
std::ostream& operator<< ( std::ostream &  os,
const Trans< T2, Rotation_Type2 > &  tt 
) [friend]

friend operator ostream out

Parameters:
[in] os ostream reference
[in] tt Trans to be out-putted
Returns:
ostream with output

Definition at line 203 of file trans.h.

00205 {
00206   std::ios::fmtflags oldBase;
00207   int oldPrecision;
00208   
00209   //os.setf(std::ios::showbase);
00210   os.unsetf(std::ios::showpoint);
00211   os.unsetf(std::ios::scientific);
00212   
00213   if (sizeof(T2)==1) {
00214     oldBase = os.setf(std::ios::hex, std::ios::basefield);
00215   } 
00216   else {
00217     oldPrecision = os.precision();
00218     os.precision(4);
00219   }
00220   
00221   if (XML_Out::is_xml_output_on())
00222       {
00223         os << tt._p;
00224         os << tt._r;
00225       }
00226     else
00227       {
00228         os << "Trans:[";
00229         os << tt._p;
00230         os << tt._r;
00231         os << " ]";
00232       }
00233 
00234   if (sizeof(T2)==1) 
00235     os.setf(oldBase, std::ios::basefield);
00236   else
00237     os.precision(oldPrecision);
00238   
00239   return os;
00240 }


Member Data Documentation


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