Welcome, Guest. Please Login.
Gravity Simulator
11/19/17 at 00:53:52
News: Registration for new users has been disabled to discourage spam. If you would like to join the forum please send me an email with your desired screen name to tony at gravitysimulator dot com.
Home Help Search Login


Pages: 1 2 
Send Topic Print
New Gravity Simulator (Read 13061 times)
Tony
YaBB Administrator
*****




Posts: 1051
Gender: male
Re: New Gravity Simulator
Reply #15 - 07/01/15 at 14:50:31
 
Quote from frankuitaalst on 07/01/15 at 13:27:52:
Thanks , I wasn't aware there was an "optimal" time step avalable .
Curious : how did you code for this ??? Taking into account the minimum actual distance between bodies ?  

I was talking about the buttons :
"stars " and the "pre-trails" which interfere .

It's programmed in the Steps Per Radian textbox. With that number set to 100, it chooses a time step that will allow an object to traverse 1 radian of its orbit in 100 steps. (in which case, the entire orbit would take 628 steps)
 
The trails you see when you turn off the stars are not pre-trails.  They are "post-trails".  They get drawn as the object moves.  Pre-trails are computed before the simulation begins running.  They're not used in the Apophis simulation.
Back to top
 
 
Email View Profile WWW   IP Logged
frankuitaalst
Ultimate Member
*****


Great site

Posts: 1507
Gender: male
Re: New Gravity Simulator
Reply #16 - 08/09/15 at 04:28:37
 
I especially like the feature which lets you INSERT a body in a simulation.  
As I understood the html version then contacts the horizons jpl website and retrieves the x,y,z,vx,vy,vz coordinates of the specified body and uses them in the simulation . Fantastic .  
http://ssd.jpl.nasa.gov/?horizons_doc#specific_quantities
Is it possible to clarify Tony which settings you use for retrieving the data ?  
( Ie : reference frame choosen (JC , FK ) and the options concerning the light -time ) .  
The latter may be important in case of far away bodies such as Pluto where the light time comes yes/no into play depending upon ...
Back to top
 
 
Email View Profile   IP Logged
Tony
YaBB Administrator
*****




Posts: 1051
Gender: male
Re: New Gravity Simulator
Reply #17 - 08/09/15 at 09:13:24
 
For example, to retrieve position and velocity vectors for Charon on May 1, 2015, paste the following into your browser:
 
http://ssd.jpl.nasa.gov/horizons_batch.cgi?batch=1&START_TIME%20=%20%272015- May-01%2000:00:00%27&STOP_TIME%20=%20%272015-May-01%2000:00:01%27&TABLE_TYPE%20=%20%27Vector%27&REF_PLANE%20=%20%27Ecliptic%27&CENTER%20=%20%27@010%27&COMMAND=%20%27901%27%20%27999%27%20%27902%27%20%27903%27%20%27904%27%20%27905%27%20%27-97%27
 
It returns sun-centered position and velocity.  Light speed is not accounted for.  I forget the explanation, but if you account for light speed in an n-body it makes the system unstable.  Somewhere in the explanation, light travel time cancels out due to a relativistic effect.  If I find a link explaining it I'll post it here.
Back to top
 
 
Email View Profile WWW   IP Logged
frankuitaalst
Ultimate Member
*****


Great site

Posts: 1507
Gender: male
Re: New Gravity Simulator
Reply #18 - 08/09/15 at 09:41:52
 
Quote from Tony on 08/09/15 at 09:13:24:
For example, to retrieve position and velocity vectors for Charon on May 1, 2015, paste the following into your browser:

http://ssd.jpl.nasa.gov/horizons_batch.cgi?batch=1&START_TIME%20=%20%272015- May-01%2000:00:00%27&STOP_TIME%20=%20%272015-May-01%2000:00:01%27&TABLE_TYPE%20=%20%27Vector%27&REF_PLANE%20=%20%27Ecliptic%27&CENTER%20=%20%27@010%27&COMMAND=%20%27901%27%20%27999%27%20%27902%27%20%27903%27%20%27904%27%20%27905%27%20%27-97%27

It returns sun-centered position and velocity.  Light speed is not accounted for.  I forget the explanation, but if you account for light speed in an n-body it makes the system unstable.  Somewhere in the explanation, light travel time cancels out due to a relativistic effect.  If I find a link explaining it I'll post it here.

