@@ -174,11 +174,11 @@ def rotate_arbitrary(v, double theta):
174
174
175
175
sage: rotate_arbitrary((1,2,3), -1).det()
176
176
1.0000000000000002
177
- sage: rotate_arbitrary((1,1,1), 2*pi/3) * vector(RDF, (1,2,3)) # rel tol 2e-15 # needs sage.symbolic
177
+ sage: rotate_arbitrary((1,1,1), 2*pi/3) * vector(RDF, (1,2,3)) # rel tol 2e-15 # needs sage.symbolic
178
178
(1.9999999999999996, 2.9999999999999996, 0.9999999999999999)
179
179
sage: rotate_arbitrary((1,2,3), 5) * vector(RDF, (1,2,3)) # rel tol 2e-15
180
180
(1.0000000000000002, 2.0, 3.000000000000001)
181
- sage: rotate_arbitrary((1,1,1), pi/7)^7 # rel tol 2e-15 # needs sage.symbolic
181
+ sage: rotate_arbitrary((1,1,1), pi/7)^7 # rel tol 2e-15 # needs sage.symbolic
182
182
[-0.33333333333333337 0.6666666666666671 0.6666666666666665]
183
183
[ 0.6666666666666665 -0.33333333333333337 0.6666666666666671]
184
184
[ 0.6666666666666671 0.6666666666666667 -0.33333333333333326]
@@ -194,7 +194,7 @@ def rotate_arbitrary(v, double theta):
194
194
195
195
Setup some variables::
196
196
197
- sage: vx,vy,vz,theta = var('x y z theta') # needs sage.symbolic
197
+ sage: vx,vy,vz,theta = var('x y z theta') # needs sage.symbolic
198
198
199
199
Symbolic rotation matrices about X and Y axis::
200
200
@@ -205,32 +205,32 @@ def rotate_arbitrary(v, double theta):
205
205
way to tell Maxima that `x^2+y^2+z^2=1` which would make for
206
206
a much cleaner calculation::
207
207
208
- sage: vy = sqrt(1-vx^2-vz^2) # needs sage.symbolic
208
+ sage: vy = sqrt(1-vx^2-vz^2) # needs sage.symbolic
209
209
210
210
Now we rotate about the `x`-axis so `v` is in the `xy`-plane::
211
211
212
- sage: t = arctan(vy/vz)+pi/2 # needs sage.symbolic
213
- sage: m = rotX(t) # needs sage.symbolic
214
- sage: new_y = vy*cos(t) - vz*sin(t) # needs sage.symbolic
212
+ sage: t = arctan(vy/vz)+pi/2 # needs sage.symbolic
213
+ sage: m = rotX(t) # needs sage.symbolic
214
+ sage: new_y = vy*cos(t) - vz*sin(t) # needs sage.symbolic
215
215
216
216
And rotate about the `z` axis so `v` lies on the `x` axis::
217
217
218
- sage: s = arctan(vx/new_y) + pi/2 # needs sage.symbolic
219
- sage: m = rotZ(s) * m # needs sage.symbolic
218
+ sage: s = arctan(vx/new_y) + pi/2 # needs sage.symbolic
219
+ sage: m = rotZ(s) * m # needs sage.symbolic
220
220
221
221
Rotating about `v` in our old system is the same as rotating
222
222
about the `x`-axis in the new::
223
223
224
- sage: m = rotX(theta) * m # needs sage.symbolic
224
+ sage: m = rotX(theta) * m # needs sage.symbolic
225
225
226
226
Do some simplifying here to avoid blow-up::
227
227
228
- sage: m = m.simplify_rational() # needs sage.symbolic
228
+ sage: m = m.simplify_rational() # needs sage.symbolic
229
229
230
230
Now go back to the original coordinate system::
231
231
232
- sage: m = rotZ(-s) * m # needs sage.symbolic
233
- sage: m = rotX(-t) * m # needs sage.symbolic
232
+ sage: m = rotZ(-s) * m # needs sage.symbolic
233
+ sage: m = rotX(-t) * m # needs sage.symbolic
234
234
235
235
And simplify every single entry (which is more effective that simplify
236
236
the whole matrix like above)::
0 commit comments