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
94362057
Commit
94362057
authored
6 years ago
by
arnaud.devevey
Browse files
Options
Downloads
Patches
Plain Diff
pentecote
parent
53d77f07
No related branches found
No related tags found
No related merge requests found
Pipeline
#6013
failed
6 years ago
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
perso/box.c
+24
-13
24 additions, 13 deletions
perso/box.c
perso/box.h
+2
-2
2 additions, 2 deletions
perso/box.h
perso/star.c
+16
-5
16 additions, 5 deletions
perso/star.c
with
42 additions
and
20 deletions
perso/box.c
+
24
−
13
View file @
94362057
...
...
@@ -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) : (
x
0;
y
0)
(x1/2;y1/2)
box1 (ur) : (x1/2;
y
0)
(x1;y1/2)
box2 (ll) : (
x
0;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
)
{
...
...
This diff is collapsed.
Click to expand it.
perso/box.h
+
2
−
2
View file @
94362057
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
perso/star.c
+
16
−
5
View file @
94362057
...
...
@@ -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;
}
...
...
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