It is currently May 14th, 2024, 12:03 pm

Equation of Kepler

Get help with creating, editing & fixing problems with skins
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Equation of Kepler

Post by Kaelri »

Fulmar wrote:One last question in this topic maybe: I will calculate the orbits for n objects in the same skin. Can this be done by this one Lua script? Do I create another Measure "MeasureKeplerScript" and another Meter "MeterLuaReturn" for each object?
Yes, the easiest way would be to create additional script measures. They can all use the same "Kepler.lua" script file; each will return the correct results for their "M" and "e" settings. Example:

Code: Select all

[Kepler1]
Measure=Script
ScriptFile=#CURRENTPATH#Kepler.lua
M=MeadObject1
e=EcorObject1

[Kepler2]
Measure=Script
ScriptFile=#CURRENTPATH#Kepler.lua
M=MeadObject2
e=EcorObject2
Fulmar
Posts: 21
Joined: July 24th, 2012, 4:50 pm
Location: Belgium

Re: Equation of Kepler

Post by Fulmar »

Just to tell the Kepler lua is working fine, except I had to change the script a bit. Because of the extreme accuracy Rainmeter crashed easily.

The script is now:

function Initialize()
MeasureName_M = SELF:GetOption("M")
MeasureName_e = SELF:GetOption("e")

Measure_M = SKIN:GetMeasure(MeasureName_M)
Measure_e = SKIN:GetMeasure(MeasureName_e)
end

function Update()
local M = Measure_M:GetValue()
local e = Measure_e:GetValue()

local E = M

repeat
local LastE = E
E = E + (M + math.deg(e)*math.sin(math.rad(E)) - E)/(1 - e*math.cos(math.rad(E)))
until math.abs (E - LastE) < 0.0000000001

return E
end

Thanks for your help

:thumbup:
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Equation of Kepler

Post by Kaelri »

That makes sense. Good solution. Glad everything's working out. :)
Lightz39
Posts: 98
Joined: August 1st, 2012, 12:48 am

Re: Equation of Kepler

Post by Lightz39 »

This is the most ridiculous thing I've ever read in my life. Nerds. :welcome:

My brain hurts. :confused:
User avatar
jsmorley
Developer
Posts: 22632
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Equation of Kepler

Post by jsmorley »

Lightz39 wrote:This is the most ridiculous thing I've ever read in my life. Nerds. :welcome:

My brain hurts. :confused:
LOL.. I'm glad you said it. I was just thinking it. ;-)