SynthMaker

circle/triangle bouncing ball

Archive · 2012 4 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

philter5 ·

hey guys, i need your help. i know it´s just some simple math but i don´t get it. in the osm there is a circle with a ball bouncing in it. how can i compute that the bouncing area would be circular (like the white outline) and not the view area? same for the triangle. i thought about using a get pixel at to check for the white outline and then flip the counter, but that´s not a good way i think now hehe... some tips are very appreciated

philter

infuzion ·

There is an XY pad that uses a circle on the forum IIRC.

oddson ·

philter5 wrote: how can i compute that the bouncing area would be circular (like the white outline)

Pythagoras?

x^2+y^2 = r^2

When the sum of x and y coordinates squared is equal to the radius squared you're on the edge so reflect.

(But you'll have to adjust for the circle not being at the origin of the coordinate system first.)

If you're going to reflect with incidence=reflection you'll also need to calculate slope of the 'wall' at the point of reflection...

I'd try to offer suggestions based on your OSM but frankly it's a bit of a mess and it looks like it would take me hours to figure out how what you have so far works.

oddson ·

I just tried to make a bouncing particle bounded in a circle that reflects off the interior surface in the expected manner (angle of incidence = angle of reflection) and it quickly got more complicated than I was willing to pursue.

I was planning to use a 'momentum' vector that consists of delta-x and delta-y components that is recalculated after each collision and then apply these to the previous location of the particle.

Problems:

If you're using discrete steps you'll need an inequality to judge when you've collided. But that means you're already past the boundary when you detect the collision and there will be some inaccuracy as a result (or a lot of very complex calculations to compensate)

You need to estimate the slope of the boundary at the estimated point of collision and use that as the angle for the reflection... so you need to rotate the vector that defines the boundary point relative to the circle origin by 90 degrees.

Then you still need to calculate the reflection of the momentum... I think that's done with:

x' = x*cos(2*Theta) + y*sin(2Theta) y' = x*sin(2*Theta) - y*cos(2Theta)

...where Theta is the angle of the reflecting surface

Doing all this with green-math in SynthMaker is very messy and time consuming.

...anyway, I'm either way off base or it's way too much work for me today.

Either way... good luck 😇

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.