Jump to content
Sign in to follow this  
Prospero

A small plea to bis re the atan2 function

Recommended Posts

Hi all,

Wouldn't it be nice to have an atan2 function that can handle zero as the second argument (i.e. as the divisor). Most other languages seem to handle this, so I just thought I'd mention it. Would save on all those messy traps one has to put in.

Prospero

Share this post


Link to post
Share on other sites

Prospero, keep in mind you're doin' some pretty advanced/crazy stuff with OFP!  tounge.gif

I'm not saying "don't ask", but sometimes I worry you're abusing the poor OFP engine & pushing it beyond its capabilities.

Doolittle smile.gif

Share this post


Link to post
Share on other sites

Hey, all I'm asking for is an atan2 function that works "properly". Indeed, atan2 was originally conceived to solve two probs - namely quadrants and the divide-by-zero condition. What we have at the mo in OFP is a 50% solution.

I'm not being critical. I love OFP. But believe me, this has been pissing me off 'cos I've been trying to make a "framework" 6DOF non-linear flight-model script for chaps who want the VTOL thing. All the rotation maths is done with quaternions - and when you convert from quats to Euler angles, it really helps to have a "fully" working atan2 func.

Prospero

Edit: Also, can we pls have doubles too?

Share this post


Link to post
Share on other sites

why don't you write a single function yourself?

should be easy, just check 2nd operator == 0 and then see if first operator > or < 0.

then:</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_angle = [x,y] call MyAtan2<span id='postcolor'>

Share this post


Link to post
Share on other sites

jeeze i dont have the first clue what you guys are talking about. Although I have heard of the word "Tangent" yes, it is a little button on my algebra calculator tounge.gif but thats about it.

I need to get smarter...

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Prospero @ Jan. 21 2003,06:49)</td></tr><tr><td id="QUOTE">Wouldn't it be nice to have an atan2 function that can handle zero as the second argument (i.e. as the divisor). Most other languages seem to handle this, so I just thought I'd mention it.<span id='postcolor'>

Function atan2 can handle zero as second argument. What it cannot handle is zero as both arguments - which is consider undefined and returns error.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Suma @ Jan. 22 2003,08:15)</td></tr><tr><td id="QUOTE"></span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Prospero @ Jan. 21 2003,06:49)</td></tr><tr><td id="QUOTE">Wouldn't it be nice to have an atan2 function that can handle zero as the second argument (i.e. as the divisor). Most other languages seem to handle this, so I just thought I'd mention it.<span id='postcolor'>

Function atan2 can handle zero as second argument. What it cannot handle is zero as both arguments - which is consider undefined and returns error.<span id='postcolor'>

Yup, sorry, I'm wrong.

I was sticking a zero in as the numerator. Sorry Suma.

:tail between legs:

Prospero

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×