Commit 7d1dbcb9 authored by Stephen D's avatar Stephen D
Browse files

More config options

parent c39da79a
......@@ -78,24 +78,32 @@ void itoa(int n, char s[])
}
//END SO
#define numStars 10000
int w = 1000;
int h = 1000;
double max_component_vel = 3;
/* CONFIGURATION OPTIONS */
#define numStars 100000
const int w = 1920; //image width
const int h = 1080; //image height
const int spawnSize = 500; //Centered on center of image
const double max_component_vel = 10;
const int num_iterations = 10000;
/* END CONFIGURATION OPTIONS */
RigidMass_t stars[numStars];
void generateStars()
{
int randAddonX = w/2 - spawnSize/2;
int randAddonY = h/2 - spawnSize/2;
RigidMass_t new;
new.mass = 500000000000;
new.mass = 50000000000;
new.dvx = 0;
new.dvy = 0;
new.tick_time = 0.05;
for(int i = 0; i < numStars; i++)
{
new.x = rand() % 250 + 375; //375 to 625
new.y = rand() % 250 + 375;
new.x = rand() % spawnSize + randAddonX;
new.y = rand() % spawnSize + randAddonY;
double dx = new.x - w / 2;
double dy = new.y - h / 2;
......@@ -110,10 +118,10 @@ void generateStars()
new.vx = -new.vy * dy / dx;
}
if(new.y < new.x)
if(dx > dy)
{
new.vy = -new.vy;
new.vx = -new.vx;
new.vx *= -1;
new.vy *= -1;
}
stars[i] = new;
......@@ -127,6 +135,11 @@ void iterate()
{
for(int b = 0; b < numStars; b++)
{
//If stars are closer than 0.1 units apart, we don't calculate the force on each other
//this is important since we're stepping through time. If we end up with two stars ridiculously
//close together, the math will act as if they were in that position for the entire tick,
//whereas they would likely only be there for a small fraction of that.
//we don't want any stars to be flung away at a fraction of the speed of light!
if(abs(stars[a].x - stars[b].x) > 0.1 && abs(stars[a].y - stars[b].y) > 0.1)
{
//printf("%d, %d \r\n", stars[a].dvx, stars[a].dvy);
......@@ -175,7 +188,7 @@ int main()
generateStars();
for(int i = 0; i < 1000; i++)
for(int i = 0; i < num_iterations; i++)
{
iterate();
addToImage();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment