AURobotServers  4
Public Member Functions | Public Attributes | List of all members
URotation Class Reference

#include <u3d.h>

Inheritance diagram for URotation:
Inheritance graph

Public Member Functions

void add (URotation *rot)
 
void add (URotation rot)
 
void add (double iOmega, double iPhi, double iKappa)
 
URotation added (URotation *rot)
 
UMatrix4 asMatrix3x3CtoW ()
 
UMatrix4 asMatrix3x3K ()
 
UMatrix4 asMatrix3x3Kt ()
 
UMatrix4 asMatrix3x3MtoR ()
 
UMatrix4 asMatrix3x3O ()
 
UMatrix4 asMatrix3x3Ot ()
 
UMatrix4 asMatrix3x3P ()
 
UMatrix4 asMatrix3x3Pt ()
 
UMatrix4 asMatrix3x3RtoM ()
 
UMatrix4 asMatrix3x3WtoC ()
 
UMatrix4 asMatrix4x4CtoW ()
 
UMatrix4 asMatrix4x4CtoW (UPosition *pos)
 
UMatrix4 asMatrix4x4MtoR ()
 
UMatrix4 asMatrix4x4MtoR (UPosition *pos)
 
UMatrix4 asMatrix4x4MtoR (UPosition pos)
 
UMatrix4 asMatrix4x4RtoM ()
 
UMatrix4 asMatrix4x4RtoM (UPosition *pos)
 
UMatrix4 asMatrix4x4RtoM (UPosition pos)
 
UMatrix4 asMatrix4x4WtoC ()
 
UMatrix4 asMatrix4x4WtoC (UPosition *pos)
 
UMatrix4 asUnitZVector3CtoW ()
 
UMatrix4 asUnitZVector4CtoW ()
 
UMatrix4 asVector3 ()
 
UMatrix4 asVector4 ()
 
void clear (void)
 
virtual const char * codeXml (char *buff, const int buffCnt, const char *extra)
 
virtual const char * codeXml (const char *name, char *buff, const int buffCnt, const char *extra)
 
int copy (UMatrix4 *rot)
 
int copy (UPosition *pos)
 
URotationgetRot ()
 
void LimitToPi ()
 
void limitToPi ()
 
bool load (const char *valueString)
 
int LoadFromReg (Uconfig *ini, const char *subject, const char *key)
 
URotation operator* (double val)
 
void operator*= (double val)
 
URotation operator+ (URotation rot)
 
void operator+= (URotation rot)
 
URotation operator- (URotation rot)
 
void operator-= (URotation rot)
 
URotation operator= (UMatrix4 vec)
 
URotation operator= (UPosition pos)
 
void print (const char *leadString)
 
bool save (FILE *fmap, const char *key)
 
int SaveToReg (Uconfig *ini, const char *subject, const char *key)
 
void scale (double val)
 
URotation scaled (double val)
 
void set (double iOmega, double iPhi, double iKappa)
 
void setFromYZ (UPosition posY, UPosition posZ)
 
void setRot (URotation rot)
 
void show (const char *leadString)
 
void snprint (const char *leadString, bool inDegree, char *s, const int bufferLength)
 
void sprint (char *s, const char *leadString, bool inDegree=true)
 
void subtract (URotation *rot)
 
URotation subtracted (URotation *rot)
 
 URotation ()
 
 URotation (double iOmega, double iPhi, double iKappa)
 
virtual ~URotation ()
 

Public Attributes

double Kappa
 
double Omega
 
double Phi
 

Detailed Description

General class to hold rotation around x,y,z axiz Omega is rotation around x axis Phi is rotation around y axis Kappa is rotation around z axis (unit is radians - right hand rotation)

Normal rotation order is Phi then Omega then Kappa just like a crane with a camera at the top This order is assumed in all camera conversion functions.

Constructor & Destructor Documentation

URotation::URotation ( )

Constructor with default initialization.

URotation::~URotation ( )
virtual

destructor

URotation::URotation ( double  iOmega,
double  iPhi,
double  iKappa 
)

Constructor with specific initialization

Member Function Documentation

