POV-Ray : Newsgroups : povray.advanced-users : Calculating planet positions Server Time
23 Nov 2024 07:50:56 EST (-0500)
  Calculating planet positions (Message 1 to 10 of 25)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Mike Horvath
Subject: Calculating planet positions
Date: 15 Sep 2018 13:07:46
Message: <5b9d3c62$1@news.povray.org>
I'm trying to adapt the following PDF to POV-Ray 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

From: Bald Eagle
Subject: Re: Calculating planet positions
Date: 15 Sep 2018 14:15:07
Message: <web.5b9d4b5dfda659e4458c7afe0@news.povray.org>
Mike Horvath <mik### [at] gmailcom> wrote:
> I'm trying to adapt the following PDF to POV-Ray 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

From: Le Forgeron
Subject: Re: Calculating planet positions
Date: 15 Sep 2018 15:03:32
Message: <5b9d5784$1@news.povray.org>
Le 15/09/2018 à 19:07, Mike Horvath a écrit :
> I'm trying to adapt the following PDF to POV-Ray 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

From: Mike Horvath
Subject: Re: Calculating planet positions
Date: 15 Sep 2018 15:06:51
Message: <5b9d584b$1@news.povray.org>
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 POV-Ray 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

From: Bald Eagle
Subject: Re: Calculating planet positions
Date: 15 Sep 2018 16:15:00
Message: <web.5b9d6796fda659e4458c7afe0@news.povray.org>
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/modulus-to-a-range-x-to-x

I do believe that this is typically done with a macro, and occurs in the POV-Ray
source code.

#macro Modulate (_X)
     #while (_X < 180) #local _X = _X+360; #end
     #While (_X > 180) #local _X = _X-360; #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

From: clipka
Subject: Re: Calculating planet positions
Date: 15 Sep 2018 19:03:19
Message: <5b9d8fb7$1@news.povray.org>
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 POV-Ray
> source code.
> 
> #macro Modulate (_X)
>      #while (_X < 180) #local _X = _X+360; #end
>      #While (_X > 180) #local _X = _X-360; #end
>      _X
> #end


That would be way too time-consuming 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 post-processing `#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 floating-point 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 POV-Ray, 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 "in-line" code.


Post a reply to this message

From: Mike Horvath
Subject: Re: Calculating planet positions
Date: 16 Sep 2018 14:26:55
Message: <5b9ea06f$1@news.povray.org>
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

From: Mike Horvath
Subject: Re: Calculating planet positions
Date: 16 Sep 2018 15:00:25
Message: <5b9ea849$1@news.povray.org>
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	= 10e-6;
	#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

From: Mike Horvath
Subject: Re: Calculating planet positions
Date: 16 Sep 2018 16:19:39
Message: <5b9ebadb@news.povray.org>
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    = 10e-6;
>      #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

From: Mike Horvath
Subject: Re: Calculating planet positions
Date: 16 Sep 2018 22:48:47
Message: <5b9f160f$1@news.povray.org>
I found the bug, and will be uploading a corrected version to the Object 
Collection shortly.


Mike


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.