So I defined..
#define RADIAN(x) x*3.14159265f/180.0f
and then used it like this:
RADIAN(theta-90)
My program constantly gave me incorrect results, it took me a couple hours to realize that there was a huge difference between the above statement and the statement below.
RADIAN((theta-90))
Now my program is running perfectly fine. Why is the first statement incorrect?
#define makes just text substitution, so RADIAN(theta-90) was really theta-90*3.14159265f/180.0f, what obviously wasn't what you meant. Try
#define RADIAN(x) ((x)*3.14159265f/180.0f)
instead.
Macro's largley do text based replacement so
RADIAN(theta-90)
expands to:
theta - 90* 3.14159265f/180.0f
which because of operator precedence, evaluates as:
theta - (90* 3.14159265f/180.0f)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With