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
414f9686
Commit
414f9686
authored
6 years ago
by
arnaud.devevey
Browse files
Options
Downloads
Patches
Plain Diff
10h
parent
f6d46722
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#6093
failed
6 years ago
Stage: test
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
perso/galaxy.c
+1
-1
1 addition, 1 deletion
perso/galaxy.c
perso/star.c
+30
-36
30 additions, 36 deletions
perso/star.c
perso/star.h
+1
-2
1 addition, 2 deletions
perso/star.h
perso/vector.c
+1
-1
1 addition, 1 deletion
perso/vector.c
perso/vector.h
+2
-0
2 additions, 0 deletions
perso/vector.h
with
35 additions
and
40 deletions
perso/galaxy.c
+
1
−
1
View file @
414f9686
...
...
@@ -64,7 +64,7 @@ int main(int argc, char **argv) {
}
else
{
printf
(
"Nombre d'arguments non valide"
);
printf
(
"
\n
Nombre d'arguments non valide
\n\n
"
);
exit
(
1
);
}
}
...
...
This diff is collapsed.
Click to expand it.
perso/star.c
+
30
−
36
View file @
414f9686
...
...
@@ -17,30 +17,15 @@ Star* new_star_vel(Vector new_pos, Vector new_speed, Vector new_acc, double new_
new_star
->
acc
=
new_acc
;
new_star
->
mass
=
new_mass
;
// copie mais en pointeur de speed
Vector
*
p_speed
=
new_vec
(
new_speed
.
x
,
new_speed
.
y
);
// est-ce que c'est égal à &new_speed ?
// on multiplie le vecteur speed par delta_t (qui retourne un pointeur sur vecteur, que l'on déréférence)
Vector
*
pos_tmp
=
mul_vec
(
p
_speed
,
new_dt
);
Vector
*
pos_tmp
=
mul_vec
(
&
new
_speed
,
new_dt
);
new_star
->
previous_pos
=
*
pos_tmp
;
free
(
pos_tmp
);
free
(
p_speed
);
// copie mais en pointeur de previous_pos
Vector
*
p_pre_pos
=
new_vec
(
new_star
->
previous_pos
.
x
,
new_star
->
previous_pos
.
y
);
// copie mais en pointeur de pos
Vector
*
p_pos
=
new_vec
(
new_star
->
pos
.
x
,
new_star
->
pos
.
y
);
// et on soustrait ce résultat au vecteur position (qui retourne un pointeur sur vecteur, que l'on déréférence)
pos_tmp
=
sub_vec
(
p_pre
_pos
,
p_
pos
);
pos_tmp
=
sub_vec
(
&
(
new_star
->
previous
_pos
)
,
&
(
new_star
->
pos
)
)
;
new_star
->
previous_pos
=
*
pos_tmp
;
free
(
pos_tmp
);
free
(
p_pre_pos
);
free
(
p_pos
);
pos_tmp
=
NULL
;
...
...
@@ -124,10 +109,11 @@ Vector random_speed(Vector r_i, double m_i) {
Star
*
super_star
(
Star
*
list_stars
,
int
size_list
)
{
Star
*
super_star
(
Star
*
list_stars
,
int
selection
,
int
size_list
)
{
Star
*
super_star
=
malloc
(
sizeof
(
Star
));
for
(
int
i
=
0
;
i
<
size_list
;
i
++
)
{
if
(
i
!=
selection
)
{
// position
super_star
->
pos
.
x
+=
list_stars
[
i
].
pos
.
x
;
super_star
->
pos
.
y
+=
list_stars
[
i
].
pos
.
y
;
...
...
@@ -139,13 +125,7 @@ Star* super_star(Star* list_stars, int size_list) {
// masse
super_star
->
mass
+=
list_stars
[
i
].
mass
;
}
// ne donne pas la même chose si on fait /= 2 pour chaque boucle for
super_star
->
pos
.
x
/=
size_list
;
super_star
->
pos
.
y
/=
size_list
;
super_star
->
acc
.
x
/=
size_list
;
super_star
->
acc
.
y
/=
size_list
;
super_star
->
mass
/=
size_list
;
}
return
super_star
;
}
...
...
@@ -207,9 +187,9 @@ void tests_star() {
Vector
*
acceleration
=
new_vec
(
4
.
0
,
5
.
0
);
Star
*
s1
=
new_star_vel
(
*
position
,
*
speed
,
*
acceleration
,
MASSE_MIN
,
DELTA_T
);
print_star
(
s1
);
// print_star(s1);
tests_star_new
(
s1
);
free
(
s1
);
...
...
@@ -220,3 +200,17 @@ void tests_star() {
printf
(
"
\n
"
);
}
void
tests_star_new
(
Star
*
s
)
{
Star
star_test
;
double
x
=
4
.
0
;
double
y
=
5
.
0
;
//star_test.previous_pos = ;
//star_test.acc = ;
//star_test.mass = ;
TEST
(
s
->
pos
.
x
==
x
&&
s
->
pos
.
y
==
y
&&
\
s
->
previous_pos
.
x
==
x
&&
s
->
previous_pos
.
y
==
y
&&
\
s
->
acc
.
x
==
x
&&
s
->
acc
.
y
==
y
&&
\
s
->
mass
==
1e20
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
perso/star.h
+
1
−
2
View file @
414f9686
#ifndef __STAR_H__
#define __STAR_H__
#include
"vector.h"
#define MASSE_MIN 1e20
...
...
@@ -70,7 +69,7 @@ Vector random_speed(Vector r_i, double m_i);
// calcule une super etoile d'après le poids et la position d'un groupe d'étoiles
Star
*
super_star
(
Star
*
list_stars
,
int
size_list
);
Star
*
super_star
(
Star
*
list_stars
,
int
selection
,
int
size_list
);
int
random_10
();
double
random_1
();
...
...
This diff is collapsed.
Click to expand it.
perso/vector.c
+
1
−
1
View file @
414f9686
#include
"vector.h"
#include
"tests.h"
...
...
This diff is collapsed.
Click to expand it.
perso/vector.h
+
2
−
0
View file @
414f9686
...
...
@@ -7,6 +7,8 @@
#include
<stdlib.h>
#include
<stdio.h>
#include
"tests.h"
/* * * * * * * * * * * * * * * * *
...
...
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