source: flair-src/trunk/lib/FlairCore/src/OneAxisRotation_impl.cpp@ 103

Last change on this file since 103 was 103, checked in by Sanahuja Guillaume, 6 years ago

maj quaternion 3dmgx3

File size: 2.0 KB
Line 
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
26using std::string;
27using namespace flair::core;
28using namespace flair::gui;
29
30OneAxisRotation_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
39OneAxisRotation_impl::~OneAxisRotation_impl() {}
40
41// compute rotation of each axis through ComputeRotation(Vector3D& vector)
42void 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
50void 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
56void 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
70void OneAxisRotation_impl::ComputeRotation(Euler &euler) const {
71 Quaternion quat;
72 euler.ToQuaternion(quat);
73 ComputeRotation(quat);
74 quat.ToEuler(euler);
75}
Note: See TracBrowser for help on using the repository browser.