I am currently programming a flight simulator for a school project, it is going excellently. I am currently configuring the relationship between pitch, roll and yaw, I have the notes and basic mathematical framework.
Upon utilising the relevant trigonometry I found that C++ defaults to radians, this is terrible for my purpose, I require (for example) sin(180) = 0 not -0.80115263573 as with radians.
I am aware that the conversion may be done by utilising Pi, however I wish to make this simulator flawless, the dilemma follows: Pi is transcendental, to ensure 100% accuracy I would need infinite places, I require the overall calculation to be exact, i.e. sin(180degrees) = 0. Are there any #defines I may utilise? I really hope to carry out all calculations in degrees.
Any help provided is appreciated, my knowledge of C++ is intermediate at best.
What would one of these magical #defines do that you can't? They sure can't get around the problem of not having infinite space to hold pi. You won't get 100% accuracy when dealing with floating point numbers in computers. But you can get close enough. There's a vast amount of literature on the web where you can read all about this.
I have these, in my math header, note that they may not be in every implementation of math headers - that is they are not portable.
And the usual recommendation is to make them constdoubles or longdouble. There are plenty of significant places there - 20 is usually good enough for most things.
@Lavaguava TheIdeasMan is generaly the best way since trigonometry calculus needs hundred of cycles , with a table you can interpolate . But All calculus will use radians no exception. There are several reasons for it. If you plan to use degrees instead , simply create yourself a function called convertDegToRad().