Commit 8def9425 authored by dawid.dymarczy's avatar dawid.dymarczy
Browse files

finnal

parent c71985a8
No preview for this file type
#include "barnes.h"
#define G_const 100 //(6.674e-11)
#define G_const 0.001 //(6.674e-11)
quad* newNode(int data,double s, double x, double y){
quad * node = (quad*) malloc(sizeof(quad));
//si le malloc n'a pas fonctionneé abandonné
......@@ -312,7 +312,7 @@ void force_par_niveau(quad* node,body* bodies,point* Forces,int N_PARTICLES,doub
k = G_const * curr->b->mass/(r*r*r);
Forces[i].x +=v.x*k;
Forces[i].y +=v.y*k;
bodies[i].pos.x+=Forces[i].x/bodies[i].mass;
bodies[i].pos.y+=Forces[i].y/bodies[i].mass;
......@@ -373,7 +373,6 @@ void show_system_barnes(struct gfx_context_t *ctxt, quad* node) {
show_system_barnes(ctxt,node->SE);
show_system_barnes(ctxt,node->SW);
show_system_barnes(ctxt,node->NW);
gfx_present(ctxt);
}
//update your tree
......
......@@ -17,9 +17,9 @@ double rand_dbl() {
int main()
{
int N_DIMENSIONS = 2;
int N_PARTICLES=10;
double theta=0.5;
int seed=1655752223;//time(NULL);
int N_PARTICLES=500;
double theta=1;
int seed=time(NULL);//1655752223;//time(NULL);
srand(seed);
struct gfx_context_t *ctxt = gfx_create("Planetary system", SCREEN_WIDTH, SCREEN_HEIGHT);
if (!ctxt)
......@@ -46,7 +46,7 @@ int main()
}
quad* node = newNode(0,100,0,0);
quad* node = newNode(0,1000,0,0);
int trace =0;
......@@ -78,7 +78,7 @@ int main()
while (true){
//temps++;
gfx_present(ctxt);
gfx_clear(ctxt, COLOR_BLACK);
// draw_cadrillage(ctxt,SCREEN_WIDTH,SCREEN_HEIGHT,16);
show_system_barnes(ctxt,node);
// for (int i=0;i<N_PARTICLES;i++){
......@@ -86,21 +86,22 @@ int main()
// bodies[i].pos.y+=bodies[i].acc.y;
//}
sum(node);//relaclule le centre de masse de l'arbre et des branches
force_par_niveau(node,bodies,Forces,N_PARTICLES,0.5);
force_par_niveau(node,bodies,Forces,N_PARTICLES,theta);
// calculetteAcc_tree(node,node->b);
for(int i=0; i<N_PARTICLES;i++){
// printf("%d",i);
bodies[i].pos.x+=Forces[i].x/bodies[i].mass;
bodies[i].pos.y+=Forces[i].y/bodies[i].mass;
}
update_barnes_hut(node,delta_temps);
//draw_cadrillage(ctxt,SCREEN_WIDTH,SCREEN_HEIGHT,100);
//update_sim(node,delta_temps,Forces,bodies);
// for(uint32_t i =0;i<6000;i++);
// TODO : draw the current state of your system
gfx_clear(ctxt, COLOR_BLACK);
gfx_present(ctxt);
//show system
// TODO : update your system
//100 ici
......
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