仮想計算機構

IT業界と無縁な派遣社員のブログ

楕円の速度ベクトル、加速度ベクトル

楕円



x=9\cos t\\
y=4\sin t

の速度ベクトル、加速度ベクトルのアニメーションを作る。

可視化に必要な関数を下記で定義する。

sage: t = var('t')
sage: x = 9*cos(t)
sage: y = 4*sin(t)
sage: vx,vy = x.derivative(),y.derivative()
sage: ax,ay = vx.derivative(),vy.derivative()

楕円そのものは parametric_plot を使う。

sage: parametric_plot((x,y),(0,2*pi))
Launched png viewer for Graphics object consisting of 1 graphics primitive

f:id:riverta1992:20201220202354p:plain

媒介変数 t0 から 2\pi まで 0.2 ずつ変化させる。

sage: l = [parametric_plot((x,y),(0,2*pi),xmin=-14,xmax=14,ymin=-7,ymax=7)+arrow2d((x(s),y(s)),(x(s)+vx(s),y(s)+vy(s)),xm
....: in=-14,xmax=14,ymin=-7,ymax=7,rgbcolor="red")+arrow2d((x(s),y(s)),(x(s)+ax(s),y(s)+ay(s)),xmin=-14,xmax=14,ymin=-7,
....: ymax=7,rgbcolor="green")+point2d((x(s),y(s)),size=90,xmin=-14,xmax=14,ymin=-7,ymax=7,rgbcolor="gray") for s in sxra
....: nge(0,2*pi,0.2)]
/opt/sagemath-9.2/src/bin/sage-ipython:1: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)
See http://trac.sagemath.org/5930 for details.
  #!/usr/bin/env sage-python
sage: animate(l)
Launched gif viewer for Animation with 32 frames

f:id:riverta1992:20201220202814g:plain

加速度ベクトルがつねに原点を指しています。