DasBabyPixel / Orbits

0 stars 1 forks source link

Ball mit Strecke kollision #1

Open DasBabyPixel opened 1 year ago

IamusingGitHubforschool commented 1 year ago

https://stackoverflow.com/questions/61272597/calculate-the-bouncing-angle-for-a-ball-point

https://stackoverflow.com/questions/27599173/computing-collision-angles

Nibelcole commented 1 year ago

Erklärungen zu den Variablen: w1/w2: Punkte der Wand xp/yp: X-Position bzw. Y-Position

b: Ball(vektor) w: Wand(vektor) xv/yv: X- bzw. Y-Wert des jew. Vektors vom jew. Objekt fx/fy: X- bzw. Y-Wert des finalen Ballvektors

Formeln: w.xv = w2.xp-w1.xp w.yv = w2.yp-w1.yp nx = (-w.yv / sqrt(w.xv w.xv + w.yv w.yv)) ny = (w.xv/ sqrt(w.xv w.xv+ w.yv w.yv)) fx= - (2 (nx b.xv+ ny b.yv) nx - b.xv) fy= - (2 (nx b.xv + ny b.yv) ny - b.yv)

Nibelcole commented 1 year ago

Zum Berechnen des Abstandes eines Balls von der Wand (a und b sind Punkte der Wand, k ist die Postion des Balls, h ist der Abstand zur Wand): Image