Welcome to mirror list, hosted at ThFree Co, Russian Federation.

traits.h « utilities « kdl « itasc « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7b0b5f1b30f696af201393d368b69e694a98d726 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/** \file itasc/kdl/utilities/traits.h
 * \ingroup itasc
 */
#ifndef KDLPV_TRAITS_H 
#define KDLPV_TRAITS_H 

#include "utility.h"

 
// forwards declarations :
namespace KDL {
   class Frame;
    class Rotation;
    class Vector;
    class Twist;
    class Wrench;
	class FrameVel;
	class RotationVel;
	class VectorVel;
	class TwistVel;
}


/**
 * @brief Traits are traits classes to determine the type of a derivative of another type.
 *
 * For geometric objects the "geometric" derivative is chosen.  For example the derivative of a Rotation
 * matrix is NOT a 3x3 matrix containing the derivative of the elements of a rotation matrix.  The derivative
 * of the rotation matrix is a Vector corresponding the rotational velocity.  Mostly used in template classes
 * and routines to derive a correct type when needed.
 * 
 * You can see this as a compile-time lookuptable to find the type of the derivative.
 *
 * Example
 * \verbatim
	Rotation R;
    Traits<Rotation> dR;
   \endverbatim
 */
template <typename T>
struct Traits {
	typedef T valueType;
	typedef T derivType;
};

template <>
struct Traits<KDL::Frame> {
	typedef KDL::Frame valueType;
	typedef KDL::Twist derivType;
};
template <>
struct Traits<KDL::Twist> {
	typedef KDL::Twist valueType;
	typedef KDL::Twist derivType;
};
template <>
struct Traits<KDL::Wrench> {
	typedef KDL::Wrench valueType;
	typedef KDL::Wrench derivType;
};

template <>
struct Traits<KDL::Rotation> {
	typedef KDL::Rotation valueType;
	typedef KDL::Vector derivType;
};

template <>
struct Traits<KDL::Vector> {
	typedef KDL::Vector valueType;
	typedef KDL::Vector derivType;
};

template <>
struct Traits<double> {
	typedef double valueType;
	typedef double derivType;
};

template <>
struct Traits<float> {
	typedef float valueType;
	typedef float derivType;
};

template <>
struct Traits<KDL::FrameVel> {
	typedef KDL::Frame valueType;
	typedef KDL::TwistVel derivType;
};
template <>
struct Traits<KDL::TwistVel> {
	typedef KDL::Twist valueType;
	typedef KDL::TwistVel derivType;
};

template <>
struct Traits<KDL::RotationVel> {
	typedef KDL::Rotation valueType;
	typedef KDL::VectorVel derivType;
};

template <>
struct Traits<KDL::VectorVel> {
	typedef KDL::Vector valueType;
	typedef KDL::VectorVel derivType;
};



#endif