예제 #1
0
파일: driver.py 프로젝트: msebaa/pydec
# decompose 4 random 1-cochains
for i in range(4):
    omega = sc.get_cochain(1)
    omega.v[:] = rand(*omega.v.shape)

    (beta, gamma, h) = hodge_decomposition(omega)

    h = h.v
    for v in H:
        h -= inner(v, h) * v
    h /= norm(h)

    H.append(h)

H = ortho(vstack(H))

# plot the results
from pylab import figure, title, quiver, axis, show
from pydec import triplot, simplex_quivers

for n, h in enumerate(H):
    figure()
    title('Harmonic 1-cochain #%d' % n)
    triplot(vertices, triangles)

    bases, dirs = simplex_quivers(sc, h)
    quiver(bases[:, 0], bases[:, 1], dirs[:, 0], dirs[:, 1])
    axis('equal')

show()
예제 #2
0
#print 'norm(b2.T * h)', norm(b2.T * h)  #should be small

# plot the results
from pylab import figure, title, plot, axis, xlim, ylim, show
from pydec import triplot, lineplot

# Nodes of the Rips complex
figure()
plot(pts[:, 0], pts[:, 1], 'ko')
axis('off')
title('Nodes of the Complex')

# Rips complex (2d triangle mesh)
figure()
title('The Rips Complex')
triplot(pts, simplices[2])

# Harmonic 1-chain
figure()
title('Harmonic 1-chain of the Rips complex')
lineplot(pts, simplices[1], linewidths=(15 * abs(h)).clip(1, 15))

# fiddle with the figures
for i in range(1, 4):
    figure(i)
    axis('off')
    axis('equal')
    xlim(-0.1, 1.1)
    ylim(-0.1, 1.1)

show()
예제 #3
0

# plot the results
from pylab import figure, title, plot, axis, xlim, ylim, show
from pydec import triplot, lineplot

# Nodes of the Rips complex
figure()
plot(pts[:,0],pts[:,1],'ko')
axis('off')
title('Nodes of the Complex')

# Rips complex (2d triangle mesh)
figure()
title('The Rips Complex')
triplot(pts,simplices[2]) 

# Harmonic 1-chain
figure()
title('Harmonic 1-chain of the Rips complex')
lineplot(pts,simplices[1],linewidths=(15*abs(h)).clip(1,15) ) 

# fiddle with the figures
for i in range(1,4):
    figure(i)
    axis('off')
    axis('equal')
    xlim(-0.1,1.1)
    ylim(-0.1,1.1)

show()
예제 #4
0
for i in range(4):
    omega = sc.get_cochain(1)
    omega.v[:] = rand(*omega.v.shape)

    (beta,gamma,h) = hodge_decomposition(omega)

    h = h.v
    for v in H:
        h -= inner(v,h) * v
    h /= norm(h)

    H.append(h)

H = ortho(vstack(H))

# plot the results
from pylab import figure, title, quiver, axis, show
from pydec import triplot, simplex_quivers

for n,h in enumerate(H):
    figure()
    title('Harmonic 1-cochain #%d' % n)
    triplot(vertices,triangles) 
    
    bases,dirs = simplex_quivers(sc,h)
    quiver(bases[:,0],bases[:,1],dirs[:,0],dirs[:,1])
    axis('equal')

show()