View unanswered posts | View active topics It is currently Wed Apr 24, 2024 3:16 pm



Reply to topic  [ 8 posts ] 
 Radian measurements 
Author Message
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post 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.


Tue Jun 09, 2009 7:28 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Radian measurements
It's 2pi is one full circle.


Tue Jun 09, 2009 7:29 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Radian measurements
Yeah, but it goes negative. So does it loop over again (-2pi to 2pi) or is it continuous (-infpi to infpi)?


Tue Jun 09, 2009 7:32 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Radian measurements
2pi is one full circle, -2pi is also one full circle.


Tue Jun 09, 2009 7:35 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post 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.


Tue Jun 09, 2009 7:37 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Radian measurements
I am fairly sure that it loops back to 0. Try printing on an object set to constantly rotate.


Tue Jun 09, 2009 7:44 pm
Profile
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: Radian measurements
It goes from -pi to pi, yes. I'm too tired to think what's wrong with the code.


Tue Jun 09, 2009 9:30 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post 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.


Tue Jun 09, 2009 11:18 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.041s | 15 Queries | GZIP : Off ]