In [1]:
import k3d
import numpy as np
g = 9.81
v0 = 24
alpha = np.radians(45)
plot = k3d.plot()
for alpha in np.linspace(1,89,15):
alpha = np.radians(alpha)
t_end = 2*v0*np.sin(alpha)/g
t = np.linspace(0,t_end,100)
# note .T at the end, k3d takes data (x1,y1,z1),(x2,y2,z2)...
traj3d = np.stack([ v0*t*np.cos(alpha), \
20*alpha+np.zeros_like(t), \
v0*t*np.sin(alpha)-g*t**2/2 ]).T.astype(np.float32)
plt_traj = k3d.line(traj3d)
plt_text = k3d.text('h_{max}', \
position=[np.cos(alpha)*t_end*v0/2, 20*alpha, (v0*np.sin(alpha))**2/(2*g)],\
color=0xff0000, size=1)
plt_text2d = k3d.text2d(r'\text{ballistic trajectory: } h=v_0 t \sin \alpha - \frac{g t^2}{2}', \
position=[0.0, 0.0], color=0x0000ff, size=1)
plt_texture_text = k3d.texture_text('START', position=[0, 0, 0],\
font_face='Calibri', color=255, size=2)
plot += plt_text
plot += plt_text2d
plot += plt_texture_text
plot += plt_traj
plot.display()