void URotation::add ( URotation rot)

Just add parameter rotation to this and adjust result to within +/- PI.

References Kappa, LimitToPi(), Omega, and Phi.

Referenced by operator+=().

void URotation::add ( URotation  rot)

Just as above, but parameter is not a pointer

References Kappa, LimitToPi(), Omega, and Phi.

void URotation::add ( double  iOmega,
double  iPhi,
double  iKappa 
)

Add values directly, and adjust result to +/- PI;

References Kappa, LimitToPi(), Omega, and Phi.

URotation URotation::added ( URotation rot)

Return a value, that is the sum of this and the parameter. This value is unchanged.

References Kappa, LimitToPi(), Omega, and Phi.

Referenced by operator+().

UMatrix4 URotation::asMatrix3x3CtoW ( )

Get transformation matrix to convert a 3D position [x,y,z] from camera to world perspective using both camera rotation only. Matrix is calculated as: P' * O' * K'
usage: Xw = asMatrix4x4CtoW(&pos) * Xc
where Xc is 3D coordinates in camera perspective and Xw is the same in world perspective.

References UMatrix::get(), Kappa, Omega, Phi, and UMatrix::setRC().

Referenced by asMatrix4x4CtoW(), asUnitZVector3CtoW(), and testMatrix().

UMatrix4 URotation::asMatrix3x3K ( )

Get rotation matrix around Z axis only

References UMatrix::get(), Kappa, and UMatrix::setRC().

Referenced by asMatrix3x3MtoR().

UMatrix4 URotation::asMatrix3x3Kt ( )

Get rotation matrix around Z axis only and transposed

References UMatrix::get(), Kappa, and UMatrix::setRC().

Referenced by asMatrix3x3RtoM().

UMatrix4 URotation::asMatrix3x3MtoR ( )

Get rotation matrix to rotate a position from map coordinates to robot coordinates

References asMatrix3x3K(), asMatrix3x3O(), and asMatrix3x3P().

Referenced by asMatrix4x4MtoR().

UMatrix4 URotation::asMatrix3x3O ( )

Get rotation matrix around X axis only

References UMatrix::get(), Omega, and UMatrix::setRC().

Referenced by asMatrix3x3MtoR().

UMatrix4 URotation::asMatrix3x3Ot ( )

Get rotation matrix around X axis only and transposed

References UMatrix::get(), Omega, and UMatrix::setRC().

Referenced by asMatrix3x3RtoM().

UMatrix4 URotation::asMatrix3x3P ( )

Get rotation matrix around Y axis only

References UMatrix::get(), Phi, and UMatrix::setRC().

Referenced by asMatrix3x3MtoR().

UMatrix4 URotation::asMatrix3x3Pt ( )

Get rotation matrix around Y axis only and transposed

References UMatrix::get(), Phi, and UMatrix::setRC().

Referenced by asMatrix3x3RtoM().

UMatrix4 URotation::asMatrix3x3RtoM ( )

Get rotation matrix to rotate a position from robot coordinates to map coordinates

References asMatrix3x3Kt(), asMatrix3x3Ot(), and asMatrix3x3Pt().

Referenced by asMatrix4x4RtoM().

UMatrix4 URotation::asMatrix3x3WtoC ( )

Gets rotation and conversion matrix:
Camera to World (CtoW) and World to Camera (WtoC)
all based on rotation seen in world coordinate perspective
with first turn around Y axis (up) left is positiove
then elevate around x axis (right) up is positive
then rotate around z axis (back) ccv is positive
translation position (pos) is camera position in world coordinates.

References UMatrix::get(), Kappa, Omega, Phi, and UMatrix::setRC().

Referenced by asMatrix4x4WtoC(), and testMatrix().

UMatrix4 URotation::asMatrix4x4CtoW ( )

Get transformation matrix to convert a 3D position [x,y,z,1] from camera to world perspective using both camera rotation only. Matrix is calculated as: P' * O' * K'
usage: Xw = asMatrix4x4CtoW(&pos) * Xc
where Xc is 3D coordinates in camera perspective and Xw is the same in world perspective.

