The double radius ball is in fact what is called the Minkowski addition, in this case of two circles. It's a technique often used to calculate and resolve complex collisions, because it turns the collision between two bodies into the collision between a point and a body. The point turns into a line as it moves, and it's easier to calculate the intersection between a line and a shape than between two shapes.
That approach will work just fine.
Help with calculating trajectory
Re: Help with calculating trajectory
That's cool!pgimeno wrote: ↑Fri May 31, 2024 6:51 am The double radius ball is in fact what is called the Minkowski addition, in this case of two circles. It's a technique often used to calculate and resolve complex collisions, because it turns the collision between two bodies into the collision between a point and a body. The point turns into a line as it moves, and it's easier to calculate the intersection between a line and a shape than between two shapes.
That approach will work just fine.
You have that line segment that goes from the picked point on the imaginary green circle to the center of the colorful ball. You can turn it into a vector by subtracting the desired starting point (the position of the colorful ball center) from both points of the segment --the picked point position and the colorful ball center itself-- which will make it a vector starting from the origin of space (0, 0).
From there, you can normalize it so the direction stays the same but its length is scaled to 1, AKA a unit vector, whose direction happens to be the surface normal of the colorful ball where it's going to be bumped.
You can use that then to reflect the white ball, and if you negate that unit vector (negate its X and Y components), it'll flip in the other direction and can be used as the direction of the colorful ball after it's bumped by the white ball.
Edit: that is, if the components of the normal are (normalX, normalY) then you flip it by using (-normalX, -normalY). This only works if it's really a vector (it starts from the origin of space).
Re: Help with calculating trajectory
I was missing this part "which will make it a vector starting from the origin of space (0, 0).", thanksRNavega wrote: ↑Fri May 31, 2024 12:57 pmThat's cool!pgimeno wrote: ↑Fri May 31, 2024 6:51 am The double radius ball is in fact what is called the Minkowski addition, in this case of two circles. It's a technique often used to calculate and resolve complex collisions, because it turns the collision between two bodies into the collision between a point and a body. The point turns into a line as it moves, and it's easier to calculate the intersection between a line and a shape than between two shapes.
That approach will work just fine.
You have that line segment that goes from the picked point on the imaginary green circle to the center of the colorful ball. You can turn it into a vector by subtracting the desired starting point (the position of the colorful ball center) from both points of the segment --the picked point position and the colorful ball center itself-- which will make it a vector starting from the origin of space (0, 0).
From there, you can normalize it so the direction stays the same but its length is scaled to 1, AKA a unit vector, whose direction happens to be the surface normal of the colorful ball where it's going to be bumped.
You can use that then to reflect the white ball, and if you negate that unit vector (negate its X and Y components), it'll flip in the other direction and can be used as the direction of the colorful ball after it's bumped by the white ball.
Edit: that is, if the components of the normal are (normalX, normalY) then you flip it by using (-normalX, -normalY). This only works if it's really a vector (it starts from the origin of space).
Re: Help with calculating trajectory
Any progress in your pool game? That last demo was cool, all it was missing was some jazzy music in the backgroundbetobala wrote: ↑Thu May 30, 2024 3:08 am My goal is to do something like this: https://imgur.com/a/o4HaceP
Who is online
Users browsing this forum: No registered users and 3 guests