1
/**********************************************************************
2
Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation version 2 of the License.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
12
***********************************************************************/
14
#ifndef OE_COORDTRANSFORM_INCLUDED
15
#define OE_COORDTRANSFORM_INCLUDED
19
#include "binary_io.h"
21
using namespace OpenEye;
26
**\brief An object for storing, manipulating and applying coordinate transformations.
28
**The most basic way to setup a transformation is to use the member function Setup(float* xyz),
29
**which requires you to supply a specific set of 4 coordinates from the initial reference frame
30
**in the final reference frame. The function Setup(float *init_xyz, float* final_xyz, unsigned int N)
31
**will set up a transformation given an arbitrary set of coordinates in the final and initial
32
**reference frame. A rotation/translation or a translation/rotation can also be supplied,
33
**see the various member functions begining with Setup.
34
**\param Applying the transformation
35
**The Transform(float *xyz, unsigned int N) member function applies the objects transform
36
**to a set of coordinates.
38
**The Invert() member function will reverses the current transformation such that it changes
39
**what was originally the final reference frame into what was originally the initial reference frame.
40
**A rotation/translation or translation/rotation cooresponding to the objects transformation
41
**can be extracted, see the various member functions begining with Get. The operator+(const OECoordTrans& ct2)
42
**and operator+=(const OECoordTrans& ct) are also defined for combining transformation.
43
**\note \b IMPORTANT : This object can only handle transformations that can be described
44
**with Euler angles (i.e., No inversions). Several member function will take rotation
45
**matricies as input, however, it is assumed that these matricies only apply simple
46
**rotations that can be described with Euler angles.
54
double Angle(double sn, double cs);
55
void ApplyTranslation(float *trans, float *xyz, unsigned int N) const;
56
void ApplyEulerInvert(float *euler, float *xyz, unsigned int N) const;
57
void ApplyEuler(float *euler, float *xyz, unsigned int N) const;
58
void ApplyRmatrix(float *rmat, float *xyz, unsigned int N) const;
59
void EulerToRmatrix(float *euler, float *rmat) const;
61
//Constructor, destructor and copy constructor
63
OECoordTrans(const OECoordTrans& cp);
67
OECoordTrans& operator=(const OECoordTrans& cp);
68
OECoordTrans& operator+=(const OECoordTrans& ct);
69
OECoordTrans operator+(const OECoordTrans& ct2) const;
74
//Read/Write to binary array/stream
75
unsigned int WriteBinary(char* ccc);
76
unsigned int ReadBinary(char* ccc);
77
void WriteBinary(ostream& ostr);
78
void ReadBinary(istream& istr);
81
bool Setup(float *xyz);
82
void Setup(float *init_xyz, float *final_xyz, unsigned int N);
83
void SetupEulerTranslation(float *euler, float *trans);
84
void SetupTranslationEuler(float *trans, float *euler);
85
void SetupRmatrixTranslation(float *rmat, float *trans);
86
void SetupTranslationRmatrix(float *trans, float *rmat);
87
void SetupRmatrixTranslation(Matrix3x3& rmat, Vector& tvec);
88
void SetupTranslationRmatrix(Vector& tvec, Matrix3x3& rmat);
91
void GetEulerTranslation(float *euler, float *trans) const;
92
void GetTranslationEuler(float *trans, float *euler) const;
93
void GetRmatrixTranslation(float *rmat, float *trans) const;
94
void GetTranslationRmatrix(float *trans, float *rmat) const;
95
void GetRmatrixTranslation(Matrix3x3& rmat, Vector& tvec);
96
void GetTranslationRmatrix(Vector& tvec, Matrix3x3& rmat);
98
//Transformation functions
99
void Transform(float *xyz, unsigned int N) const;
106
**\fn OECoordTrans::_trans()
107
**\brief Stores the translation part of the transformation. This
108
**translation is applied after the rotation.
112
**\fn OECoordTrans::_euler()
113
**\brief Stores the rotation part of the transformation in euler angles.
114
**This rotation is applied before the translation. The elements of
115
**the array are : euler[0], a rotation about the z-axis; euler[1],
116
**a rotation about the x-axis; euler[2], a rotation about the z-axis.
117
**The rotations are applied in the order given.
121
**\fn OECoordTrans::_rmat()
122
**\brief Stores the rotation part of the transformation as a
123
**rotation matrix. This rotation is applied before the translation.
124
**_rmat[3*i+j] hold the matrix element in the i'th row and j'th column.
128
} //End OpenEye namespace