big bang theory

edited December 2016 in Library Questions

Hello everyone; I am trying to create a simulation for Big Bang Theory. I would like to create a sphere in the middle then make it explode and then I would like to create the sun(as a new sphere) and the solar system.

I tried my best but something is definitely not working as I want. I would appreciate If you guys can help me. It is very urgent since it is my final project.

import peasy.org.apache.commons.math.geometry.*;

PeasyCam cam; Planet sun; Particle [] particles = new Particle [800]; Sun mySun;

void setup () {

size (700, 700, P3D); smooth (); cam = new PeasyCam(this, 700); sun = new Planet(40, 0, 0); sun.spawnMoons(3, 1); for (int i=0; i<particles.length; i++) { particles [i] = new Particle (); }

mySun = new Sun(); }

void draw () { background (0); //clear the background for (int i=0; i<particles.length; i++) { particles[i].update(); } float time= millis(); if (millis() > 5500) { mySun.display(); time= millis (); }

if ( millis() >7500) { lights(); sun.display(); sun.orbit(); time= millis(); } }

class Particle {

float x; float y;

float aX; // speed float aY;

Particle () { //x and y position to be in middle of screen x = width/2; y = height/2;

aX = random (-10,10);
aY = random (-10,15);

}

void update () {

x+=aX;
y+=aY;

fill (255);
ellipse (x,y,7,7);

} }

class Planet { // solar system works as I want float radius; float distance;

Planet[] planets; float angle; float orbitspeed; PVector v; PShape globe;

Planet(float r, float d, float o) {

v = PVector.random3D();

radius = r;
distance = d;
v.mult(distance);
angle = random(PI-45);
orbitspeed = o;

}

void orbit() { angle = angle + orbitspeed; if (planets != null) { for (int i = 0; i < planets.length; i++) { planets[i].orbit(); } } }

void spawnMoons(int total, int level) { planets = new Planet[total]; for (int i = 0; i < planets.length; i++) { float r = radius/(level2); float d = random((radius + r), (radius+r)2); float o = random(-0.1, 0.1); planets[i] = new Planet(r, d, o); if (level < 2) { int num = int(random(0, 3)); planets[i].spawnMoons(num, level+1); } } }

void display() { pushMatrix(); noStroke(); PVector v2 = new PVector(1, 0, 1); PVector p = v.cross(v2); rotate(angle, p.x, p.y, p.z); stroke(255);

translate(v.x, v.y, v.z);
noStroke();
fill(170);
sphere(radius);
if (planets != null) {
  for (int i = 0; i < planets.length; i++) {
    planets[i].display();
  }
}
popMatrix();

} } class Sun { // the sphere I want to explode

void display(){ lights();

pushMatrix(); translate(350, 350, 0); noStroke(); fill(255); sphere(40); popMatrix(); } }

Answers

  • Unreadable

    Edit post, highlight code, press Ctrl-o

  • I tried my best but something is definitely not working as I want

    So what is working and what is not working.? You have to provide specific details so to get proper answers. And how are you creating planets from a single big bang.? Again provide details as nobody is familiar with your codenor your model.

    Kf

  • edited December 2016 Answer ✓

    Where did a Sun and Planets come into Big Bang???
    It took millions (billions) of years before all that came in.
    Atleast start from a blank sketch instead of trying to improvise on an existing one.

    I am assuming you want a realistic simulation of the big bang. Now, you need to figure out how to simulate an explosion. Answer - you need particle systems (I notice you already have one).
    And how much detail is required? And what about performance? And how much time do you want to simulate? Just after the Big Bang (which would just be a big explosion) or for billions of years later (far more difficult)?

  • It is a huge task...

    because of the huge time passing between big bang and the first suns

    you could counter that in making text pages in between:

    • text In the beginning there was the big bang

    • animation: sphere explodes

    • text: over million of years the explosion expanded... swirls of dust condensed

    • animation : dust that rotates and condensed to a sun and a planet

  • In reality, a sphere probably never existed before Big Bang. So what you need is just an explosion coming out of "nowhere".

Sign In or Register to comment.