1 | // %flair:license{
|
---|
2 | // This file is part of the Flair framework distributed under the
|
---|
3 | // CECILL-C License, Version 1.0.
|
---|
4 | // %flair:license}
|
---|
5 | // created: 2013/04/17
|
---|
6 | // filename: OneAxisRotation_impl.cpp
|
---|
7 | //
|
---|
8 | // author: Guillaume Sanahuja
|
---|
9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
10 | //
|
---|
11 | // version: $Id: $
|
---|
12 | //
|
---|
13 | // purpose: objet integrant pour une rotation sur un axe
|
---|
14 | //
|
---|
15 | //
|
---|
16 | /*********************************************************************/
|
---|
17 |
|
---|
18 | #include "OneAxisRotation_impl.h"
|
---|
19 | #include "GroupBox.h"
|
---|
20 | #include "ComboBox.h"
|
---|
21 | #include "DoubleSpinBox.h"
|
---|
22 | #include <Vector3D.h>
|
---|
23 | #include <Euler.h>
|
---|
24 | #include <Quaternion.h>
|
---|
25 |
|
---|
26 | using std::string;
|
---|
27 | using namespace flair::core;
|
---|
28 | using namespace flair::gui;
|
---|
29 |
|
---|
30 | OneAxisRotation_impl::OneAxisRotation_impl(GroupBox *box) {
|
---|
31 | rot_value =
|
---|
32 | new DoubleSpinBox(box->NewRow(), "value", " deg", -180., 180., 10., 1);
|
---|
33 | rot_axe = new ComboBox(box->LastRowLastCol(), "axis");
|
---|
34 | rot_axe->AddItem("x");
|
---|
35 | rot_axe->AddItem("y");
|
---|
36 | rot_axe->AddItem("z");
|
---|
37 | }
|
---|
38 |
|
---|
39 | OneAxisRotation_impl::~OneAxisRotation_impl() {}
|
---|
40 |
|
---|
41 | // compute rotation of each axis through ComputeRotation(Vector3D& vector)
|
---|
42 | void OneAxisRotation_impl::ComputeRotation(Quaternion &quat) const {
|
---|
43 | Vector3D rot = Vector3D(quat.q1, quat.q2, quat.q3);
|
---|
44 | ComputeRotation(rot);
|
---|
45 | quat.q1 = rot.x;
|
---|
46 | quat.q2 = rot.y;
|
---|
47 | quat.q3 = rot.z;
|
---|
48 | }
|
---|
49 |
|
---|
50 | void OneAxisRotation_impl::ComputeRotation(RotationMatrix &matrix) const {
|
---|
51 | printf("not yet implemented\n");
|
---|
52 | }
|
---|
53 |
|
---|
54 | // on utilise la rotation d'un vector pour faire une rotation de repere
|
---|
55 | // d'ou le signe negatif
|
---|
56 | void OneAxisRotation_impl::ComputeRotation(Vector3D &vector) const {
|
---|
57 | switch (rot_axe->CurrentIndex()) {
|
---|
58 | case 0:
|
---|
59 | vector.RotateXDeg(-rot_value->Value());
|
---|
60 | break;
|
---|
61 | case 1:
|
---|
62 | vector.RotateYDeg(-rot_value->Value());
|
---|
63 | break;
|
---|
64 | case 2:
|
---|
65 | vector.RotateZDeg(-rot_value->Value());
|
---|
66 | break;
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | void OneAxisRotation_impl::ComputeRotation(Euler &euler) const {
|
---|
71 | Quaternion quat;
|
---|
72 | euler.ToQuaternion(quat);
|
---|
73 | ComputeRotation(quat);
|
---|
74 | quat.ToEuler(euler);
|
---|
75 | }
|
---|