Thanks Tony for the link .  
Concerning the light time correction : It is assumed gravity works instantanious , just as Newton derived .  This means the action of far away bodies comes from another position as to where we "see" the body . Just wondered with which value GravSim works . Seems ok  
Edit : maybe the "light time correction " may give some funny results if one would observe eclipses , such as solar eclipse in which the observed time may be off by several minutes .    
Back to top
 
« Last Edit: 08/09/15 at 10:55:46 by frankuitaalst »  
Email View Profile   IP Logged
frankuitaalst
Ultimate Member
*****


Great site

Posts: 1507
Gender: male
Re: New Gravity Simulator
Reply #19 - 12/12/15 at 11:28:53
 
I'm really fascinated about some new features in the html version of the GravSim simulator as there are :
 the possibility to choose a camera location and "look at" feature , and also the feature which displays on screen crescents , such as the crescent moon , taking account the position of the illumination source .  
I've not looked at the code yet , but is this a "standard " function html provides or did it require additional coding ?
Back to top
 
 
Email View Profile   IP Logged
Tony
YaBB Administrator
*****




Posts: 1051
Gender: male
Re: New Gravity Simulator
Reply #20 - 12/13/15 at 13:20:52
 
The camera position and "look at" feature was done with additional coding.  The crescents were done with additional coding as well.
There are some libraries available to HTML5 such as WebGL and three.js.  I've played around with each a little, but not all browsers support them, so I didn't use them.
In the future, I might use them to include surfaces of planets, so when you look at Earth, you see continents and oceans instead of a big blue circle.
 
Crescents were done by computing the phase angle between the camera/object and object/sun lines.  The shape of the terminator line is a half ellipse, alternating between e = 0 (circle) and e = 1, straight line.  In the code, look for the function: function drawCrescentA()
Back to top
 
 
Email View Profile WWW   IP Logged
frankuitaalst
Ultimate Member
*****


Great site

Posts: 1507
Gender: male
Re: New Gravity Simulator
Reply #21 - 12/13/15 at 13:40:03
 
Thanks for the reply Tony. Amazing achievement in coding !  
I looked at the "moon occults Venus" html sim .  
It really looks as viewing through a telesscope to view the crescent moon occult the phased Venus .  
Drwaing phases is also done by drawCrescentA() ?  
I'll take a look .
Back to top
 
 
Email View Profile   IP Logged
Tony
YaBB Administrator
*****




Posts: 1051
Gender: male
Re: New Gravity Simulator
Reply #22 - 12/13/15 at 16:27:15
 
Yes, the drawing phases is done by drawCrescentA().  But lots of math is done outside that function before it is called.
You need to know the vectors for the various objects.
 
The two vectors are:
vector1: the line connecting the target object to the Sun
vector2: the line connecting the target object to the camera object
 
So in the "Moon occults Venus" sim when it draws the Moon, vector 1 is the line connecting the Moon to the Sun and vector2 is the line connecting the Moon to the Earth.
When it draws Venus, vector1 is the line connecting Venus to the Sun, and vector2 is the line connecting Venus to the Earth.
 
The following code gets executed just prior to calling drawCrescentA();
 
These 2 lines of code create the vectors in heliocentric coordinates (Sun is at 0, 0, 0)
 
vector1x = objx[k]; vector1y = objy[k]; vector1z = objz[k];
vector2x = objx[k] - objx[fromObjA]; vector2y = objy[k] - objy[fromObjA]; vector2z = objz[k] - objz[fromObjA];
 
 
These 2 lines use Pythagorean theorem to get the lengths or magnitudes of the vectors
 
vector1mag = Math.sqrt(vector1x * vector1x+ vector1y * vector1y + vector1z*vector1z);
vector2mag = Math.sqrt(vector2x * vector2x+ vector2y * vector2y + vector2z*vector2z);
 
 
To get the phase angle between 2 vectors, you use:
arccosine (dot product of the 2 vectors divided by the product of their magnitudes)
 
These two lines compute the dot product and the magnitude product
 
dot = vector1x * vector2x  + vector1y * vector2y  + vector1z * vector2z ;
mag = vector1mag * vector2mag;
 
 
Now you can compute the phase angle
 
