def get_position(self, delta):
# Increment elapsed time and compute the current velocity after a
# decay of the initial velocity.
self._elapsed += delta
current_velocity = self._velocity*math.pow(self._decay, self._elapsed)
self._position += current_velocity*delta
# Make sure the position stays within values that range from 0 to <10.
self._position = math.fmod(self._position, 10.0)
if self._position < 0.0:
self._position += 10.0
return self._position
# Initialize NeoPixels and accelerometer.
评论列表
文章目录