[2] | 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 | {
|
---|
| 32 | rot_value=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 |
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | //compute rotation of each axis through ComputeRotation(Vector3D& vector)
|
---|
| 45 | void OneAxisRotation_impl::ComputeRotation(Quaternion& quat) const {
|
---|
| 46 | Vector3D rot=Vector3D(quat.q1,quat.q2,quat.q3);
|
---|
| 47 | ComputeRotation(rot);
|
---|
| 48 | quat.q1=rot.x;
|
---|
| 49 | quat.q2=rot.y;
|
---|
| 50 | quat.q3=rot.z;
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | void OneAxisRotation_impl::ComputeRotation(RotationMatrix& matrix) const {
|
---|
| 54 | printf("not yet implemented\n");
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | //on utilise la rotation d'un vector pour faire une rotation de repere
|
---|
| 58 | //d'ou le signe negatif
|
---|
| 59 | void OneAxisRotation_impl::ComputeRotation(Vector3D& vector) const
|
---|
| 60 | {
|
---|
| 61 | switch(rot_axe->CurrentIndex())
|
---|
| 62 | {
|
---|
| 63 | case 0:
|
---|
| 64 | vector.RotateXDeg(-rot_value->Value());
|
---|
| 65 | break;
|
---|
| 66 | case 1:
|
---|
| 67 | vector.RotateYDeg(-rot_value->Value());
|
---|
| 68 | break;
|
---|
| 69 | case 2:
|
---|
| 70 | vector.RotateZDeg(-rot_value->Value());
|
---|
| 71 | break;
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | void OneAxisRotation_impl::ComputeRotation(Euler& euler) const
|
---|
| 76 | {
|
---|
| 77 | Quaternion quat;
|
---|
| 78 | euler.ToQuaternion(quat);
|
---|
| 79 | ComputeRotation(quat);
|
---|
| 80 | quat.ToEuler(euler);
|
---|
| 81 | }
|
---|
| 82 |
|
---|