Algorithms_in_C
1.0.0
Set of algorithms implemented in C.
|
Function to convert a Cartesian co-ordinate to polar form. More...
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
Macros | |
#define | _USE_MATH_DEFINES |
required for MS Visual C | |
Functions | |
void | to_polar (double x, double y, double *r, double *theta) |
Function to convert cartesian coordinates to polar. More... | |
double | get_rand (double lim1, double lim2) |
Generate a random number in the given limits. More... | |
void | test () |
Test implementation. More... | |
int | main () |
Main function. | |
Function to convert a Cartesian co-ordinate to polar form.
double get_rand | ( | double | lim1, |
double | lim2 | ||
) |
void test | ( | ) |
Test implementation.
void to_polar | ( | double | x, |
double | y, | ||
double * | r, | ||
double * | theta | ||
) |
Function to convert cartesian coordinates to polar.
\begin{eqnarray*} r &=& \sqrt{x^2+y^2}\\ \theta &=& \atan\frac{y}{x} \end{eqnarray*}
[in] | x | absicca value |
[in] | y | ordinate value |
[out] | r | pointer to store polar radius |
[out] | theta | pointer to store polar angle (in radian) |