Last active
May 4, 2018 08:03
-
-
Save serguei-k/71495d0f881739dea82a9ec0e70d270f to your computer and use it in GitHub Desktop.
Spherical Coordinates Stereographic Projection Inverse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.api.OpenMaya as om | |
from math import * | |
def T(z): | |
return 0.5 * z | |
for i, p in enumerate(cmds.ls('unit.vtx[*]', fl=True)): | |
x, y, z = cmds.xform(p, q=True, t=True) | |
x = T(x) | |
y = T(y) | |
xprime = 2 * x / (1 + pow(x, 2) + pow(y, 2)) | |
yprime = 2 * y / (1 + pow(x, 2) + pow(y, 2)) | |
zprime = (-1 + pow(x, 2) + pow(y, 2)) / (1 + pow(x, 2) + pow(y, 2)) | |
proj = om.MVector(xprime, yprime, zprime) | |
cmds.xform('unit.vtx[{0}]'.format(i), t=proj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment