Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualrip-off

Posted 16 July 2012 - 07:14 AM

I have written some lines of code that allows me to accelerate a user controlled cue ball. These lines of code has to do with Android and it's accelerometer. Now, ignore the Android. I am on my Android phone typing all of this.

Our main point of interest is how I should write the code that will give the ball that is hit by the cue ball its collision response; A feedback after the cue ball hits the targeted ball. All balls mentioned do not have mass, are not affected by gravity, and have the same radius/diameter/rigid body.

My little idea was formed by relying on Math.Alan2(), which I can use to translate Cartesian coordinates (the coordinates we normally associate with (x, y)) to polar coordinates (the line of collision P, the normal of the line N). From that static method, I can obtain the Theta value. Then I continue onwards by doing sine and cosine on the Theta.

What I got confused with, is how should I calculate the new velocity on the line of collision after I have gotten the the sine and cosine of Theta for the targeted ball? And how does that integrates fully with the aforementioned accelerometer, which I am able to get the cue ball's acceleration?

If anyone can enlighten me, I will be truly grateful. Thanks in advance.

#2tom_mai78101

Posted 16 July 2012 - 06:44 AM

I have written some lines of code that allows me to accelerate a user controlled cue ball. These lines of code has to do with Android and it's accelerometer. Now, ignore the Android. I am on my Android phone typing all of this.

Our main point of interest is how I should write the code that will give the ball that is hit by the cue ball its collision response; A feedback after the cue ball hits the targeted ball. All balls mentioned do not have mass, are not affected by gravity, and have the same radius/diameter/rigid body.

My little idea was formed by relying on Math.Alan2(), which I can use to translate Cartesian coordinates (the coordinates we normally associate with (x, y)) to polar coordinates (the line of collision P, the normal of the line N). From that static method, I can obtain the Theta value. Then I continue onwards by doing sine and cosine on the Theta.

What I got confused with, is how should I calculate the new velocity on the line of collision after I have gotten the the sine and cosine of Theta for the targeted ball? And how does that integrates fully with the aforementioned accelerometer, which I am able to get the cue ball's acceleration?

If anyone can enlighten me, I will be truly grateful. Thanks in advance.

#1tom_mai78101

Posted 15 July 2012 - 12:20 PM

I have written some lines of code that allows me to accelerate a user controlled cue ball. These lines of code has to do with Android and it's accelerometer. Now, ignore the Android. I am on my Android phone typing all of this.

Our main point of interest is how I should write the code that will give the ball that is hit by the cue ball its collision response; A feedback after the cue ball hits the targeted ball. All balls mentioned do not have mass, are not affected by gravity, and have the same radius/diameter/rigid body.

My little idea was formed by relying on Math.Alan2(), which I can use to translate Cartesian coordinates (the coordinates we normally associate with (x, y)) to polar coordinates (the line of collision P, the normal of the line N). From that static method, I can obtain the Theta value. Then I continue onwards by doing sine and cosine on the Theta.

What I got confused with, is how should I calculate the new velocity on the line of collision after I have gotten the the sine and cosine of Theta for the targeted ball? And how does that integrates fully with the aforementioned accelerometer, which I am able to get the cue ball's acceleration?

If anyone can enlighten me, I will be truly grateful. Thanks in advance.

PARTNERS