Skip to content

Instantly share code, notes, and snippets.

@apertureless
Created June 2, 2015 09:29
Show Gist options
  • Save apertureless/ca1ac6b9317edd7a095c to your computer and use it in GitHub Desktop.
Save apertureless/ca1ac6b9317edd7a095c to your computer and use it in GitHub Desktop.
ball yo
import bpy
import math
# Variablen
durchmesser = 0.25 #object.dimensions[0]
höhe = 1.7
wurfgeschwindigkeit = 3
g = 9.81
# 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öhe
object.location[0] = richtung
anim.keyframe_insert(type='Location')
zeit = math.sqrt(höhe * 2 / g)
frame += zeit * 24
scene.frame_current = frame
richtung += zeit * wurfgeschwindigkeit
object.location[2] = durchmesser / 2
object.location[0] = richtung
anim.keyframe_insert(type='Location')
höhe = höhe * 0.77
wurfgeschwindigkeit = wurfgeschwindigkeit * 0.85
zeit = math.sqrt(höhe * 2 / g)
richtung += zeit * wurfgeschwindigkeit
frame += zeit * 24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment