HP Forums
Gradian toolbox - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP Prime Software Library (/forum-15.html)
+--- Thread: Gradian toolbox (/thread-5477.html)



Gradian toolbox - AlfaSierra - 01-08-2016 09:36 AM

Hi to everybody!
I created a small program that provides conversion from radians or degrees to gradian and viceversa. There are also the three basic trigonometric functions and their inverse functions that work directly in gradians.
I hope it is useful to someone. If there are errors and bugs report it!

Code:

// Gradian Toolbox
// January 2016
// HAngle = 1 -> degrees mode
// HAngle = 0 -> radian mode
// Exact function removes approximation error
// Approx function convert decimal value to fraction whenever possible

// Converting to grads
EXPORT TO_GRAD(n)
BEGIN
IF HAngle == 1 THEN 
RETURN 10*n/9;
ELSE 
RETURN 200*n/π;
END;
END;

// Convert from grads
EXPORT FROM_GRAD(n)
BEGIN
IF HAngle == 1 THEN 
RETURN 9*n/10; 
ELSE 
RETURN n*π/200;
END;
END;

// Grads cosine
EXPORT COS_G(n)
BEGIN
RETURN COS(FROM_GRAD(n));
END;

// Grads sine
EXPORT SIN_G(n)
BEGIN
RETURN SIN(FROM_GRAD(n));
END;

// Grads tangent
EXPORT TAN_G(n)
BEGIN
RETURN TAN(FROM_GRAD(n));
END;

// Grads arccosine
EXPORT ACOS_G(n)
BEGIN
IF HAngle == 1 THEN 
RETURN approx(exact(10*ACOS(n)/9));
ELSE 
RETURN approx(exact(200*ACOS(n)/π));
END;
END;

// Grads arcsine
EXPORT ASIN_G(n)
BEGIN
IF HAngle == 1 THEN 
RETURN approx(exact(10*ASIN(n)/9));
ELSE 
RETURN approx(exact(200*ASIN(n)/π));
END;
END;

// Grads arctangent
EXPORT ATAN_G(n)
BEGIN
IF HAngle == 1 THEN 
RETURN approx(exact(10*ATAN(n)/9));
ELSE 
RETURN approx(exact(200*ATAN(n)/π));
END;
END;



RE: Gradian toolbox - salvomic - 01-08-2016 06:41 PM

thank you! very useful. Gradian should be an option in the Prime, like degree and radiants!

Salvo


RE: Gradian toolbox - rprosperi - 01-09-2016 09:52 PM

(01-08-2016 06:41 PM)salvomic Wrote:  thank you! very useful.

Useful for what? I am not questioning you, I just have no idea who still uses GRADS and for what purpose? I believe Surveying used them, but I've heard that has not been true for many years.


RE: Gradian toolbox - salvomic - 01-09-2016 10:06 PM

(01-09-2016 09:52 PM)rprosperi Wrote:  Useful for what? I am not questioning you, I just have no idea who still uses GRADS and for what purpose? I believe Surveying used them, but I've heard that has not been true for many years.

military people use (used?) gradian in their operations...
I can still see gradian examples in old Italian Mathematics's books.
Sure you have already seen here: https://en.wikipedia.org/wiki/Gradian for some ideas.
However I mean: it's useful to have in the Prime also Gradian (not only Degree and Radians): better many than few Smile

Salvo


RE: Gradian toolbox - Archanus - 01-10-2016 01:47 AM

Thanks a Lot Big Grin !!! IT IS VERY USEFUL Big Grin !!!


RE: Gradian toolbox - Eddie W. Shore - 02-21-2016 04:29 PM

Just downloaded it - thank you.