





 
 




 
 


I'm trying to adapt the following PDF to POVRay code for my
planetarium/orrery.
https://ssd.jpl.nasa.gov/txt/aprx_pos_planets.pdf
How do I calculate the modulus 180 <= M <= +180?
Is it equal to this?
mod(number+180,360)180
Mike
Post a reply to this message


 
 




 
 


Mike Horvath <mik### [at] gmailcom> wrote:
> I'm trying to adapt the following PDF to POVRay code for my
> planetarium/orrery.
>
> https://ssd.jpl.nasa.gov/txt/aprx_pos_planets.pdf
It was a gigantic PITA
http://news.povray.org/povray.binaries.animations/thread/%3Cweb.5915a4387de46d5ec437ac910%40news.povray.org%3E/?mtop=41
6271
Even more of a PITA was unpacking date codes.
> How do I calculate the modulus 180 <= M <= +180?
I don't know what that means
Post a reply to this message


 
 




 
 


Le 15/09/2018 Ã 19:07, Mike Horvath a Ã©critÂ :
> I'm trying to adapt the following PDF to POVRay code for my
> planetarium/orrery.
>
> https://ssd.jpl.nasa.gov/txt/aprx_pos_planets.pdf
>
> How do I calculate the modulus 180 <= M <= +180?
>
180 degrees, really ?
Can't they use a decent measure of angle, in Grades !
> Is it equal to this?
>
> Â Â Â Â mod(number+180,360)180
Probably, as long as number is above 180 at start.
I never understood mod of negative value, and there might be divergent
definitions.
They seem to be using a referential for M to describe a full "circle",
so yes, they want to reduce the range of M to be between 180 and +180.
>
>
> Mike
Post a reply to this message


 
 




 
 


On 9/15/2018 2:11 PM, Bald Eagle wrote:
> Mike Horvath <mik### [at] gmailcom> wrote:
>> I'm trying to adapt the following PDF to POVRay code for my
>> planetarium/orrery.
>>
>> https://ssd.jpl.nasa.gov/txt/aprx_pos_planets.pdf
>
> It was a gigantic PITA
>
http://news.povray.org/povray.binaries.animations/thread/%3Cweb.5915a4387de46d5ec437ac910%40news.povray.org%3E/?mtop=41
> 6271
>
> Even more of a PITA was unpacking date codes.
>
>
Interesting. It seems I posted in that thread too.
>> How do I calculate the modulus 180 <= M <= +180?
>
> I don't know what that means
>
>
>
Quote:
"Modulos the mean anomaly so that 180 <= M <= +180 ..."
Mike
Post a reply to this message


 
 




 
 


Mike Horvath <mik### [at] gmailcom> wrote:
> Interesting. It seems I posted in that thread too.
Yes. :D
> Quote:
>
> "Modulos the mean anomaly so that 180 <= M <= +180 ..."
5 sec search yielded:
https://lite.qwant.com/?q=""modulus+the+mean+anomaly
https://math.stackexchange.com/questions/1325434/modulustoarangextox
I do believe that this is typically done with a macro, and occurs in the POVRay
source code.
#macro Modulate (_X)
#while (_X < 180) #local _X = _X+360; #end
#While (_X > 180) #local _X = _X360; #end
_X
#end
type of thing.
Then of course, there's
http://www.povray.org/documentation/view/3.6.2/458/
clamp(V, Min, Max). A function that limits a value to a specific range, if it
goes outside that range it is "clamped" to this range, wrapping around. As the
input increases or decreases outside the given range, the output will repeatedly
sweep through that range, making a "sawtooth" waveform.
Parameters:
V = Input value.
Min = Minimum of output range.
Max = Maximum of output range.
Bill
Post a reply to this message


 
 




 
 


Am 15.09.2018 um 22:12 schrieb Bald Eagle:
>> "Modulos the mean anomaly so that 180 <= M <= +180 ..."
...
> I do believe that this is typically done with a macro, and occurs in the POVRay
> source code.
>
> #macro Modulate (_X)
> #while (_X < 180) #local _X = _X+360; #end
> #While (_X > 180) #local _X = _X360; #end
> _X
> #end
That would be way too timeconsuming for very large or very small values.
> Then of course, there's
> http://www.povray.org/documentation/view/3.6.2/458/
>
> clamp(V, Min, Max). A function that limits a value to a specific range, if it
> goes outside that range it is "clamped" to this range, wrapping around. As the
> input increases or decreases outside the given range, the output will repeatedly
> sweep through that range, making a "sawtooth" waveform.
> Parameters:
That'll indeed do it:
#include "math.inc"
#local Foo = clamp(M,180,180);
Alternatively:
#local Foo = mod(M+180,360)180;
#if (Foo < 180)
#local Foo = Foo + 260;
#end
The postprocessing `#if` branch is necessary because mod(X,Y) wraps
positive values into the range [0..Y), but negative values into the
range (Y..0].
[At least on platforms where converting a floatingpoint number to an
integer rounds towards 0. That's the case for all contemporary platform
I'm aware of, and is an official prerequisite for compiling POVRay, but
the C++ standard would also allow for rounding towards negative infinity
instead.]
`clamp()` effectively does the same, but is implemented as a function,
which probably makes it faster than a macro or "inline" code.
Post a reply to this message


 
 




 
 


