Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nathanmsmith
Created November 9, 2017 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanmsmith/8d7f672346f2a990d60a72fc7af1d878 to your computer and use it in GitHub Desktop.
Save nathanmsmith/8d7f672346f2a990d60a72fc7af1d878 to your computer and use it in GitHub Desktop.
174eyyyyyy
import numpy as np
np.set_printoptions(formatter={'float': lambda x: "{0:0.3f}".format(x)})
cam = np.matrix() # put cam matrix here
wcs = np.matrix([[3, 0, -2, 1],
[2, 0, -1, 5],
[1, -3, 2, -1],
[1, 1, 1, 1]])
mproj = np.matrix() # put m_proj matrix here
vp = np.matrix() # put viewport matrix here
vcs = cam * wcs
print("M_vcs:")
print(vcs)
print("\n")
ccs = mproj * vcs
print("M_ccs:")
print(ccs)
print("\n")
ndcs = 1 / ccs[3, 3] * ccs
print("M_ndcs:")
print(ndcs)
print("\n")
dcs = vp * ndcs
print("M_dcs:")
print(dcs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment