@@ -103,13 +103,13 @@ void mafDataSetCollection::orientations(double ori[3], double t) {
103103 double sx, sy;
104104
105105 // Extract the rotation sub-matrix and calculate the angles considering the Yaw-Pitch-Roll convention.
106- nx = m-> get ( 0 ,0 );
107- ny = m-> get ( 1 ,0 );
108- nz = m-> get ( 2 ,0 );
109- ax = m-> get ( 0 ,2 );
110- ay = m-> get ( 1 ,2 );
111- sx = m-> get ( 0 ,1 );
112- sy = m-> get ( 1 ,1 );
106+ nx = cvmGet (m, 0 ,0 );
107+ ny = cvmGet (m, 1 ,0 );
108+ nz = cvmGet (m, 2 ,0 );
109+ ax = cvmGet (m, 0 ,2 );
110+ ay = cvmGet (m, 1 ,2 );
111+ sx = cvmGet (m, 0 ,1 );
112+ sy = cvmGet (m, 1 ,1 );
113113
114114 ori[Z_AXIS] = atan2 (ny, nx);
115115 ori[Y_AXIS] = atan2 (-nz, cos (ori[Z_AXIS])*nx + sin (ori[Z_AXIS])*ny);
@@ -143,7 +143,7 @@ void mafDataSetCollection::position(double pos[3], double t) {
143143
144144 // Extract the position vector from the matrix and write it into the array.
145145 for (int i = 0 ; i < 3 ; ++i) {
146- pos[i] = m-> get ( i,3 );
146+ pos[i] = cvmGet (m, i,3 );
147147 }
148148}
149149
@@ -170,51 +170,58 @@ mafPoseMatrix *mafDataSetCollection::poseMatrix(double t) {
170170
171171void mafDataSetCollection::writePosition (double x, double y, double z, mafPoseMatrix *m) {
172172 // Write the position vector into the given matrix.
173- m-> put ( 0 ,3 , x);
174- m-> put ( 1 ,3 , y);
175- m-> put ( 2 ,3 , z);
173+ cvmSet (m, 0 ,3 ,x);
174+ cvmSet (m, 1 ,3 ,y);
175+ cvmSet (m, 2 ,3 ,z);
176176}
177177
178178void mafDataSetCollection::writeOrientation (double rx, double ry, double rz, mafPoseMatrix *m) {
179- // calculate the rotation sub-matrix considering the Yaw-Pitch-Roll convention.
180- mafPoseMatrix Rz;
181- mafPoseMatrix Ry;
182- mafPoseMatrix Rx;
183-
184- Rz.set_identity ();
185- Ry.set_identity ();
186- Rx.set_identity ();
179+ // calculate the rotation sub-matrix considering the Yaw-Pitch-Roll convention.
180+ mafPoseMatrix *Rz = cvCreateMat (4 ,4 ,CV_64FC1);
181+ cvSetIdentity (Rz);
182+ mafPoseMatrix *Ry = cvCreateMat (4 ,4 ,CV_64FC1);
183+ cvSetIdentity (Ry);
184+ mafPoseMatrix *Rx = cvCreateMat (4 ,4 ,CV_64FC1);
185+ cvSetIdentity (Rx);
187186
188187 double rx_rad, ry_rad, rz_rad;
189188 rx_rad = degreesToRadiant (rx);
190189 ry_rad = degreesToRadiant (ry);
191190 rz_rad = degreesToRadiant (rz);
192191
193- Rz. put ( 0 ,0 ,cos (rz_rad));
194- Rz. put ( 1 ,1 ,cos (rz_rad));
195- Rz. put ( 0 ,1 ,-sin (rz_rad));
196- Rz. put ( 1 ,0 ,sin (rz_rad));
192+ cvmSet (Rz, 0 ,0 ,cos (rz_rad));
193+ cvmSet (Rz, 1 ,1 ,cos (rz_rad));
194+ cvmSet (Rz, 0 ,1 ,-sin (rz_rad));
195+ cvmSet (Rz, 1 ,0 ,sin (rz_rad));
197196
198- Ry. put ( 0 ,0 ,cos (ry_rad));
199- Ry. put ( 2 ,2 ,cos (ry_rad));
200- Ry. put ( 0 ,2 ,sin (ry_rad));
201- Ry. put ( 2 ,0 ,-sin (ry_rad));
197+ cvmSet (Ry, 0 ,0 ,cos (ry_rad));
198+ cvmSet (Ry, 2 ,2 ,cos (ry_rad));
199+ cvmSet (Ry, 0 ,2 ,sin (ry_rad));
200+ cvmSet (Ry, 2 ,0 ,-sin (ry_rad));
202201
203- Rx. put ( 1 ,1 ,cos (rx_rad));
204- Rx. put ( 2 ,2 ,cos (rx_rad));
205- Rx. put ( 1 ,2 ,-sin (rx_rad));
206- Rx. put ( 2 ,1 ,sin (rx_rad));
202+ cvmSet (Rx, 1 ,1 ,cos (rx_rad));
203+ cvmSet (Rx, 2 ,2 ,cos (rx_rad));
204+ cvmSet (Rx, 1 ,2 ,-sin (rx_rad));
205+ cvmSet (Rx, 2 ,1 ,sin (rx_rad));
207206
208207 // Store the old position for the matrix m
209208 double pos[3 ];
210209 for (int i = 0 ; i < 3 ; ++i) {
211- pos[i] = m-> get ( i,3 );
210+ pos[i] = cvmGet (m, i,3 );
212211 }
213212
214213 // Copy into 'm' the result of the matrix multiplication.
215- *m = Rz * Ry * Rx;
214+ mafPoseMatrix *T = cvCreateMat (4 ,4 ,CV_64FC1);
215+ cvMatMul (Rz, Ry, T);
216+ cvMatMul (T, Rx, m);
216217 // Re-Apply the position
217218 writePosition (pos[0 ], pos[1 ], pos[2 ], m);
219+ cvReleaseMat (&Rx);
220+ cvReleaseMat (&Ry);
221+ cvReleaseMat (&Rz);
222+ cvReleaseMat (&T);
223+
224+
218225}
219226
220227bool mafDataSetCollection::insertItem (mafDataSet *item, double t) {
@@ -303,13 +310,12 @@ mafDataSet *mafDataSetCollection::itemAt(double t) {
303310 item = mafNEW (mafResources::mafDataSet);
304311 item->setParent (this );
305312 mafPoseMatrix *m;
306- m = new mafPoseMatrix ( );
307- m-> set_identity ( );
313+ m = cvCreateMat ( 4 , 4 ,CV_64FC1 );
314+ cvSetIdentity (m );
308315 item->setPoseMatrix (m);
309316 insertItem (item, ts);
310317 item->release ();
311- delete m;
312- m = NULL ;
318+ cvReleaseMat (&m);
313319 }
314320 return item;
315321}
0 commit comments