# Math Library Survey



## Big Bob (Apr 4, 2014)

For the current version of the KSP Math Library (V610), the angular unit used for the trig functions is the deci-grad (1/1000 of a right angle or 4000 divisions per circle).

*1. Would you like to see this precision increased by roughly a factor of 10? *
For example, we could use the centi-grad which would have 40000 divisions per circle (instead of the current 4000)..

*2. Would you prefer using degrees instead of grads? * 
For example, deci-degrees or centi-degrees (which would divide a circle into 3600 deci-degrees or 36000 centi-degrees,
ie 0.1 or 0.01 degrees of precision).

*3. If I change the angular unit or its resolution, should I provide a compiler option to retain the old unit/resolution?*

I'm thinking of adding the inverse trig functions to the next library release; along with an *atan2* routine for *rectangular to polar conversions*. And, I have to decide whether or not to provide more angular resolution. I think it might be advisable to do this but then it might also be better if I upgraded the existing trig functions to use more angular resolution.

If I provide (3), it would only affect the existing trig functions and not the new inverse functions. With *OldTrig* mode on, the Sin, Cos, and Tan routines would still use deci-grads while the asin, acos, atan, and atan2 routines would use whatever the new unit/resolution is. With *OldTrig* off, all trig functions would use the new unit/resolution.

Here's your chance to influence the next Math Library release. *Speak now or forever hold your peace.* :lol: 

Rejoice,

Bob


----------



## d.healey (Apr 4, 2014)

1. More accuracy can only be a good thing, right?

2. I have no real preference here

3. For backwards compatibility? If so, yes.

Thanks for your hard work on this library Bob, I appreciate it very much!


----------



## mk282 (Apr 5, 2014)

1. Why not  As an additional option, though, to preserve compatibility.

2. I would prefer degrees.

3. Definitely, backwards compatibility is paramount. In fact, I would rather suggest that the math library continues to use previous unit, and the new unit is enabled via a compiler option.


----------



## d.healey (Apr 5, 2014)

mk282 @ Sat Apr 05 said:


> In fact, I would rather suggest that the math library continues to use previous unit, and the new unit is enabled via a compiler option.



I agree with this idea.


----------



## andreasOL (Apr 5, 2014)

Hi Bob!

Same for me. Backwards compatibility is mandatory!

Depending on where the degrees or grads come from one or the other is appropriate for new projects.

So, yes to all points 

Cheers,
Andreas


----------



## Big Bob (Apr 5, 2014)

Hey guys, thanks for the feedback, and, I hear you about the backwards compatibility. 8) 

Here's my current plan.

The internal angular resolution will be 40000 divisions per circle which makes the 'natural' angular unit the centi-grad (10000 units per right angle). However, I will add a new *SetMathMode* compiler option to allow you to choose the angular unit you want to use.

I'm thinking of providing the following 4 choices:

0 - deci-grads: 4000 divisions per circle (the current unit)
1 - centi-grads: 40000 divisions per circle (10x the current resolution)
2 - deci-degrees: 3600 divisions per circle (0.1 degree resolution)
3 - centi-degrees: 36000 divisions per circle (0.01 degrees resolution)

Internally the library will work with centi-grads so no input/output conversion will be necessary with option #1 (which is the highest resolution). That will also make this mode the most efficient. All the remaining modes will scale input and output angles as necessary. Currently only input angles are involved however, once I add the inverse functions, there will be output angles as well. Currently I plan that the selected angular unit will apply to both input and output angles.

I will also arrange it so that the library constant *Ang90* will always represent a right angle, no matter which angular unit you choose. In mode 0, 1, 2, and 3, *Ang90* will have the values 1000, 10000, 900, 9000 respectively.

Rejoice,

Bob


----------



## d.healey (Apr 5, 2014)

Genius!


----------



## Big Bob (Apr 6, 2014)

Oh my, I'm far from genius material David but thanks for the compliment :oops: 

But, I guess that you approve of my latest plan then?

Is everyone else happy with this plan?

Is there anyone who is unhappy with it? :lol:

Rejoice,

Bob


----------



## paoling (Apr 9, 2014)

I'm really happy with your plan and I feel like you're doing it a bit for my needs  So I thank you again Bog, and I really prefer the decigrads, than the degrees.


----------



## Big Bob (Apr 9, 2014)

> So I thank you again Bog, and I really prefer the decigrads, than the degrees.



Well, in your case then, all you will have to do is use:

SetMathMode(FIT,DG)

Then, all trig functions will use deci-grads as their angular unit. The new fast-mode option is for 'inverse trig' functions (when you want them to use fast math).

BTW whose Bog? :lol:


----------

