forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlrotation_src.I
More file actions
116 lines (103 loc) · 2.65 KB
/
lrotation_src.I
File metadata and controls
116 lines (103 loc) · 2.65 KB
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
115
116
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file lrotation_src.I
* @author frang, charles
* @date 2000-06-23
*/
/**
*
*/
INLINE_LINMATH FLOATNAME(LRotation)::
FLOATNAME(LRotation)() {
}
/**
*
*/
INLINE_LINMATH FLOATNAME(LRotation)::
FLOATNAME(LRotation)(const FLOATNAME(LQuaternion) &c) :
FLOATNAME(LQuaternion)(c) {
}
/**
*
*/
INLINE_LINMATH FLOATNAME(LRotation)::
FLOATNAME(LRotation)(const FLOATNAME(LVecBase4) ©) :
FLOATNAME(LQuaternion)(copy) {
}
/**
*
*/
INLINE_LINMATH FLOATNAME(LRotation)::
FLOATNAME(LRotation)(FLOATTYPE r, FLOATTYPE i, FLOATTYPE j, FLOATTYPE k) :
FLOATNAME(LQuaternion)(r, i, j, k) {
}
/**
* lmatrix3
*/
INLINE_LINMATH FLOATNAME(LRotation)::
FLOATNAME(LRotation)(const FLOATNAME(LMatrix3) &m) {
set_from_matrix(m);
}
/**
* lmatrix4
*/
INLINE_LINMATH FLOATNAME(LRotation)::
FLOATNAME(LRotation)(const FLOATNAME(LMatrix4) &m) {
set_from_matrix(m);
}
/**
* axis + angle (in degrees)
*/
INLINE_LINMATH FLOATNAME(LRotation)::
FLOATNAME(LRotation)(const FLOATNAME(LVector3) &axis, FLOATTYPE angle) {
FLOATTYPE radians = deg_2_rad(angle);
FLOATTYPE theta_over_2 = radians * FLOATCONST(0.5);
FLOATTYPE sin_to2 = csin(theta_over_2);
set_r(ccos(theta_over_2));
set_i(axis[0] * sin_to2);
set_j(axis[1] * sin_to2);
set_k(axis[2] * sin_to2);
}
/**
* Sets the rotation from the given Euler angles.
*/
INLINE_LINMATH FLOATNAME(LRotation)::
FLOATNAME(LRotation)(FLOATTYPE h, FLOATTYPE p, FLOATTYPE r) {
set_hpr(FLOATNAME(LVecBase3)(h, p, r));
}
/**
*
*/
INLINE_LINMATH FLOATNAME(LRotation) FLOATNAME(LRotation)::
operator * (FLOATTYPE scalar) const {
return FLOATNAME(LRotation)(FLOATNAME(LVecBase4)::operator * (scalar));
}
/**
*
*/
INLINE_LINMATH FLOATNAME(LRotation) FLOATNAME(LRotation)::
operator / (FLOATTYPE scalar) const {
return FLOATNAME(LRotation)(FLOATNAME(LVecBase4)::operator / (scalar));
}
/**
* Rotation * Rotation = Rotation
*/
INLINE_LINMATH FLOATNAME(LRotation) FLOATNAME(LRotation)::
operator * (const FLOATNAME(LRotation) &other) const {
return multiply(other);
}
/**
* Rotation * Orientation = Orientation This is another meaningless operation,
* attempting to apply an orientation to a rotation.
*/
INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LRotation)::
operator * (const FLOATNAME(LQuaternion) &other) const {
nassert_raise("LRotation * LQuaternion is undefined; use LRotation * LRotation or LQuaternion * LQuaternion");
return multiply(other);
}