Find Source & Learn ArcTan2 for Degrees Calculation

  • Thread starter Sky Scripter
  • Start date
  • Tags
    Function
In summary, the conversation discusses finding the source for the ArcTan2 function, which calculates the degrees in a line using the arctangent function. The conversation also includes a code example of how to program the function in various programming languages.
  • #1
Sky Scripter
5
0
Anyone have the Source for ArcTan2 ( x, y: Extended);
I Can have it in most any programming language, if you can show me how it works.. then that would be great too.

And just so you know I am trying to calculate the Degrees in a line using ArcTan2;

for example:

Degrees := (ArcTan2(MiddleX - X, MiddleY - Y));

MiddleX := Center of the Circle (X Axis);
MiddleY := Center of the Circle (Y Axis);

X := Being the Point i want to calculate (X Axis)
Y := Being the Point i want to calculate (Y Axis)

Thanks :D
 
Last edited:
Technology news on Phys.org
  • #2
I don't know what extended means, but if you want to program the arctan(x) function, you might want to use the taylor series of the function. Its the summation of [tex]\frac{x^n}{n!}f^n(x)[/tex], where [tex]f^n(x)[/tex] is the nth derivative of the function youre finding the series of.

If that's too much of a hassle, just look up the series online. In your case, replace x by y/x (as [tex]tan\theta=\frac{y}{x}[/tex] which gives [tex]\theta=tan^{-1}\frac{y}{x}[/tex].
 
  • #3
nvm found source :)

thanks though...

Code:
function ArcTan(x: Extended): Extended;
var
  i: Integer;
begin
  if x > 1.0 then
  begin
    Result := Pi / 2 - ArcTan(1 / x);
  end else
  begin
    for i := 0 to 200 do
    begin
      Result := Result + ((Pow((-1), i) * Pow(x, (2 * i + 1))) / (2 * i + 1))
    end;
  end;
   while Result > 360 do Result := Result - 360;
   while Result < 0 do result := result + 360;
end;

function ArcTan2(y, x: Extended): Extended;
var
   A1: extended;
begin
  A1 := Pi / 180;
  
  if (y = 0.0) and (x < 0.0) then Result := A1 * 180;
  if (y = 0.0) and (x > 0.0) then Result := 0.0;
  if (x = 0.0) and (y < 0.0) then Result := A1 * 270;
  if (x = 0.0) and (y > 0.0) then Result := A1 * 90;
  if (Result = 0.0) and (x <> 0.0) then if (Abs(y) / Abs(x) = 1.0) then
    begin
      if (y > 0.0) and (x > 0.0) then Result := A1 * 45;
      if (y > 0.0) and (x < 0.0) then Result := A1 * 135.0;
      if (y < 0.0) and (x < 0.0) then Result := A1 * 225.0;
      if (y < 0.0) and (x > 0.0) then Result := A1 * 315.0;
    end;
  if Result = 0 then
  begin
    Result := ArcTan(Abs(-y) / Abs(x));
    if (y > 0.0) and (x < 0.0) then Result := Result + A1 * 90.0;
    if (y < 0.0) and (x < 0.0) then Result := Result + A1 * 180.0;
    if (y < 0.0) and (x > 0.0) then Result := Result + A1 * 270.0;
  end;
end;
 

Related to Find Source & Learn ArcTan2 for Degrees Calculation

1. What is the purpose of finding the source and learning ArcTan2 for degrees calculation?

The purpose of finding the source and learning ArcTan2 for degrees calculation is to accurately determine the angle of a given point in a coordinate system. This can be useful in various fields such as mathematics, physics, and engineering.

2. What is ArcTan2 and why is it used for degrees calculation?

ArcTan2 is a mathematical function that calculates the inverse tangent of two numbers, usually denoted as atan2(y,x). It is used for degrees calculation because it can handle all possible cases of x and y values, unlike other trigonometric functions which have limitations.

3. How do I find the source of ArcTan2 for degrees calculation?

The source of ArcTan2 for degrees calculation can be found in various programming languages, such as C++, Java, and Python. It is also included in most scientific calculators. You can also find the source code online or in mathematical textbooks.

4. Can I use ArcTan2 for degrees calculation in different coordinate systems?

Yes, ArcTan2 can be used in various coordinate systems, such as Cartesian, polar, and cylindrical. However, it is important to make sure that the input values are in the correct format for the chosen coordinate system.

5. What are the advantages of using ArcTan2 for degrees calculation?

One of the main advantages of using ArcTan2 for degrees calculation is its ability to handle all possible cases, making it more accurate than other trigonometric functions. It also has a wider range of input values, making it suitable for various applications.

Similar threads

  • Programming and Computer Science
Replies
2
Views
1K
Replies
2
Views
695
  • Calculus and Beyond Homework Help
Replies
8
Views
645
  • Precalculus Mathematics Homework Help
Replies
5
Views
1K
Replies
2
Views
382
  • Introductory Physics Homework Help
Replies
11
Views
1K
  • Programming and Computer Science
Replies
2
Views
924
Replies
63
Views
3K
  • Calculus and Beyond Homework Help
Replies
3
Views
607
  • Programming and Computer Science
Replies
12
Views
1K
Back
Top