Example #1
0
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import matplotlib as mpl
import matplotlib.pyplot as plt
import rodrigues
import numpy as np
import math

fig = plt.figure()
ax = fig.gca(projection='3d')

ax.set_zlim(0,12)

norm = mpl.colors.Normalize(vmin=0,vmax=12)
cmap = plt.get_cmap("rainbow")
import drawfern
x,z = drawfern.fern(1000)
y = [0]*len(x)

for div in range(1,13):
	M = rodrigues.rrot(np.matrix([x,y,z]), np.matrix('0;1;2') / math.sqrt(5), math.pi*2*div/12)
	M = np.squeeze(np.asarray(M))
	ax.scatter(M[0],M[1],M[2], s=10, c=np.array([div]*len(x)), cmap=cmap, norm=norm)

ax.set_xlabel('X ')
ax.set_ylabel('Y ')
ax.set_zlabel('Z ')
plt.show()

Example #2
0
	K = 0.25
	a = 0.2
	if depth < 1: return
	area = depth**3*10
	for d in range(0,360*2,60):
		t = d * math.pi/180
		r = K * math.exp(t*a)
		m = np.matrix((r*math.cos(t), r*math.sin(t))).T
		for k in range(0,360,50):
			u = x+m[0]
			v = y+m[1]
			resX.append(float(u))
			resY.append(float(v))
			resZ.append(H-math.sqrt(u**2+v**2)+0.3)
			#c = ax.scatter(u,v, H-math.sqrt(u**2+v**2)+0.3,c=2, s=area, cmap=plt.get_cmap("Greens"), norm=mpl.colors.Normalize(vmin=0,vmax=3))
			m = Rot * m
			# x,y = u,v and go back

	return resX,resY,resZ
x,y,z=put2(0,0,2)

import rodrigues
    
ax.scatter(x,y,z, s=100, cmap=plt.get_cmap("Greens"), norm=mpl.colors.Normalize(vmin=0,vmax=3))
M = rodrigues.rrot(np.matrix([x,y,z]), np.matrix('1;1;1') / math.sqrt(3), math.pi)
M = np.squeeze(np.asarray(M))
#ax.scatter(x,y,z, s=100, cmap=plt.get_cmap("Greens"), norm=mpl.colors.Normalize(vmin=0,vmax=3))
ax.scatter(M[0],M[1],M[2], s=100, cmap=plt.get_cmap("Greens"), norm=mpl.colors.Normalize(vmin=0,vmax=3))

plt.show()