On 9/15/2018 4:12 PM, Bald Eagle wrote:
> clamp(V, Min, Max). A function that limits a value to a specific range, if it
> goes outside that range it is "clamped" to this range, wrapping around. As the
> input increases or decreases outside the given range, the output will repeatedly
> sweep through that range, making a "sawtooth" waveform.
> Parameters:
>
> V = Input value.
> Min = Minimum of output range.
> Max = Maximum of output range.
>
>
> Bill
>
>
Clamp works, thanks!
Mike
Post a reply to this message


 
 




 
 


https://ssd.jpl.nasa.gov/txt/aprx_pos_planets.pdf
I am a little confused about the "Solution of Kepler's Equation" on Page
2 of this document. Have I implemented it correctly do you think?
#local Orrery_Temp_EStar = 180/pi * Orrery_Temp_Eccentricity;
#local Orrery_Temp_EccentricAnomaly = Orrery_Temp_MeanAnomaly +
Orrery_Temp_EStar * sind(Orrery_Temp_MeanAnomaly);
#local Orrery_Temp_EccentricAnomalyTolerance = 10e6;
#local Orrery_Temp_EccentricAnomalyDelta = 0;
#while (abs(Orrery_Temp_EccentricAnomalyDelta) >
Orrery_Temp_EccentricAnomalyTolerance)
#local Orrery_Temp_MeanAnomalyDelta = Orrery_Temp_MeanAnomaly 
(Orrery_Temp_EccentricAnomaly  Orrery_Temp_EStar *
sind(Orrery_Temp_EccentricAnomaly));
#local Orrery_Temp_EccentricAnomalyDelta =
Orrery_Temp_MeanAnomalyDelta/(1  Orrery_Temp_Eccentricity *
cosd(Orrery_Temp_EccentricAnomaly));
#local Orrery_Temp_EccentricAnomaly = Orrery_Temp_EccentricAnomaly
+ Orrery_Temp_EccentricAnomalyDelta;
#end
Mike
Post a reply to this message


 
 




 
 


On 9/16/2018 3:00 PM, Mike Horvath wrote:
> https://ssd.jpl.nasa.gov/txt/aprx_pos_planets.pdf
>
> I am a little confused about the "Solution of Kepler's Equation" on Page
> 2 of this document. Have I implemented it correctly do you think?
>
> Â Â Â Â #local Orrery_Temp_EStarÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â =
180/pi *
> Orrery_Temp_Eccentricity;
> Â Â Â Â #local Orrery_Temp_EccentricAnomalyÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â =
> Orrery_Temp_MeanAnomaly + Orrery_Temp_EStar *
> sind(Orrery_Temp_MeanAnomaly);
> Â Â Â Â #local Orrery_Temp_EccentricAnomalyToleranceÂ Â Â = 10e6;
> Â Â Â Â #local Orrery_Temp_EccentricAnomalyDeltaÂ Â Â Â Â Â Â = 0;
> Â Â Â Â #while (abs(Orrery_Temp_EccentricAnomalyDelta) >
> Orrery_Temp_EccentricAnomalyTolerance)
> Â Â Â Â Â Â Â #local Orrery_Temp_MeanAnomalyDeltaÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â =
> Orrery_Temp_MeanAnomaly  (Orrery_Temp_EccentricAnomaly 
> Orrery_Temp_EStar * sind(Orrery_Temp_EccentricAnomaly));
> Â Â Â Â Â Â Â #local Orrery_Temp_EccentricAnomalyDeltaÂ Â Â Â Â Â Â =
> Orrery_Temp_MeanAnomalyDelta/(1  Orrery_Temp_Eccentricity *
> cosd(Orrery_Temp_EccentricAnomaly));
> Â Â Â Â Â Â Â #local Orrery_Temp_EccentricAnomalyÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â =
> Orrery_Temp_EccentricAnomaly + Orrery_Temp_EccentricAnomalyDelta;
> Â Â Â Â #end
>
>
>
> Mike
I did end up finding a bug in that code, but I also discovered that
there's not a visible difference with the code working or not working.
So the major problems I am having lie elsewhere.
:(
Mike
Post a reply to this message


 
 




 
 


I found the bug, and will be uploading a corrected version to the Object
Collection shortly.
Mike
Post a reply to this message


 
 




 