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 - C Tutorial
From the course: C Standard Library
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
Mathematical functions2m 50s
-
Rounding and truncating51s
-
Rounding and truncating example5m 4s
-
Trigonometric functions1m 42s
-
Trigonometric functions example1m 27s
-
Powers and exponentials1m 9s
-
Powers and exponentials example3m 4s
-
Challenge: Polar coordinate conversion2m 19s
-
Solution: Polar coordinate conversion6m 53s
-
C23 update3m 39s
-
-