Method: PendulumAnimationDemo#showPhase

Defined in:
sample/demos-en/pendulum.rb,
sample/demos-jp/pendulum.rb

#showPhaseObject

Update the phase-space graph according to the current angle and the rate at which the angle is changing (the first derivative with respect to time.)



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'sample/demos-en/pendulum.rb', line 170

def showPhase
  unless @psw && @psh
    @psw = @k.width/2
    @psh = @k.height/2
  end
  @points << @theta + @psw << -20*@dTheta + @psh
  if @points.length > 100
    @points = @points[-100..-1]
  end
  (0...100).step(10){|i|
    first = - i
    last = 11 - i
    last = -1 if last >= 0
    next if first > last
    lst = @points[first..last]
    @graph[i].coords(lst) if lst && lst.length >= 4
  }
end