How to represent computer code correctly
You should represent the computer code using the correct tags when you write a post about the computer science. (more…)
View On WordPress
seen from Australia

seen from Malaysia
seen from United States
seen from United States

seen from Mexico

seen from United States
seen from Canada
seen from United States
seen from United States

seen from United States
seen from United States
seen from United States

seen from Germany
seen from Malaysia
seen from United States

seen from United States
seen from United States
seen from United States
seen from China

seen from United States
How to represent computer code correctly
You should represent the computer code using the correct tags when you write a post about the computer science. (more…)
View On WordPress
These are the functions I'm using to rotate 3-dimensional co-ordinates, taken from here and here
I kind of suspect the source of all the strange warping is in there somewhere.
import math def cart_to_polar(xyz): x, y, z = xyz x = float(x); y = float(y); z = float(z) r = (x**2 + y**2 + z**2) ** 0.5 if r == 0: # to avoid division by zero return (0,0,0) phi = math.acos(z / r) theta = math.atan2(y, x) return (r, theta, phi) def polar_to_cart(r, theta, phi): x = r * math.cos(theta) * math.sin(phi) y = r * math.sin(theta) * math.sin(phi) z = r * math.cos(phi) return (x, y, z) def rotate(xyz, dtheta, dphi): r, theta, phi = cart_to_polar(xyz) return polar_to_cart(r, theta + dtheta, phi + dphi)