How to Calculate the X, Y of any Position on a Circle

The DegreesToXYsubroutine, part of CodeBank’s standard procedurelibrary, calculates the X (horizontal) and Y (vertical) coordinatesof any point, measured in degrees, on the circumference of a circleor ellipse. As you can see, it’s a pretty simple routine, butextremely valuable when drawing graphics or placing objects:

 Public Sub DegreesToXY(CenterX As _        Long, CenterY As Long, degree _        As Double, radiusX As Long, _        radiusY As Long, X As Long, Y _        As Long)Dim convert As Double        convert = 3.141593 / 180         'pi divided by 180        X = CenterX - (Sin(-degree * _                convert) * radiusX)        Y = CenterY - (Sin((90 + _                (degree)) * convert) * radiusY)End Sub

Pass the subroutine the center X, Y of your ellipse, the degreeposition, and the horizontal and vertical radii (if they are equal,you’re specifying a circle, if not, it is an elongated ellipse).DegreesToXY will return the coordinates in the X and Y parameters.This routine has any number of uses, limited only by your imagination.For example, various CodeBank routines rely on it when drawingarched and rotated text, triangles, polygons, and jagged “smash”ovals when implementing motion effects, and much more.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS