Numerical sphere-plane collision resolve

159 Views Asked by At

I want to write a c++ program that will calculate collision between sphere and plane.

The rule is that the angle of the falling object equals to angle of reflection.

What do I have for sphere:

//sphere coordinates and radius
float x;
float y;
float z;
float r;
//sphere velocity vector projections
float vx;
float vy;
float vz;

Plane is described by plane equation coefficients:

float A;
float B;
float C;
float D;

With sphere-plane collision detection I have no problem. But how to find velocity after collision?

enter image description here

What did I find:

Angle between vector $\vec{(x,y,z)}$ and plane $Ax+By+Cz+D=0$:

$$φ = arcsin(\frac{| A · x + B · y + C · z |}{ \sqrt{A^2 + B^2 + C^2} · \sqrt{x^2 + y^2 + z^2}})$$

So, ultimately I need to calculate updated values for vx vy vz.

1

There are 1 best solutions below

1
On

The velocity vector after the collision is a vector that is reflected around the contact plane. To reflect around a plane with normal $\bf n$, multiply the speed vector by the matrix $I-\bf 2nn^T$. Are you familiar with matrix and vector notation?