I am trying to do a simple reflection of a point entity off of an arbitrary surface that contains it. It doesn't have to be physically correct but essentially the goal is to do the following:

if (isOutsideOfContainer()) {
float2 container = getContainerNormal();
float2 newVelocity = f(velocity, container);

So essentially I am placing the out of bounds point on an edge of the container, getting the normal of the edge at that point on the container, and using that to calculate the new velocity vector.

How exactly do I do this?

I am doing this so that particles can "bounce" off of the edge of the screen as computationally cheaply as possible. Sometimes the screen will be a boring rectangle but other times it might be an iPhone X, or have half of its corners rounded. No-matter what the screen I want to properly simulate its bounce.



You must log in to answer this question.

Browse other questions tagged .