title: Python - Plotting velocity and acceleration vectors at certain points
body: <p>Here, i have a parametric equation.   </p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  from mpl_toolkits.mplot3d import Axes3D
  
  t = np.linspace(0,2*np.pi, 40)
  
  # Position Equation
  def rx(t):
      return t * np.cos(t)
  def ry(t):
      return t * np.sin(t)
  
  # Velocity Vectors
  def vx(t):
      return np.cos(t) - t*np.sin(t)
  def vy(t):
      return np.sin(t) + t*np.cos(t)
  
  # Acceleration Vectors
  def ax(t):
      return -2*np.sin(t) - t*np.cos(t)
  
  def ay(t):
      return 2*np.cos(t) - t*np.sin(t)
  
  fig = plt.figure()
  ax1 = fig.gca(projection='3d')
  
  z = t 
  ax1.plot(rx(z), ry(z), z)
  plt.xlim(-2*np.pi,2*np.pi)
  plt.ylim(-6,6)
  #ax1.legend() # no labels
  plt.show()
  </code></pre>
  
  <p>So i have this parametric equation that creates this graph.</p>
  
  <p><a href="https://i.stack.imgur.com/G0xyj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G0xyj.png" alt="![enter image description here"></a></p>
  
  <p>I have defined my velocity and acceleration parametric equations above in my code. </p>
  
  <p>What i am wanting to do is to plot the acceleration and velocity vectors in my position graph above at defined points. (Id est, t = pi/2, 3pi/2, 2pi)</p>
  
  <p>Something like this:</p>
  
  <p><a href="https://stackoverflow.com/questions/11140163/python-matplotlib-plotting-a-3d-cube-a-sphere-and-a-vector">Plotting a 3d cube, a sphere and a vector in Matplotlib</a></p>
  
  <p>but i want to do something more straight forward since i have to define each point t into two equations.</p>
  
  <p>Is such a thing possible? I can only find vector fields and what not.</p>
  
  <p>Something like this.
  <a href="https://i.stack.imgur.com/3Q1KX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Q1KX.jpg" alt="enter image description here"></a></p>
  
  <p>Thank you.</p>
  
  <p><strong>Edit Question</strong></p>
  
  <pre><code># t = pi/4 
  
  t_val_start_pi4 = np.pi/4
  vel_start_pi4 = [rx(t_val_start_pi4), ry(t_val_start_pi4), t_val_start_pi4]
  
  vel_end_pi4 = [rx(t_val_start_pi4 ) + vx(t_val_start_pi4 ), ry(t_val_start_pi4 )+vy(t_val_start_pi4 ), t_val_start_pi4 ]
  
  vel_vecs_pi4 = (t_val_start_pi4 , vel_end_pi4)
  
  vel_arrow_pi4 = Arrow3D(vel_vecs_pi4[0],vel_vecs_pi4[1], vel_vecs_pi4[2], mutation_scale=20, lw=1, arrowstyle="-|&gt;", color="b")
  
  axes.add_artist(vel_arrow_pi4)
  </code></pre>
  
  <p>It'll give me an error saying <code>Tuple out of index</code></p>