SHARE
TWEET

Untitled

a guest Feb 17th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     # intialize the gradient
  2.     gradient = np.zeros(v.shape)
  3.    
  4.     # TODO: iterate over all triangles and sum up the vertices gradients
  5.     for i in range(0, len(f)):
  6.         point = v[f[i]]
  7.         e0 = v[f[i][0]]
  8.         e1 = v[f[i][1]]
  9.         e2 = v[f[i][2]]
  10.         a = e0 - e1
  11.         b = e2 - e0
  12.         c = e1 - e2
  13.         orthe0 = np.cross(a,b)/np.linalg.norm(np.cross(a,b))
  14.         gradient[f[i][0]] = gradient[f[i][0]] + np.cross(c,orthe0)
  15.         orthe1 = np.cross(c,a)/np.linalg.norm(np.cross(c,a))
  16.         gradient[f[i][1]] = gradient[f[i][1]] + np.cross(b,orthe1)
  17.         orthe2 = np.cross(b,c)/np.linalg.norm(np.cross(b,c))
  18.         gradient[f[i][2]] = gradient[f[i][2]] + np.cross(a,orthe2)
  19.  
  20.  
  21.     return gradient
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top