Home  |  Delphi .net Home  |  System.Math  |  ATan2 Method
ATan2  
Method  
Gets the angle whose Tangent is the quotient of the given numbers
Math Class
System NameSpace
CF1.  Function ATan2 ( Y:DoubleY : Double; X : Double; ) : Double; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns the ArcTangent (ATan) value in radians of Y/X.
 
PI Radians = 180 degrees
Notes
Static methods are not methods of an object - they are simply class functions or procedures available at any time.
Microsoft MSDN Links
System
System.Math
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  float : Double;
begin
  // Given the following triangle :

  //         .
  //        /|
  //       / |
  //      /  | Y = 2.0
  //     /   |
  //    /A   |
  //   .-----.
  //   X = 1.0

  // Angle A = ArcTan(Y/X) = ArcTan(2/1) = ArcTan(0.5) = 63.43495 degrees
  float := System.Math.ATan2(2.0, 1.0);

  // Convert to degrees to show the value
  float := float * 180 / PI;

  Console.WriteLine('ATan2(2.0, 1.0) = {0} degrees', float.ToString);

  Console.ReadLine;
end.
Show full unit code
  ATan2(2.0, 1.0) = 63.434948822922 degrees
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author