def to_varifold(self, q) :
# Compute edges's vertices
a = q[self.connectivity[:,0]]
b = q[self.connectivity[:,1]]
c = q[self.connectivity[:,2]]
# A surface is represented as a sum of dirac, one for each triangle
x = .33333333 * (a + b + c) # Mean
# Cross product
ab = (b-a).dimshuffle(0, 1, 'x')
ac = (c-a).dimshuffle(0, 'x', 1)
t = (ab * ac).reshape((self.connectivity.shape[0], 9))
cp = t.dot( np.array( [
[0., 0., 0., 0., 0., 1., 0., -1., 0.],
[0., 0., -1., 0., 0., 0., 1., 0., 0.],
[0., 1., 0., -1., 0., 0., 0., 0., 0.]
]
).T)
mu = T.sqrt( (cp**2).sum(1) ) # Length
u = ( cp / mu.dimshuffle(0,'x')) # Normal direction
mu = T.cast(.5*mu, dtype=config.floatX)
u = T.cast(u, dtype=config.floatX)
return (x, mu, u)
评论列表
文章目录