theta = Math.acos(dot / mag);
 
 
Now you have to compute the orientation of the terminator line.  The terminator touches the limb of the planet on 2 points, 180 degrees apart.  This forms a line.
Find the slope of this line using slope = rise / run.
Then use arctangent to get the angle of that line.
 
 
rise = sY - sunY; run = sX - sunX; phi = Math.atan2(rise, run) - 0.5 * Math.PI;
 
 
Prevent quadrant error.
 
if (sunTheta > 90) {phi = phi - Math.PI}
 
 
Send to the drawCrescent function the index of the object to be drawn (k), plus its position on the screen (sX, sY), its angular size (plotsize), the phase angle (theta), and the orientation (phi).
plotsize, sX and sY were computed a few lines before the crescent code since they're the same whether the user chooses to display crescents or not.
 
drawCrescentA(k, sX, sY, plotsize, theta, phi);
 
The function drawCrescent takes this info and:
1. Draws a semi circle representing the dark limb of the object.
2. A semi ellipse representing the terminator (day/night line).
3. Colors this closed shape with the object's shadow color.
4. Draws another semi circle representing the bright limb of the object.
5. Redraws the same semi ellipse representing the terminator.
6. Colors this closed shape with the object's color.
Back to top
 
« Last Edit: 12/13/15 at 18:21:21 by Tony »  
Email View Profile WWW   IP Logged
Tony
YaBB Administrator
*****




Posts: 1051
Gender: male
Re: New Gravity Simulator
Reply #23 - 12/13/15 at 18:40:42
 
Quote from frankuitaalst on 12/12/15 at 11:28:53:
I'm really fascinated about some new features in the html version of the GravSim simulator...

It also has realistic stars.
I won't be able to see this in San Francisco, but here's a view from Brussels of the Moon occulting Aldebaran on the night before the night before Christmas.
http://orbitsimulator.com/gravitySimulatorCloud/simulations/1450059732001_Moon_O ccults_Aldebaran.html
Back to top
 
 
Email View Profile WWW   IP Logged
frankuitaalst
Ultimate Member
*****


Great site

Posts: 1507
Gender: male
Re: New Gravity Simulator
Reply #24 - 12/14/15 at 11:43:32
 
Just one word to above posts Tony : waw !  
Great job !  
 
Edit : thought the DrawCrescent() was a standard function in html , but after looking at the code I see the function is coded as the parts you describe in the previous post . Nice !  
Second Edit : any chance the code may be extended with the anaglyph viewing function ? Would be nice to get some depth in the screen . I see parallel vieuwing is already inplemented . The step to anaglyph may therfor be possible .
Back to top
 
« Last Edit: 12/14/15 at 14:20:46 by frankuitaalst »  
Email View Profile   IP Logged
Tony
YaBB Administrator
*****




Posts: 1051
Gender: male
Re: New Gravity Simulator
Reply #25 - 12/14/15 at 21:18:53
 
Yes, I had to write drawCrescent.
 
The code already has anaglyph view.
 
Going back to a slightly older version, here's an example:
http://orbitsimulator.com/gravitySimulatorCloud/simulations/1450155652482_3d.htm l
 
In the newer versions, you use the 3d checkbox to turn on or off the stereo mode.
 
You can control the baseline and swap views with the "crosseye" or "parallel" options.
 
I don't like red/blue glasses, so I never tinted the images.  Instead, send away for the "Owl Viewer", invented by astrophysicist Brian May (also the guitarist for Queen [We will we will rock you!]). http://www.londonstereo.com/shop_home3.html
If you have a very high res display like most current tablets have, you can't even see the pixels through the magnifying glasses.  But if you don't, you can always take very-hi res screen shots and print them just like family photos at the local drug store.  If you get the baseline properly adjusted, the images pop out at you just like 3-d movies.
 
If it doesn't make you dizzy or give you headaches, you can always just cross your eyes and make a free 3d image.  No glasses or viewer required!
 
This also explains why the code has drawCrescentA() and drawCrescentB().  A is the left image, and B is the right.
Back to top
 
 
Email View Profile WWW   IP Logged
Pages: 1 2 
Send Topic Print