From the course: C Standard Library

Unlock the full course today

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

Solution: Polar coordinate conversion

Solution: Polar coordinate conversion - C Tutorial

From the course: C Standard Library

Start my 1-month free trial

Solution: Polar coordinate conversion

(upbeat music) - [Instructor] My solution to this challenge is very straight forward. So, the first thing I want to show you is in line 4. Where I defined a symbol for pi. And this shouldn't be really necessary if I am using a math library, right? Well, it turns out that constants like pi, are not portable in the C standard library distributions. So, some distributions may have it and some may not because this is implementation defined. And so I had to define my own. And this will be useful to convert degrees to radiance and the other way around. Because as you may remember, the trigonometric functions use angles in radiance. So at the beginning of the main function in line 7, I'm defining some variables which are all double floating point numbers. And they are A_x, A_y, B_radius, and B_angle because I am defining two points. One that is called A and one that is called B. A will be represented in Cartesian coordinates and I will convert it to Polar. And B will come in Polar…

Contents