Skip to content

Instantly share code, notes, and snippets.

@apertureless
Last active August 29, 2015 14:19
Show Gist options
  • Save apertureless/f7ea7a17814fab475c59 to your computer and use it in GitHub Desktop.
Save apertureless/f7ea7a17814fab475c59 to your computer and use it in GitHub Desktop.
Basketball Bounce animation script
import bpy
import math
# Variablen
d = 0.25 # Durchmesser
h = 1.7 # Hoehe
v = 0.8 # Geschwindigkeit
g = 9.81 # Erdanziehung
# Der Basketball trifft (boinks / 2) mal auf den Boden auf
# Vergleiche die Abbildung in der Aufgabe
boinks = 9
# Ein wenig Schreibarbeit sparen
scene = bpy.context.scene
object = bpy.context.object
anim = bpy.ops.anim
# Vorbereitung...
richtung = 0
frame = 1
# Interpolation
for x in range(1, boinks + 1):
# Berechnung fuer die Keys
scene.frame_current = frame
object.location[2] = h
object.location[0] = richtung
anim.keyframe_insert(type='Location')
t = math.sqrt(h * 2 / g)
frame += t * 24
scene.frame_current = frame
richtung += t * v
object.location[2] = d / 2
object.location[0] = richtung
anim.keyframe_insert(type='Location')
h = h * 0.77
wurfgeschwindigkeit = v * 0.85
t = math.sqrt(h * 2 / g)
richtung += t * v
frame += t * 24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment