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 6737299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:13:58+00:00 2026-05-26T11:13:58+00:00

The problem I’m having is not finding the distance but finding the radians with

  • 0

The problem I’m having is not finding the distance but finding the radians with Atan() and converting it to degrees.

using System;
class Program
{
    static void Main()
    {
        double xCoord =0, yCoord=0 ;       
        //accessing methods
        getUserInput(ref xCoord, ref yCoord);
        CalulatePolarCoords(ref xCoord, ref yCoord);
        outputCords( ref xCoord,  ref yCoord);
        Console.ReadLine();
    }//End Main()

    static void getUserInput(ref double xc, ref double yc) 
    {
    //validating input
        do
        {
            Console.WriteLine(" please enter the x cororidnate must not equal 0 ");
            xc = double.Parse(Console.ReadLine());
            Console.WriteLine("please inter the y coordinate");
            yc = double.Parse(Console.ReadLine());
        if(xc <= 0)
    Console.WriteLine(" invalid input"); 
        }
        while (xc <= 0);
            Console.WriteLine(" thank you");

    }

   //calculating coords
    static void CalulatePolarCoords(ref double x , ref double y) 
    {
        double r;
        double q;
       r = x;
       q = y;
        r = Math.Sqrt((x*x) + (y*y));

        q = Math.Atan(x/y);

    x = r;
    y = q;
    }
    static void outputCords( ref double x, ref double y)
    {
        Console.WriteLine(" The polar cordinates are...");
        Console.WriteLine("distance from the Origin {0}",x);
        Console.WriteLine(" Angle (in degrees) {0}",y);
        Console.WriteLine(" press enter to continute");

    }
}//End class Program
  • 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. Editorial Team
    Editorial Team
    2026-05-26T11:13:58+00:00Added an answer on May 26, 2026 at 11:13 am

    You want to use Atan2 here.

    q = Math.Atan2(y, x);
    

    To convert to degrees multiply by 180/Math.PI.

    This will give you a result in the range -180 to 180. If you want it in the range 0 to 360 then you will have to shift any negative angles by 360.

    I also strongly recommend that you do not return your polar coordinates in the same parameters that you used to pass in cartesian coordinates. Make your function like this:

    static void CalculatePolarCoords(double x, double y, out double r, out double q)
    

    Your outputCoords method also uses ref parameters incorrectly. Only use ref parameters for values that are passed into a method, modified, and then need to be passed back to the caller.

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

Sidebar

Related Questions

Problem: I can set the exposureMode property of AVCaptureDevice, but it does not stay
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem: I need an array (datamember) in a parent class A. However, depending on
Problem One: </a> 19-10-2011, 04:49 PM </td> <td class=thread How to fetch the DATE
Problem: I have 2 classes, DB class and a User class, that will work
PROBLEM: I have a Child class which uses DataContractSerialization and raises a Changed event
Problem : Need onclick event to pause/unpause a Youtube video, but impossible to add
Problem: Visitors open the url website.com/?i=133r534|213213|12312312 but this url isn't valid anymore and they
Problem: I'm attempting to disable a radio button by using the code below. This
Problem I have a Silverlight 5 application using the treeview from the SDK. Now

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.