A Space & astronomy forum. SpaceBanter.com

Go Back   Home » SpaceBanter.com forum » Astronomy and Astrophysics » Astronomy Misc
Site Map Home Authors List Search Today's Posts Mark Forums Read Web Partners

gravity simulator - initial galaxy positions



 
 
Thread Tools Display Modes
  #1  
Old May 26th 05, 03:36 AM
Gerald Kaszuba
external usenet poster
 
Posts: n/a
Default gravity simulator - initial galaxy positions

Hi there

I'm not sure if this is the right place to ask, but I've written an
open-source gravity simulator using the barnes hut (oct-tree) method
(It's called "gravit" - google it if you want to check it out). My math
isn't so good -- I'm trying to work out how to 'spawn' galaxies on an
abitrary angle. Right now I'm able to start them on the X, Y or Z plane.
I'll write some psudeocode to explain myself better:

for each particle
distanceFromCenter = random(0 to galaxyRadius)
angle = random(0 to 2 * pi)
position.x = cos(angle) * distanceFromCenter
position.y = sin(angle) * distanceFromCenter
position.z = 0
velocity.x = cos(angle + pi / 2) * distanceFromCenter * 0.0001
velocity.y = sin(angle + pi / 2) * distanceFromCenter * 0.0001
velocity.z = 0
next

It looks like this:
http://gravit.slowchop.com/screenies/spiral-galaxy.jpg

That creats a circlular pattern of random particles, with velocities
going at a perpendicular angle to the center -- but only on the Z plane.
How can I rotate the galaxy to not be fixed to a plane, but a random angle?

Thanks

Gerald
  #2  
Old May 27th 05, 03:50 AM
Greg Neill
external usenet poster
 
Posts: n/a
Default

"Gerald Kaszuba" wrote in message ...
Hi there

I'm not sure if this is the right place to ask, but I've written an
open-source gravity simulator using the barnes hut (oct-tree) method
(It's called "gravit" - google it if you want to check it out). My math
isn't so good -- I'm trying to work out how to 'spawn' galaxies on an
abitrary angle. Right now I'm able to start them on the X, Y or Z plane.
I'll write some psudeocode to explain myself better:

for each particle
distanceFromCenter = random(0 to galaxyRadius)
angle = random(0 to 2 * pi)
position.x = cos(angle) * distanceFromCenter
position.y = sin(angle) * distanceFromCenter
position.z = 0
velocity.x = cos(angle + pi / 2) * distanceFromCenter * 0.0001
velocity.y = sin(angle + pi / 2) * distanceFromCenter * 0.0001
velocity.z = 0
next

It looks like this:
http://gravit.slowchop.com/screenies/spiral-galaxy.jpg

That creats a circlular pattern of random particles, with velocities
going at a perpendicular angle to the center -- but only on the Z plane.
How can I rotate the galaxy to not be fixed to a plane, but a random angle?


You could generate it "on the Z plane" as you say, and then apply
a coordinate rotation to each point to rotate the body to some
arbitrary orientation. Google coordinate rotation.


  #3  
Old May 28th 05, 05:06 AM
Gerald Kaszuba
external usenet poster
 
Posts: n/a
Default

Greg Neill wrote:
"Gerald Kaszuba" wrote in message ...

How can I rotate the galaxy to not be fixed to a plane, but a random angle?


You could generate it "on the Z plane" as you say, and then apply


Woops! I meant the XY plane.

a coordinate rotation to each point to rotate the body to some
arbitrary orientation. Google coordinate rotation.


That did it, thanks.

Gerald
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
GR begets gravity begot from Newton's 1st Law is false, whereas gravity Archimedes Plutonium Astronomy Misc 2 March 25th 05 09:18 PM
GRAVITATION AND QUANTUM MECHANICS GRAVITYMECHANIC2 Astronomy Misc 0 December 13th 04 03:17 AM
The Gravitational Instability Theory on the Formation of the Universe Br Dan Izzo Policy 6 September 7th 04 09:29 PM
Gravity as Falling Space Henry Haapalainen Science 1 September 4th 04 04:08 PM
A dialogue between Mr. Big BANG and Mr. Steady STATE Marcel Luttgens Astronomy Misc 12 August 6th 03 06:15 AM


All times are GMT +1. The time now is 07:15 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 SpaceBanter.com.
The comments are property of their posters.