From the course: C Standard Library

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Challenge: Polar coordinate conversion

Challenge: Polar coordinate conversion - C Tutorial

From the course: C Standard Library

Start my 1-month free trial

Challenge: Polar coordinate conversion

(electronic music) - [Instructor] Here's a challenge to test what you've learned about mathematical functions in the math.h header file. This time, you must write some code to convert a two-dimensional point represented in Cartesian, or rectangular, coordinates to polar coordinates and the other way around. I'll clarify this shortly. As always, remember that we want you to experiment with the functions in math.h, and you shouldn't worry about special cases, like, for example, a user entering something other than a number. Just to be clear, here's what you need to calculate to perform coordinate conversions. A point P in a two-D plane can be represented by using two of the four parameters shown, Px, Py, r, and theta. In Cartesian coordinates, P is represented as the pair Px, Py. In polar coordinates, P is represented as the pair r for radius, and theta, which is the angle, and we'll express it in degrees. Px and Py are calculated as r cosine of theta and r sine of theta, respectively…

Contents