![]() |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
"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
|
|||
|
|||
![]()
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 | |
|
|
![]() |
||||
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 |