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 - C Tutorial
From the course: C Standard Library
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…
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
-
-