@@ -66,12 +66,35 @@ def test_constructor(self):
66
66
array_compare (R , rotz (0.2 ))
67
67
self .assertIsInstance (R , SO3 )
68
68
69
- # triple angle
69
+ # OA
70
+ R = SO3 .OA ([0 , 1 , 0 ], [0 , 0 , 1 ])
71
+ nt .assert_equal (len (R ), 1 )
72
+ array_compare (R , np .eye (3 ))
73
+ self .assertIsInstance (R , SO3 )
74
+
75
+ # random
76
+ R = SO3 .Rand ()
77
+ nt .assert_equal (len (R ), 1 )
78
+ self .assertIsInstance (R , SO3 )
79
+
80
+ # copy constructor
81
+ R = SO3 .Rx (pi / 2 )
82
+ R2 = SO3 (R )
83
+ R = SO3 .Ry (pi / 2 )
84
+ array_compare (R2 , rotx (pi / 2 ))
85
+
86
+ def test_constructor_Eul (self ):
87
+
70
88
R = SO3 .Eul ([0.1 , 0.2 , 0.3 ])
71
89
nt .assert_equal (len (R ), 1 )
72
90
array_compare (R , eul2r ([0.1 , 0.2 , 0.3 ]))
73
91
self .assertIsInstance (R , SO3 )
74
92
93
+ R = SO3 .Eul (0.1 , 0.2 , 0.3 )
94
+ nt .assert_equal (len (R ), 1 )
95
+ array_compare (R , eul2r ([0.1 , 0.2 , 0.3 ]))
96
+ self .assertIsInstance (R , SO3 )
97
+
75
98
R = SO3 .Eul (np .r_ [0.1 , 0.2 , 0.3 ])
76
99
nt .assert_equal (len (R ), 1 )
77
100
array_compare (R , eul2r ([0.1 , 0.2 , 0.3 ]))
@@ -82,26 +105,105 @@ def test_constructor(self):
82
105
array_compare (R , eul2r ([10 , 20 , 30 ], unit = 'deg' ))
83
106
self .assertIsInstance (R , SO3 )
84
107
108
+ R = SO3 .Eul (10 , 20 , 30 , unit = 'deg' )
109
+ nt .assert_equal (len (R ), 1 )
110
+ array_compare (R , eul2r ([10 , 20 , 30 ], unit = 'deg' ))
111
+ self .assertIsInstance (R , SO3 )
112
+
113
+ # matrix input
114
+
115
+ angles = np .array ([
116
+ [0.1 , 0.2 , 0.3 ],
117
+ [0.2 , 0.3 , 0.4 ],
118
+ [0.3 , 0.4 , 0.5 ],
119
+ [0.4 , 0.5 , 0.6 ]
120
+ ])
121
+ R = SO3 .Eul (angles )
122
+ self .assertIsInstance (R , SO3 )
123
+ nt .assert_equal (len (R ), 4 )
124
+ for i in range (4 ):
125
+ array_compare (R [i ], eul2r (angles [i ,:]))
126
+
127
+ angles *= 10
128
+ R = SO3 .Eul (angles , unit = 'deg' )
129
+ self .assertIsInstance (R , SO3 )
130
+ nt .assert_equal (len (R ), 4 )
131
+ for i in range (4 ):
132
+ array_compare (R [i ], eul2r (angles [i ,:], unit = 'deg' ))
133
+
134
+
135
+ def test_constructor_RPY (self ):
136
+
137
+ R = SO3 .RPY (0.1 , 0.2 , 0.3 , order = 'zyx' )
138
+ nt .assert_equal (len (R ), 1 )
139
+ array_compare (R , rpy2r ([0.1 , 0.2 , 0.3 ], order = 'zyx' ))
140
+ self .assertIsInstance (R , SO3 )
141
+
142
+ R = SO3 .RPY (10 , 20 , 30 , unit = 'deg' , order = 'zyx' )
143
+ nt .assert_equal (len (R ), 1 )
144
+ array_compare (R , rpy2r ([10 , 20 , 30 ], order = 'zyx' , unit = 'deg' ))
145
+ self .assertIsInstance (R , SO3 )
146
+
147
+ R = SO3 .RPY ([0.1 , 0.2 , 0.3 ], order = 'zyx' )
148
+ nt .assert_equal (len (R ), 1 )
149
+ array_compare (R , rpy2r ([0.1 , 0.2 , 0.3 ], order = 'zyx' ))
150
+ self .assertIsInstance (R , SO3 )
151
+
152
+ R = SO3 .RPY (np .r_ [0.1 , 0.2 , 0.3 ], order = 'zyx' )
153
+ nt .assert_equal (len (R ), 1 )
154
+ array_compare (R , rpy2r ([0.1 , 0.2 , 0.3 ], order = 'zyx' ))
155
+ self .assertIsInstance (R , SO3 )
156
+
157
+ # check default
85
158
R = SO3 .RPY ([0.1 , 0.2 , 0.3 ])
86
159
nt .assert_equal (len (R ), 1 )
87
- array_compare (R , rpy2r ([0.1 , 0.2 , 0.3 ]))
160
+ array_compare (R , rpy2r ([0.1 , 0.2 , 0.3 ], order = 'zyx' ))
88
161
self .assertIsInstance (R , SO3 )
89
162
90
- R = SO3 .RPY (np .r_ [0.1 , 0.2 , 0.3 ])
163
+ # XYZ order
164
+
165
+ R = SO3 .RPY (0.1 , 0.2 , 0.3 , order = 'xyz' )
91
166
nt .assert_equal (len (R ), 1 )
92
- array_compare (R , rpy2r ([0.1 , 0.2 , 0.3 ]))
167
+ array_compare (R , rpy2r ([0.1 , 0.2 , 0.3 ], order = 'xyz' ))
93
168
self .assertIsInstance (R , SO3 )
94
169
95
- R = SO3 .RPY ([ 10 , 20 , 30 ] , unit = 'deg' )
170
+ R = SO3 .RPY (10 , 20 , 30 , unit = 'deg' , order = 'xyz ' )
96
171
nt .assert_equal (len (R ), 1 )
97
- array_compare (R , rpy2r ([10 , 20 , 30 ], unit = 'deg' ))
172
+ array_compare (R , rpy2r ([10 , 20 , 30 ], order = 'xyz' , unit = 'deg' ))
98
173
self .assertIsInstance (R , SO3 )
99
174
100
175
R = SO3 .RPY ([0.1 , 0.2 , 0.3 ], order = 'xyz' )
101
176
nt .assert_equal (len (R ), 1 )
102
177
array_compare (R , rpy2r ([0.1 , 0.2 , 0.3 ], order = 'xyz' ))
103
178
self .assertIsInstance (R , SO3 )
104
179
180
+ R = SO3 .RPY (np .r_ [0.1 , 0.2 , 0.3 ], order = 'xyz' )
181
+ nt .assert_equal (len (R ), 1 )
182
+ array_compare (R , rpy2r ([0.1 , 0.2 , 0.3 ], order = 'xyz' ))
183
+ self .assertIsInstance (R , SO3 )
184
+
185
+ # matrix input
186
+
187
+ angles = np .array ([
188
+ [0.1 , 0.2 , 0.3 ],
189
+ [0.2 , 0.3 , 0.4 ],
190
+ [0.3 , 0.4 , 0.5 ],
191
+ [0.4 , 0.5 , 0.6 ]
192
+ ])
193
+ R = SO3 .RPY (angles , order = 'zyx' )
194
+ self .assertIsInstance (R , SO3 )
195
+ nt .assert_equal (len (R ), 4 )
196
+ for i in range (4 ):
197
+ array_compare (R [i ], rpy2r (angles [i ,:], order = 'zyx' ))
198
+
199
+ angles *= 10
200
+ R = SO3 .RPY (angles , unit = 'deg' , order = 'zyx' )
201
+ self .assertIsInstance (R , SO3 )
202
+ nt .assert_equal (len (R ), 4 )
203
+ for i in range (4 ):
204
+ array_compare (R [i ], rpy2r (angles [i ,:], unit = 'deg' , order = 'zyx' ))
205
+
206
+ def test_constructor_AngVec (self ):
105
207
# angvec
106
208
R = SO3 .AngVec (0.2 , [1 , 0 , 0 ])
107
209
nt .assert_equal (len (R ), 1 )
@@ -113,22 +215,7 @@ def test_constructor(self):
113
215
array_compare (R , roty (0.3 ))
114
216
self .assertIsInstance (R , SO3 )
115
217
116
- # OA
117
- R = SO3 .OA ([0 , 1 , 0 ], [0 , 0 , 1 ])
118
- nt .assert_equal (len (R ), 1 )
119
- array_compare (R , np .eye (3 ))
120
- self .assertIsInstance (R , SO3 )
121
-
122
- # random
123
- R = SO3 .Rand ()
124
- nt .assert_equal (len (R ), 1 )
125
- self .assertIsInstance (R , SO3 )
126
218
127
- # copy constructor
128
- R = SO3 .Rx (pi / 2 )
129
- R2 = SO3 (R )
130
- R = SO3 .Ry (pi / 2 )
131
- array_compare (R2 , rotx (pi / 2 ))
132
219
133
220
def test_shape (self ):
134
221
a = SO3 ()
0 commit comments