References asMatrix3x3CtoW(), and UMatrix::expand().

Referenced by asMatrix4x4CtoW(), and UCalibrationMarkSet::geterrorInPixels().

UMatrix4 URotation::asMatrix4x4CtoW ( UPosition pos)

Get transformation matrix to convert a 3D position [x,y,z,1] from camera to world perspective using both camera rotation and position. Matrix is calculated as: T(-pos) * P' * O' * K'
usage: Xw = asMatrix4x4CtoW(&pos) * Xc
where Xc is 3D coordinates in camera perspective and Xw is the same in world perspective.

References UPosition::asMatrix4x4(), asMatrix4x4CtoW(), and UPosition::scale().

UMatrix4 URotation::asMatrix4x4MtoR ( )

Get rotation matrix to rotate a position from map coordinates to robot coordinates.
Returns 4x4 matrix.

References asMatrix3x3MtoR(), and UMatrix::expand().

Referenced by asMatrix4x4MtoR(), UClientFuncLaserGui::doImage(), UPosRot::getMtoRMatrix(), UImgPolyProj::getRobToCam(), UImgProj::getRobToCam(), setFromYZ(), and testUPosRot().

UMatrix4 URotation::asMatrix4x4MtoR ( UPosition pos)

Makes rotation translation matrix from map coordiantes to robot coordinates,with the following robot coordinates X is forward, Y is left, Z is Up.
(Right hand coordinates)
Phi (P) is y-axis (robot nose up or down down is positive)
Omega (O) is x-axis (tilt robot left or right, right is positive)
Kappa (K) is z axis (turn robot left or right, left is positive)
pos (T) is is position of robot in world coordinates (meter). Returns a 4x4 matrix.

References UPosition::asMatrix4x4(), and asMatrix4x4MtoR().

UMatrix4 URotation::asMatrix4x4MtoR ( UPosition  pos)
inline

Same as above, but full position as parameter

References asMatrix4x4MtoR().

Referenced by asMatrix4x4MtoR().

UMatrix4 URotation::asMatrix4x4RtoM ( )

Get rotation matrix to rotate a position from robot coordinates to map coordinates.
Returns 4x4 matrix.

References asMatrix3x3RtoM(), and UMatrix::expand().

Referenced by asMatrix4x4RtoM(), UClientFuncLaserGui::doImage(), UImgProj::getCamToRob(), UImgPolyProj::getCamToRob(), UClientFuncLaserGui::getPixToRobFloor(), UPosRot::getRtoMMatrix(), UOriPlane::set(), and testUPosRot().

UMatrix4 URotation::asMatrix4x4RtoM ( UPosition pos)

Makes rotation translation matrix from robot coordiantes to map coordinates,with the following robot coordinates.
X is forward, Y is left, Z is Up. (Right hand coordinates)
Phi (P) is y-axis (robot nose up or down down is positive)
Omega (O) is x-axis (tilt robot left or right, right is positive)
Kappa (K) is z axis (turn robot left or right, left is positive)
pos (T) is is position of robot in world coordinates (meter). Returns a 4x4 matrix.

References UPosition::asMatrix4x4(), asMatrix4x4RtoM(), and UPosition::scale().

UMatrix4 URotation::asMatrix4x4RtoM ( UPosition  pos)
inline

Same as above, but full position as parameter

References asMatrix4x4RtoM().

Referenced by asMatrix4x4RtoM().

UMatrix4 URotation::asMatrix4x4WtoC ( )

Phi (P) is y-axis (turn camera to the left is positive)
Omega (O) is x-axis (tilt camera up towards cealing is positive)
Kappa (K) is z axis (rotate camera ccv is positive)
usage: matrix from world to camera oriented coordinates is K * O * P (* T).

References asMatrix3x3WtoC(), and UMatrix::expand().

Referenced by asMatrix4x4WtoC(), and UCalibrationMarkSet::geterrorInPixels().

UMatrix4 URotation::asMatrix4x4WtoC ( UPosition pos)

