Skip to content
Snippets Groups Projects
Commit 94362057 authored by arnaud.devevey's avatar arnaud.devevey
Browse files

pentecote

parent 53d77f07
No related branches found
No related tags found
No related merge requests found
Pipeline #6013 failed
......@@ -8,7 +8,7 @@
* *
* * * * * * * * * * * * * * * * */
Box* new_box(double new_x0, double new_x1, double new_y0, double new_y1) {
Box* new_box(double new_x0, double new_y0, double new_x1, double new_y1) {
Box* temp_box = malloc(sizeof(Box));
if (new_x0 > new_x1) {
......@@ -32,27 +32,37 @@ Box* new_box(double new_x0, double new_x1, double new_y0, double new_y1) {
}
Box* divide_in_four(Box box) {
Box* sub_boxes = malloc(sizeof(Box) * 4);
// retourner quatre box
Box* divide_in_four(Box* box) {
/*
x0 = 0 y0 = 0
(x0 ; y0)
-------------------
| |
| |
| |
------------------- x1 = 5 y1 = 3
------------------- (x1 ; y1)
box0 (ul) : (0;0) (x1/2;y1/2)
box1 (ur) : (x1/2;0) (x1;y1/2)
box2 (ll) : (0;y1/2) (x1/2;y1)
box0 (ul) : (x0;y0) (x1/2;y1/2)
box1 (ur) : (x1/2;y0) (x1;y1/2)
box2 (ll) : (x0;y1/2) (x1/2;y1)
box3 (lr) : (x1/2;y1/2) (x1;y1)
*/
Box* b0 = new_box(box -> x0, box -> y0, box -> x1/2, box -> y1/2);
Box* b1 = new_box(box -> x1/2, box -> y0, box -> x1, box -> y1/2);
Box* b2 = new_box(box -> x0, box -> y1/2, box -> x1/2, box -> y1);
Box* b3 = new_box(box -> x1/2, box -> y1/2, box -> x1, box -> y1);
// pointeur ou pas?
Box* sub_boxes[] = malloc(4 * sizeof(Box*));
sub_boxes[0] = b0;
sub_boxes[1] = b1;
sub_boxes[2] = b2;
sub_boxes[3] = b3;
return sub_boxes;
......@@ -95,8 +105,8 @@ void print_box(Box box) {
void tests_box() {
printf("TESTS BOX : \n");
Box* b1 = new_box(0.0, 3.0, 0.0, 3.0);
Box* b2 = divide_in_four(*b1);
Box* b1 = new_box(0.0, 0.0, 3.0, 3.0);
Box* b2 = divide_in_four(b1);
tests_box_new(b1);
......@@ -116,6 +126,7 @@ void tests_box_new(Box* b1) {
void tests_box_divide(Box* b2) {
// COMPLETER APRES AVOIR FINI DIVIDE()
printf("bla");
}
void tests_box_include(Box* b1) {
......
......@@ -23,10 +23,10 @@ typedef struct __box {
* * * * * * * * * * * * * * * * */
// crée une nouvelle box
Box* new_box(double new_x0, double new_x1, double new_y0, double new_y1);
Box* new_box(double new_x0, double new_y0, double new_x1, double new_y1);
// divise une box en quatre parties égales
Box* divide_in_four(Box box);
Box* divide_in_four(Box* box);
// détérmine si une position est dans la box
bool is_inside(Box box, Vector vector);
......
......@@ -67,15 +67,26 @@ void print_star(const Star* const star) {
}
/*
il faut deja faire une liste de stars qui se trouvent dans une box
Star* super_star(Star* list_stars) {
// il faut deja faire une liste de stars qui se trouvent dans une box
Star* super_star(Star* list_stars, int size_list) {
Star* super_star = malloc(sizeof(Star))
for (int i = 0; i < list_stars.len() MARCHE PAS COMME CA; i++) {
super_star -> pos += list_stars[i] -> pos;
for (int i = 0; i < size_list; i++) {
// position
super_star -> pos -> x += list_stars[i] -> pos -> x;
super_star -> pos -> y += list_stars[i] -> pos -> y;
// accélération
super_star -> acc -> x += list_stars[i] -> acc -> x;
super_star -> acc -> y += list_stars[i] -> acc -> y;
// masse
super_star -> mass -> x += list_stars[i] -> pos -> masse;
}
super_star -> # /= list_stars.len()
// ne donne pas la même chose si on fait /= 2 pour chaque boucle for
super_star -> mass /= size_list;
return super_star;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment