Page 2 of 2
Re: Help with calculating trajectory
Posted: Fri May 31, 2024 6:51 am
by pgimeno
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.
Re: Help with calculating trajectory
Posted: Fri May 31, 2024 12:57 pm
by RNavega
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.
That's cool!
betobala wrote: ↑Fri May 31, 2024 4:45 amI'm trying to invert the normal line, but i can not do it, do u have any tips to help me calculate that?
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
Posted: Fri May 31, 2024 6:51 pm
by betobala
RNavega wrote: ↑Fri May 31, 2024 12:57 pm
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.
That's cool!
betobala wrote: ↑Fri May 31, 2024 4:45 amI'm trying to invert the normal line, but i can not do it, do u have any tips to help me calculate that?
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).
I was missing this part "which will make it a vector starting from the origin of space (0, 0).", thanks
Re: Help with calculating trajectory
Posted: Mon Jul 08, 2024 2:19 pm
by RNavega
Any progress in your pool game? That last demo was cool, all it was missing was some jazzy music in the background