Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tp_8_galaxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
arnaud.devevey
tp_8_galaxy
Commits
53d77f07
Commit
53d77f07
authored
6 years ago
by
arnaud.devevey
Browse files
Options
Downloads
Patches
Plain Diff
star avance
parent
302e5235
No related branches found
No related tags found
No related merge requests found
Pipeline
#5985
failed
6 years ago
Stage: test
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
perso/Makefile
+1
-1
1 addition, 1 deletion
perso/Makefile
perso/box.c
+4
-11
4 additions, 11 deletions
perso/box.c
perso/box.h
+3
-0
3 additions, 0 deletions
perso/box.h
perso/galaxy.c
+2
-2
2 additions, 2 deletions
perso/galaxy.c
perso/star.c
+40
-6
40 additions, 6 deletions
perso/star.c
with
50 additions
and
20 deletions
perso/Makefile
+
1
−
1
View file @
53d77f07
CC
=
gcc
CC
=
gcc
CARGS
=
-std
=
c11
-Wall
-Wextra
-fsanitize
=
address
-fsanitize
=
leak
-fsanitize
=
undefined
CARGS
=
-g
-std
=
c11
-Wall
-Wextra
-fsanitize
=
address
-fsanitize
=
leak
-fsanitize
=
undefined
LARGS
=
-lm
-lSDL2
LARGS
=
-lm
-lSDL2
all
=
box galaxy quadtree star vector
all
=
box galaxy quadtree star vector
...
...
This diff is collapsed.
Click to expand it.
perso/box.c
+
4
−
11
View file @
53d77f07
...
@@ -72,15 +72,15 @@ double compute_length(Box box) {
...
@@ -72,15 +72,15 @@ double compute_length(Box box) {
double
height
=
box
.
x1
-
box
.
x0
;
double
height
=
box
.
x1
-
box
.
x0
;
double
width
=
box
.
y1
-
box
.
y0
;
double
width
=
box
.
y1
-
box
.
y0
;
printf
(
"
\t
print_box
() : la hauteur de la box est : %
d
"
,
height
);
printf
(
"
\t
compute_length
() : la hauteur de la box est : %
f
"
,
height
);
printf
(
"
\t
print_box
() : la largeur de la box est : %
d
"
,
width
);
printf
(
"
\t
compute_length
() : la largeur de la box est : %
f
"
,
width
);
return
2
.
0
;
return
2
.
0
;
}
}
void
print_box
(
Box
box
)
{
void
print_box
(
Box
box
)
{
printf
(
"
\t
print_box() :
x0 = %f
\t
x1 = %f
\t
y0 = %f
\t
y1 =
%f
\n
"
,
box
.
x0
,
box
.
x1
,
box
.
y0
,
box
.
y1
);
printf
(
"
\t
print_box() :
coin haut-gauche : (%f;%f) / coin bas-droite : (%f;
%f
)
\n
"
,
box
.
x0
,
box
.
y0
,
box
.
x1
,
box
.
y1
);
}
}
...
@@ -115,14 +115,7 @@ void tests_box_new(Box* b1) {
...
@@ -115,14 +115,7 @@ void tests_box_new(Box* b1) {
}
}
void
tests_box_divide
(
Box
*
b2
)
{
void
tests_box_divide
(
Box
*
b2
)
{
Box
*
b_divide
=
new_box
(
0
.
0
,
1
.
5
,
0
.
0
,
1
.
5
);
// COMPLETER APRES AVOIR FINI DIVIDE()
TEST
(
b2
->
x0
==
b_divide
->
x0
&&
b2
->
x1
==
b_divide
->
x1
&&
b2
->
y0
==
b_divide
->
y0
&&
b2
->
y1
==
b_divide
->
y1
)
free
(
b_divide
);
}
}
void
tests_box_include
(
Box
*
b1
)
{
void
tests_box_include
(
Box
*
b1
)
{
...
...
This diff is collapsed.
Click to expand it.
perso/box.h
+
3
−
0
View file @
53d77f07
...
@@ -39,5 +39,8 @@ void print_box(Box box);
...
@@ -39,5 +39,8 @@ void print_box(Box box);
void
tests_box
();
void
tests_box
();
void
tests_box_new
(
Box
*
b1
);
void
tests_box_divide
(
Box
*
b2
);
void
tests_box_include
(
Box
*
b1
);
#endif
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
perso/galaxy.c
+
2
−
2
View file @
53d77f07
...
@@ -65,12 +65,12 @@ int main(int argc, char **argv) {
...
@@ -65,12 +65,12 @@ int main(int argc, char **argv) {
* --- FONCTIONS --- *
* --- FONCTIONS --- *
* *
* *
* * * * * * * * * * * * * * * * */
* * * * * * * * * * * * * * * * */
/*
Galaxy* create_and_init_galaxy(int nb_bodies, Box box, double delta_t) {
Galaxy* create_and_init_galaxy(int nb_bodies, Box box, double delta_t) {
}
}
/*
void reset_acc_galaxy(Galaxy* galaxy) {
void reset_acc_galaxy(Galaxy* galaxy) {
}
}
...
...
This diff is collapsed.
Click to expand it.
perso/star.c
+
40
−
6
View file @
53d77f07
#include
<math.h>
#include
"star.h"
#include
"star.h"
#define MASSE_MIN
math.pow(10,
20
)
#define MASSE_MIN
1e
20
#define MASSE_SOLAIRE
(
1.98892
* math.pow(10, 30))
#define MASSE_SOLAIRE 1.98892
e30
#define DELTA_T
(math.pow(10, 10))
// discrétisation temporelle
#define DELTA_T
1e10
// discrétisation temporelle
/* * * * * * * * * * * * * * * * *
/* * * * * * * * * * * * * * * * *
* *
* *
...
@@ -18,9 +19,16 @@ Star* new_star_vel(Vector new_pos, Vector new_speed, Vector new_acc, double new_
...
@@ -18,9 +19,16 @@ Star* new_star_vel(Vector new_pos, Vector new_speed, Vector new_acc, double new_
new_star
->
pos
=
new_pos
;
new_star
->
pos
=
new_pos
;
// on multiplie le vecteur speed par delta_t (qui retourne un pointeur sur vecteur, que l'on déréférence)
// on multiplie le vecteur speed par delta_t (qui retourne un pointeur sur vecteur, que l'on déréférence)
new_star
->
previous_pos
=
*
(
mul_vec
(
&
new_speed
,
new_dt
));
Vector
*
pos_tmp
=
mul_vec
(
&
new_speed
,
new_dt
);
new_star
->
previous_pos
=
*
pos_tmp
;
free
(
pos_tmp
);
// et on soustrait ce résultat au vecteur position (qui retourne un pointeur sur vecteur, que l'on déréférence)
// et on soustrait ce résultat au vecteur position (qui retourne un pointeur sur vecteur, que l'on déréférence)
new_star
->
previous_pos
=
*
(
sub_vec
(
&
(
new_star
->
previous_pos
),
&
new_pos
));
pos_tmp
=
sub_vec
(
&
(
new_star
->
previous_pos
),
&
new_pos
);
new_star
->
previous_pos
=
*
pos_tmp
;
free
(
pos_tmp
);
pos_tmp
=
NULL
;
new_star
->
acc
=
new_acc
;
new_star
->
acc
=
new_acc
;
new_star
->
mass
=
new_mass
;
new_star
->
mass
=
new_mass
;
...
@@ -58,6 +66,21 @@ void print_star(const Star* const star) {
...
@@ -58,6 +66,21 @@ void print_star(const Star* const star) {
masse = %f
\n
"
,
star
->
pos
.
x
,
star
->
pos
.
y
,
star
->
previous_pos
.
x
,
star
->
previous_pos
.
y
,
star
->
acc
.
x
,
star
->
acc
.
y
,
star
->
mass
);
masse = %f
\n
"
,
star
->
pos
.
x
,
star
->
pos
.
y
,
star
->
previous_pos
.
x
,
star
->
previous_pos
.
y
,
star
->
acc
.
x
,
star
->
acc
.
y
,
star
->
mass
);
}
}
/*
il faut deja faire une liste de stars qui se trouvent dans une box
Star* super_star(Star* list_stars) {
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;
}
super_star -> # /= list_stars.len()
return super_star;
}
*/
...
@@ -70,9 +93,20 @@ void print_star(const Star* const star) {
...
@@ -70,9 +93,20 @@ void print_star(const Star* const star) {
void
tests_star
()
{
void
tests_star
()
{
printf
(
"TESTS STAR :
\n
"
);
printf
(
"TESTS STAR :
\n
"
);
Star
*
s1
=
malloc
(
sizeof
(
Star
));
Vector
*
position
=
new_vec
(
4
.
0
,
5
.
0
);
Vector
*
speed
=
new_vec
(
4
.
0
,
5
.
0
);
Vector
*
acceleration
=
new_vec
(
4
.
0
,
5
.
0
);
Star
*
s1
=
new_star_vel
(
*
position
,
*
speed
,
*
acceleration
,
MASSE_MIN
,
DELTA_T
);
print_star
(
s1
);
free
(
s1
);
free
(
s1
);
free
(
position
);
free
(
speed
);
free
(
acceleration
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment