Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

How to move the solar system?

$
0
0

Hey guys, I´m Theresa, student of Visual Communication in Germany, so English is not my native language and I am new in processing but I will try my best, so here is my question. I try to simulate a moving solar system in processing with all physics components like gravitation, forces, velocity, acceleration, positions etc. the coordinates I got from the nasa website. I have two mainly problems. the first is the physic, I don't know, if the calculating methods are right and the second problem is that only one planet is visible but I defined two. Ah, and it must be ready till Monday :-P please, could anyone help me? Here is my code:

/////// SONNE zum 1.1. 2000
/////// X = -7.139143380212697E-03 Y = -2.792019770161695E-03 Z = 2.061838852554664E-04
/////// VX= 5.374260940168566E-06 VY=-7.410965396701423E-06 VZ=-2.522925180072137E-03

/////// MERKUR zum 1.1. 2000
/////// X =-1.478672233442572E-01 Y =-4.466929775364947E-01 Z =-2.313937582786785E-02
/////// VX= 2.117424563261189E-02 VY=-7.105386404267509E-03 VZ=-2.522925180072137E-03

/////// VENUS zum 1.1. 2000
/////// X =-7.257693602841776E-01 Y =-2.529582082587794E-02 Z = 4.137802526208009E-02
/////// VX= 5.189070188671265E-04 VY=-2.031355258779472E-02 VZ=-3.072687386494688E-04

/////// ERDE zum 1.1. 2000
/////// X =-1.756637922977122E-01   Y = 9.659912850526895E-01   Z = 2.020629118443605E-04
/////// VX=-1.722857156974862E-02   VY=-3.015071224668472E-03   VZ=-5.859931223618532E-08

/////// MARS zum 1.1. 2000
/////// X = 1.383221922520998E+00 Y =-2.380174081741852E-02 Z =-3.441183028447500E-02
/////// VX= 7.533013850513376E-04 VY= 1.517888771209419E-02 VZ= 2.996589710207392E-04

/////// https://rechneronline.de/planeten/masse.php

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

PVector pos;
PVector vel;
PVector acc;
float mas;
float deltaT;
float far;

Boid Erde = new Boid(
new PVector(-1.756637922977122E-01, 9.659912850526895E-01, 2.020629118443605E-04),
new PVector(-1.722857156974862E-02, -3.015071224668472E-03, -5.859931223618532E-08),
new PVector(0, 0, 0),
0.000002988,
0.999,
255);

Boid Venus = new Boid(
new PVector(-7.257693602841776E-01, -2.529582082587794E-02, 4.137802526208009E-02),
new PVector(5.189070188671265E-04, -2.031355258779472E-02, -3.072687386494688E-04),
new PVector(0, 0, 0),
0.000002448,
0.999,
155);

PeasyCam cam;

void setup() {
  size(1600, 1200, P3D);
  background(150);
  frameRate(10);
  cam = new PeasyCam(this, 10000);
}


void draw() {
  lights();
  translate(width / 2, height / 2);
  scale(2000);
  Erde.bewegDich();
  Erde.zeichneDich();
  Venus.bewegDich();
  Venus.zeichneDich();
}

and than a second tab called "boid"

class Boid {
  Boid(PVector position, PVector velocity, PVector acceleration, float masse, float deltaZeit, float farbe) {
    pos = position;
    vel = velocity;
    acc = acceleration;
    mas = masse;
    deltaT = deltaZeit;
    far = farbe;
  }

  void bewegDich() {
    PVector posS = new PVector();
    float masS = 1;                                     // Sonne in Sonnenmassen
    float G_SI = 6.674E-11;                             // m^3 kg^-1 s^-2
    float sekundenTag;
    float kiloSonnenmassen;
    float meterAE;
    float Grav;

    float r = PVector.dist(posS, pos);                  //muss in AE umgerechnet werden
    sekundenTag = (24 * 60 * 60);
    kiloSonnenmassen = 1.98892E+30;
    meterAE = (1 / (1.49597E+11));
    Grav = (G_SI * (sekundenTag * sekundenTag) * kiloSonnenmassen * (meterAE * meterAE * meterAE));               // 0.017204072^2
    PVector Anziehungskraft = (PVector.sub(posS, pos)).mult(Grav * mas * masS * (1 / (r * r * r)));               // anziehungskraft der sonne

    acc = PVector.div(Anziehungskraft, mas);
    vel = PVector.add(vel, (acc.mult(deltaT)));
    pos = PVector.add(pos, vel);                                                                                  // DIE GESCHWINDIGKEIT WIRD AUF DIE POSITION AUFADDIERT
    acc = PVector.mult(acc, 0);
  }

  void zeichneDich() {
    background(0);
    println(pos);
    pushMatrix();                                       // ändert die koordinaten innerhalb von push/pop matrix
    translate(pos.x, pos.y, pos.z);
    fill(far);
    noStroke();
    sphere(0.1);
    popMatrix();
  }
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles