Data Realms Fan Forums http://45.55.195.193/ |
|
Radian measurements http://45.55.195.193/viewtopic.php?f=73&t=15280 |
Page 1 of 1 |
Author: | Duh102 [ Tue Jun 09, 2009 7:28 pm ] |
Post subject: | Radian measurements |
Does CC use -Pi to Pi (or -2Pi to 2Pi) for radian measurements? Or does it use continuous scale from -inf to inf? Right now, I've got a script that measures the angle of incidence and sees if a particle's heading is going within Pi/2 of a normal, but for some reason it does not work for angles going about Pi/3 from normal in the first quadrant. Here's my detection script. Code: local normal = math.atan2(-((self.Pos.Y) - particle.Pos.Y), (self.Pos.X - particle.Pos.X)); local particleHeading = math.atan2(-(particle.Vel.Y), (particle.Vel.X)); if math.abs(math.pi + normal - (particleHeading + math.pi)) < (math.pi/2) then I thought it was -Pi to Pi, which is why I added math.pi to both sides to make both positive measurements. |
Author: | Grif [ Tue Jun 09, 2009 7:29 pm ] |
Post subject: | Re: Radian measurements |
It's 2pi is one full circle. |
Author: | Duh102 [ Tue Jun 09, 2009 7:32 pm ] |
Post subject: | Re: Radian measurements |
Yeah, but it goes negative. So does it loop over again (-2pi to 2pi) or is it continuous (-infpi to infpi)? |
Author: | Grif [ Tue Jun 09, 2009 7:35 pm ] |
Post subject: | Re: Radian measurements |
2pi is one full circle, -2pi is also one full circle. |
Author: | Duh102 [ Tue Jun 09, 2009 7:37 pm ] |
Post subject: | Re: Radian measurements |
But, when you reach -2pi, does it loop over again to 0, or does it continue on to -2.1pi, -2.5 pi, and so on? EDIT: What I'm getting at here is, should I modulo my angles by 2pi before I test them or not. |
Author: | Grif [ Tue Jun 09, 2009 7:44 pm ] |
Post subject: | Re: Radian measurements |
I am fairly sure that it loops back to 0. Try printing on an object set to constantly rotate. |
Author: | piipu [ Tue Jun 09, 2009 9:30 pm ] |
Post subject: | Re: Radian measurements |
It goes from -pi to pi, yes. I'm too tired to think what's wrong with the code. |
Author: | Duh102 [ Tue Jun 09, 2009 11:18 pm ] |
Post subject: | Re: Radian measurements |
I did some more testing, and it looks like the problem is right around 0 rads. Any more than a few tenths of a rad more or less and it works fine. I'll see if I can fiddle with it some more. EDIT: Fixed with adding 3/2pi instead of pi. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |