Polar coordinates
2025/12/27
- Type
- Learning Resource
- Format
- Glossary Article
- Version
- General
- Subject Tags
- Created
- Updated
- 2026/02/16
- 2025/12/27
Polar coordinates represent a position using an angle and a distance from a point. This is an alternative to Cartesian coordinates, which use distances from a point along axes.
Among other applications, polar coordinates are useful to represent:
Given an angle and a distance, you can take a unit vector pointing to the right, rotate it by the angle, and multiply it by the distance to convert polar coordinates to Cartesian ones.
Here's a GDScript code example that uses polar coordinates to generate a random position within a circle:
var random_angle := randf_range(0.0, 2.0 * PI)
var random_direction := Vector2(1.0, 0.0).rotated(random_angle)
var random_distance := randf_range(60.0, 120.0)
position = random_direction * random_distanceThis code generates a random angle between 0 and 2π, a random direction by rotating a unit vector by the random angle, and a random distance between 60 and 120. By multiplying the direction by the distance, we get a random position within a circle.
Don't stop here. Step-by-step tutorials are fun but they only take you so far.
Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.
Get help from peers and pros on GDQuest's Discord server!
20,000 membersJoin ServerThere are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!
Sponsor this library by learning gamedev with us onGDSchool
Learn MoreImprove and build on assets or suggest edits onGithub
Contributeshare this page and talk about GDQUest onRedditYoutubeTwitter…