Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from numpy import cos, sin, array
- from math import pi
- # polar angle (down from z-axis)
- theta = pi/2
- # azimuthal angle (off the x axis)
- phi = pi/2
- # step 1: to get the desired theta, rotate about the y-axis by theta (not sure if this is exactly what the want. if not, just use Rx)
- Ry = array([
- [cos(theta), 0, sin(theta)],
- [0, 1, 0],
- [-sin(theta), 0, cos(theta)]
- ])
- # Rx = array([
- # [1, 0, 0],
- # [0, cos(theta), -sin(theta)],
- # [0, sin(theta), cos(theta)]
- # ]).T
- # step 2: to get the desired phi, rotate about the z-axis by phi
- Rz = array([
- [cos(phi), -sin(phi), 0],
- [sin(phi), cos(phi), 0],
- [0, 0, 1],
- ])
- # start with a vector along the positive z direction
- vec = array([0,0,1])
- print(Rz.dot(Ry.dot(vec)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement