Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Elliptic orbit

Author
Message
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 7th Jul 2009 15:44
Im not very good at my maths, i got the trig tutorial but still dont make much sense of it...

im after a piece of code that will help me do an elliptic orbit.

I had seen a post on it quite a while ago but i couldnt find it again...

All help is appreciated..
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 7th Jul 2009 16:09
Quote: "newxvalue(x, ang, speed) = x + sin(ang) * speed
newyvalue(y, ang, speed) = y + tan(ang) * speed `hate this one
newzvalue(z, ang, speed) = z + cos(ang) * speed `better for Y

And, as I always seem to be posting recently:

sphere2.x = sphere1.x + ( sin(angy) * cos(angx) * distance )
sphere2.y = sphere1.y - ( sin(angx) * distance )
sphere2.z = sphere1.z + ( cos(angy) * cos(angx) * distance )

Where:
sphere1 and sphere2 are the positions of each of the spheres
angx and angy are the angles you wish to have between the spheres
distance is the distance between them"


(Posted by Zotoaster; search for "orbit").

lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 8th Jul 2009 03:38
hmm is that elliptic??

if it is are the angx and y for the semiminor axis and semimajor axis...?
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 8th Jul 2009 09:25 Edited at: 8th Jul 2009 09:26
I think you just specify two different arguments for the trig functions to make it elliptic.
Ie. x * 1.5 or similar, so that they still have something in common.

lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 8th Jul 2009 11:05
ok ive half solved it, after much reading on trogonometry and ellipses i have come up with this



i might even turn it into a function and post it in the code snippets so that anybody else searching for the truth will say thats not an E.T. LOL! JK

now i will work out an orbit path with this and come back her if i have any issues, thankyou vm...
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 8th Jul 2009 17:09
ok i have tried this



to push a small example, but for some reason it just positions it and then it doesnt move....

any ideas???
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 8th Jul 2009 18:40
Yes, because the screen is only drawn when sync is called.
Omit the for loop and just put in A = wrapvalue(A + 1) in the while loop, which would move it one degree (which probably is to fast, so you should consider using a float instead) for each rendered frame.

lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 9th Jul 2009 02:51 Edited at: 9th Jul 2009 04:12
yes thankyou, i was a little drowsy last night...

thats what meds do to you.

thankyou for the help....

EDIT: Ok now a know that the sime time is based on the A#+1, How could i implement movement based on a MilPerSimHour Variable??

i mean, i have the orbit period in days i think, and i need to convert that to hours and then use the MilPerSimHour Variable to calculate its speed in the utility...

I have used it before in a circular orbit



but now i need it for an elliptic orbit..
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 9th Jul 2009 11:15 Edited at: 9th Jul 2009 11:16
Well, one day = 24 hours, so divide the orbit period in days with 24.

Then you of course need to know the update rate (the smartest thing would be to use a timer based system) so that you can ensure that the orbit period is xxx seconds.

You could then just increase the angle value with ((orbitPeriod / (60 * 60)) / fps) * 360° for each loop cycle, effectively giving you one leap per timePeriod hours.

Hm... I just got up, so this is probably rather hard to understand

lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 9th Jul 2009 12:39
That algorithm was a little confusing, 60 * 60 What for???

and how do i make it so that the sim speed is in there...

i may have found another way to do it, i will post up my results soon...
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 9th Jul 2009 13:57
One hour = 60 minutes, which in turn is 60 seconds. Hence, one hour = 60 * 60 = 3600 seconds

orbitPeriod in my post would be the same as your simSpeed, I guess.

lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 9th Jul 2009 14:19
ok lets say it takes 24 hours to orbit the sun (Hypothetical) that would be in orbitPeriod, but then there is also sim speed, so if simspeed = 1 then 1 hour will pass in-game every fram i believe thats how it worked, but if it was 2 then 2 hours every frame...

i hope that helped explain better.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 9th Jul 2009 14:45
I see.
Well, then actual speed = orbit period * sim speed.

lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 10th Jul 2009 10:27
well everything seems to work ok now except its very jumpy, i wonder why??
Couchyam
15
Years of Service
User Offline
Joined: 24th Jul 2009
Location:
Posted: 25th Jul 2009 04:43
I think it might have to do with the type of elliptic orbit you made. If you want a physics elliptical orbit, then the mathematical form should be more like A/(1-ecos(angle)).

Login to post a reply

Server time is: 2024-11-25 04:56:52
Your offset time is: 2024-11-25 04:56:52