Converting Delphi Angles between Degrees, Radians and X/Y

If you need to convert angles in Delphi between degrees (0 – 360), radians and X/Y coordinates you have come to the right place.  Ill show you how to do it in just one line of code, two if you count the USES entry



Download the full source code and demo project in Delphi 10.1 (Berlin) format.
These will most likely work in many earlier versions of Delphi

Some of the angle conversions are easy

To convert Radian to Degrees use Delphi’s built in RadToDeg function in the System.Math unit

To convert Degrees to Radian use Delphi’s built in DegToRad function in the System.Math unit

Some are more difficult.  Use my routines for those

This is an overview of my conversion routines in the AngleConvertU.pas unit, plus the built in Delphi conversions routines


Boring Behind The Scenes Bits

The Radian to X / Y routines are based on SIN and COS functions.

x := sin (myRadian); 
y := cos (myRadian);

The SIN and COS functions are radian based, not degree based.  That might confuse you at first if you are used to 360 Degrees, but remember you can easily convert Radian to Degrees (see above for example)

Zero Angle At The Bottom – weoh thats craaazy !

Delphi’s co-ordinate system has the top left pixel at (0,0) and the Y axis increases in value as it stretches down to the bottom of the screen.   That is the reverse of how we normally use angles where the Y axis decreases towards the bottom.  As a result, my conversion routines use 0 degrees at the bottom like this.  If that doesn’t float your goat, you have access to my source code so you can rewrite tje code or add a wrapper to my functions.


Done !

Its that simple.   Just use my unit or the built in Delphi function.
Its just one line of code to call each angle conversion routines

  vRadian : single;
  vRadian := zzXYtoDegreeReal(X, Y);


Download the source code and demo project in Delphi 10.1 (Berlin) format.

It should open in earlier versions of Delphi, although with some complaints

+1 this post

I am trying to get this blog listed on
If you like this post, please +1 for me here on Delphi Feeds

and here on BeginEnd

Thank You !

About The Author

The Usual Suspect
– Scott Hollows –

  • Oracle and Delphi software developer.
  • Australian Delphi User Group – Western Australia Chief Cat Herder
  • Australian Delphi User Group – President
blog email linkedinlogo

Published by

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: