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

I'm using Instruments to try to determine if there are places in my application
We try to convert from string to Byte[] using the following Java code: String
I try to determine the right most nth bit set if (value & (1
I'm try to determine how to use the zip cmd line tool to move
I try to resolve the paths of shell links, which are contained in the
I'm try to determine how to setting up AWStats for multiple sites on the
i try to write my own control.But my control' html has problem: Look like
I try to debug my silverlight application that contain OpenFileDialog.ShowDialog() call - and i
im try to catch a fileupload from my Flashfile, this sends it with $_POST
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error

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.