Phi (P) is y-axis (turn camera to the left is positive)
Omega (O) is x-axis (tilt camera up towards cealing is positive)
Kappa (K) is z axis (rotate camera ccv is positive)
Matrix from world to camera oriented coordinates is K * O * P * pos).
Usage: Xc = asMatrix4x4WtoC(&pos) * Xw,
where Xc is 3D coordinates in camera perspective and Xw is the same in world perspective.

References UPosition::asMatrix4x4(), and asMatrix4x4WtoC().

UMatrix4 URotation::asUnitZVector3CtoW ( )

Returns a unit vector in z-direction in camera coordinates rotated by this rotation, assuming this is the camera rotation: returns R * (0, 0, -1).

References asMatrix3x3CtoW(), and UMatrix::setAt().

Referenced by asUnitZVector4CtoW().

UMatrix4 URotation::asUnitZVector4CtoW ( )

Returns a unit vector in z-direction in camera coordinates rotated by this rotation, assuming this is the camera rotation: returns R * (0, 0, -1, 1).

References asUnitZVector3CtoW(), UMatrix::init(), and UMatrix::setAt().

UMatrix4 URotation::asVector3 ( )

Converts parameters to vector format. Returns (Omega, Phi, Kappa).

References UPosition::asVector3(), and UPosition::copy().

UMatrix4 URotation::asVector4 ( )

Converts parameters to vector format. Returns (Omega, Phi, Kappa, 1).

References UPosition::asVector4(), and UPosition::copy().

void URotation::clear ( void  )
const char * URotation::codeXml ( char *  buff,
const int  buffCnt,
const char *  extra 
)
virtual

Code this structure in XML format. The open tag includes any additional XML attributes from the codeXmlAttributes function call

Parameters
buffis the character buffer where the attributes are stored
buffCntis the amount of buffer space allocated
extrais an extra attribute string that is added to the tag
Returns
a pointer to the buffer

References Kappa, Omega, and Phi.

Referenced by codeXml(), and UFunctionLaser::handleSetCommand().

const char * URotation::codeXml ( const char *  name,
char *  buff,
const int  buffCnt,
const char *  extra 
)
virtual

Code this structure in XML format. The open tag includes any additional XML attributes from the codeXmlAttributes function call

