Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 154711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:01:38+00:00 2026-05-11T10:01:38+00:00

I try to determine the angle from a point (n,m) to (0,0) . Without

  • 0

I try to determine the angle from a point (n,m) to (0,0). Without arctan2 being available, I’m running into the problem that m can be 0, which leads to a possible division by zero.

What would be an elegant, correct solution to tackling this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:01:38+00:00Added an answer on May 11, 2026 at 10:01 am

    don’t use the conventional quadrants, use the branch points defined by the lines y = +/- x, and use the 1st two steps of a CORDIC-like algorithm (e.g. rotate coordinates by a known angle and keep track of how much you’ve rotated):

    function atan2_substitute(x,y) {    double angle = 0;    if (x < y)    { angle = M_PI; x = -x; y = -y; }    // this guarantees that the angle is between -135 and +45 degrees     if (x < -y)    {      angle -= M_PI/2; tmp = x; x = -y; y = tmp;    }    // this guarantees that the angle is between -45 and +45     angle += atan(y/x);     if (angle > M_PI)       angle -= 2*M_PI;    // fails at 0,0; otherwise is accurate over the entire plane } 

    the reason for doing it this way is that atan() may be more likely to be accurate for ratios y/x between -1 and +1, than for ratios greater than 1. (though a good atan() algorithm would recognize this and take the reciprocal)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

from what i read i understand that iPhone can determine your location using Wi-Fi.
I ran into a problem today at work wherein I have a BindingGroup that
Is there a way to determine which OS is the browser being run on?
i'm try to determine the amount to scale down an image, which is in
I am running some tests to try and determine what distribution my data follows.
I am having to try to determine whether a date from a hidden field,
I have some code that uses ctypes to try to determine if the file
I have a problem to solve from SPOJ -like platform and I can't come
I try to determine the right most nth bit set if (value & (1
This returns an empty string when I try to determine the default text direction...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.