Post Reply 
[Prime] Missing trigonometric/hyperbolic functions, possible navigational enhancement
10-31-2015, 08:25 PM
Post: #9
RE: [Prime] Missing trigonometric/hyperbolic functions, possible navigational enhancement
I am not sure if it would count as a trig function as it would also have uses elsewhere: But seeing as haversines and astronomy have been mentioned...

I would like to see a function I have never noticed (perhaps it is in a calculator somewhere).
REDUCE_RANGE.

in astronomical algorithms one frequently calculates some angle and then wishes to take its sin... But first, the spec glibly says "reduce range" (eg from 362 degrees to 2 degrees, or 25 h to 1 h). If there could be a reduce range function, that would be great as I could just call it and carry on.

Of course, one can simply use a modulo function... But by the time I have thought about the range required (0..360? -180..180?) And written a test program to check how MOD on that compiler handles negatives (some languages may produce different results), I will have forgotten the application code I was in the middle of. Or to carry on with the application coding, you could ignore getting bogged down in MOD syntax, and repeatedly subtract... No chance of bugs there, until you use a very large angle Smile.

A reduce_range function makes it immediately clear what your code is trying to ach hiieve with minimum distraction and close similarity to the spec.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [Prime] Missing trigonometric/hyperbolic functions, possible navigational enhancement - StephenG1CMZ - 10-31-2015 08:25 PM



User(s) browsing this thread: 4 Guest(s)