Parameters
optionalname value for a name attribute (if NULL, no name attribute.
buffis the character buffer where the attributes are stored
buffCntis the amount of buffer space allocated
extrais an extra attribute string that is added to the tag
Returns
a pointer to the buffer

References codeXml().

int URotation::copy ( UMatrix4 rot)

Copy rotation data from vector , assuming that first element is Omega, second is Phi and third is Kappa. If size 4 vector then fourth value is assumed scale.

References UPosition::copy(), Kappa, Omega, Phi, UPosition::x, UPosition::y, and UPosition::z.

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

int URotation::copy ( UPosition pos)

Copy values from a position, transferring Omega = x, Phi = y, Kappa = z.

References Kappa, Omega, Phi, UPosition::x, UPosition::y, and UPosition::z.

URotation* URotation::getRot ( )
inline

Get a pointer to this URotation value (for decendent classes)

References add.

Referenced by UPosRot::getRot(), and UPosRot::rot().

void URotation::LimitToPi ( )

Limit Omega, Phi and Kappa to within the -Pi to -Pi limit.

References Kappa, Omega, and Phi.

Referenced by add(), added(), UCalibrate::findBarcodeChartPosition(), set(), subtract(), and subtracted().

void URotation::limitToPi ( )
inline

lower initial letter version. Limit Omega, Phi and Kappa to within the -Pi to -Pi limit.

bool URotation::load ( const char *  valueString)

Load values from comma separated string values in e format. Returns true if all 3 values were read.

References Kappa, Omega, and Phi.

int URotation::LoadFromReg ( Uconfig ini,
const char *  subject,
const char *  key 
)

Load rotation values from configuration structure 'ini' as found under the provided subject and key. If subject or key do not exist, then rotation is cleared.

References copy(), Kappa, UPosition::LoadFromReg(), Omega, and Phi.

URotation URotation::operator* ( double  val)

Make scaled version of a rotation set

References scaled().

void URotation::operator*= ( double  val)

Scale this rotation set with a factor

References scale().

URotation URotation::operator+ ( URotation  rot)

Make a sum of two rotation sets

References added().

void URotation::operator+= ( URotation  rot)

Add an angle set to this value

References add().

URotation URotation::operator- ( URotation  rot)

Make diffrence of two rotation sets

References subtracted().

void URotation::operator-= ( URotation  rot)

Subtract an angle set to this value

References subtract().

URotation URotation::operator= ( UMatrix4  vec)

Function as copy described above. Copy a vector to a rotation type, from vector [Omega, Phi, Kappa], or from vector [w * Omega, w * Phi, w * Kappa, w].

References copy().

URotation URotation::operator= ( UPosition  pos)
inline

Copy a 3D position as a rotation type.

References add.

void URotation::print ( const char *  leadString)

Print the values of the rotation to the console directly, with the provided string as lead in string.

References Kappa, Omega, and Phi.

Referenced by testUPosRot().

bool URotation::save ( FILE *  fmap,
const char *  key 
)

Save rotation in html-like format. Returns true if saved.

References Kappa, Omega, and Phi.

int URotation::SaveToReg ( Uconfig ini,
const char *  subject,
const char *  key 
)

Save rotation values to configuration structure under the provided subject and key. If subject or key do not exist then it is created.

References UPosition::copy(), and UPosition::SaveToReg().

void URotation::scale ( double  val)

Scale this rotation with provided factor.

References Kappa, Omega, and Phi.

Referenced by UCalibrationMarkSet::evaluateChartPosRot(), and operator*=().

URotation URotation::scaled ( double  val)

Return a scaled verion of this rotation, caled with this factor.

References Kappa, Omega, and Phi.

Referenced by UCamParEst::adjustParameters35(), and operator*().

void URotation::set ( double  iOmega,
double  iPhi,
double  iKappa 
)
void URotation::setFromYZ ( UPosition  posY,
UPosition  posZ 
)

Set rotation from these 2 vectors pointing in Y and Z direction (robot coordinate type). Rotation is set as azimult first - a rotation arounf Z axis (positive CCV) (kappa). then as elevation +/- PI/2 around the Y axis (Phi) positive down. And finally rotation around the x axis (+/- Pi) - positive to the right (Omega)

References asMatrix4x4MtoR(), UPosition::clear(), UPosition::cross(), Kappa, Omega, Phi, UPosition::toUnitVector(), UPosition::x, UPosition::y, and UPosition::z.

Referenced by UPosRot::setCtoR(), UPosRot::setRtoC(), and testUPosRot().

void URotation::setRot ( URotation  rot)
inline

Set value directly

Referenced by UPosRot::set(), and UPosRot::setRot().

void URotation::show ( const char *  leadString)
inline

Print the values of the rotation to the console directly, with the provided string as lead in string.

References DoFindPeak().

void URotation::snprint ( const char *  leadString,
bool  inDegree,
char *  s,
const int  bufferLength 
)

As above function, but with limit on buffer length.

References Kappa, Omega, and Phi.

Referenced by UCamPush::print(), and UClientCamData::snprint().

void URotation::sprint ( char *  s,
const char *  leadString,
bool  inDegree = true 
)

Print values to string 's' with 'leadString' in front. Values are in degrees if 'inDegree' is true, else in radians.

References Kappa, Omega, and Phi.

Referenced by UCalibrationMarkSet::evaluateChartPosRot(), and UCalibrationMarkSet::evaluatePosRot().

void URotation::subtract ( URotation rot)

Subtract parameter rotation from this, and adjust the result to within +/- PI.

References Kappa, LimitToPi(), Omega, and Phi.

Referenced by UCalibrationMarkSet::evaluateChartPosRot(), UCalibrationMarkSet::evaluatePosRot(), and operator-=().

URotation URotation::subtracted ( URotation rot)

Returns a value where the referenced is subtracted. This value is unchanged.

References Kappa, LimitToPi(), Omega, and Phi.

Referenced by operator-().

Member Data Documentation

double URotation::Kappa
double URotation::Omega
double URotation::Phi

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