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.

Dark GDK / Drawing Lines

Author
Message
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 11th Oct 2009 01:58
Yes I know a simple question, but I have a Solar System program where the planets orbit the sun. I want to draw the orbit lines.

The main problem comes in when the player gets to move the planet around to see what the gravitation changes would do. I want to show this by drawing the line of the new orbit.

So, I'm not sure how to draw a variable orbit line in GDK.

Any ideas?
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 11th Oct 2009 17:01
What do you mean by variable orbit line? You should be able to parameterize the orbit curve and then draw the path using those equations and iterating over small intervals.

ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 12th Oct 2009 00:23
Well I problem that I'm facing is drawing a line that keeps its shape as the user moves around the screen. Also, the dbLine function only draws a straight line from A to B.
entomophobiac
22
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 12th Oct 2009 01:01
Interesting... What do you use for rotations, ReiKumar? I've had trouble with the actual orbits, myself.
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 13th Oct 2009 01:57
I don't have anything doing the orbits for me yet, but I will have it once I finish my orbital function, which at the moment can only be tested if I have the orbit drawing function working.
MxM111
15
Years of Service
User Offline
Joined: 3rd Oct 2009
Location:
Posted: 13th Oct 2009 07:47
The orbit is a parametrized function in 3D space (or 2D space if you have 2D app). This function is something like
x = function1(t);
y = function2(t);
z = function3(t);

where x, y, and z are possible coordinate of planet from parameter t (t actually can be time but not necessarily so). So the orbit is a set of x(t), y(t) z(t).

In the simplest case of circular orbit around point 0,0 in z-plane those functions can be:

x = R*cos(t);
y = R*sin(t);
z = 0;

where R is the orbit radius. You function will be more complex, to account for shifts, rotations and may be elliptical orbits.

What you have to do, in general case, is to run t from 0 to 2pi and draw a short lines using dbLine. Something like

Login to post a reply

Server time is: 2024-11-20 13:39:22
Your offset time is: 2024-11-20 13:39:22