Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Galaxy_Simulator
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
benjamin.sitbon
Galaxy_Simulator
Commits
408805fa
Commit
408805fa
authored
6 years ago
by
Benjamin-Sitbon
Browse files
Options
Downloads
Patches
Plain Diff
Comments
Comments added
parent
9b718668
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.idea/workspace.xml
+7
-10
7 additions, 10 deletions
.idea/workspace.xml
Vector.c
+35
-10
35 additions, 10 deletions
Vector.c
with
42 additions
and
20 deletions
.idea/workspace.xml
+
7
−
10
View file @
408805fa
...
@@ -10,10 +10,7 @@
...
@@ -10,10 +10,7 @@
</component>
</component>
<component
name=
"ChangeListManager"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"43aff179-c306-46b9-b69f-eca5306fbf96"
name=
"Default Changelist"
comment=
""
>
<list
default=
"true"
id=
"43aff179-c306-46b9-b69f-eca5306fbf96"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/Vector"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/Vector"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/Vector.c"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/Vector.c"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/Vector.c"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/Vector.c"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/Vector.o"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/Vector.o"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/makefile"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/makefile"
afterDir=
"false"
/>
</list>
</list>
<option
name=
"EXCLUDED_CONVERTED_TO_IGNORED"
value=
"true"
/>
<option
name=
"EXCLUDED_CONVERTED_TO_IGNORED"
value=
"true"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
...
@@ -26,8 +23,8 @@
...
@@ -26,8 +23,8 @@
<file
pinned=
"false"
current-in-tab=
"true"
>
<file
pinned=
"false"
current-in-tab=
"true"
>
<entry
file=
"file://$PROJECT_DIR$/Vector.c"
>
<entry
file=
"file://$PROJECT_DIR$/Vector.c"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"3
76
"
>
<state
relative-caret-position=
"3
42
"
>
<caret
line=
"
74
"
column=
"
14"
lean-forward=
"true
"
selection-start-line=
"
74
"
selection-start-column=
"
14
"
selection-end-line=
"
74
"
selection-end-column=
"
14
"
/>
<caret
line=
"
211
"
column=
"
97
"
selection-start-line=
"
211
"
selection-start-column=
"
97
"
selection-end-line=
"
211
"
selection-end-column=
"
97
"
/>
</state>
</state>
</provider>
</provider>
</entry>
</entry>
...
@@ -66,7 +63,7 @@
...
@@ -66,7 +63,7 @@
</list>
</list>
</option>
</option>
</component>
</component>
<component
name=
"ProjectFrameBounds"
extendedState=
"
6
"
>
<component
name=
"ProjectFrameBounds"
extendedState=
"
7
"
>
<option
name=
"x"
value=
"848"
/>
<option
name=
"x"
value=
"848"
/>
<option
name=
"y"
value=
"317"
/>
<option
name=
"y"
value=
"317"
/>
<option
name=
"width"
value=
"1050"
/>
<option
name=
"width"
value=
"1050"
/>
...
@@ -118,12 +115,12 @@
...
@@ -118,12 +115,12 @@
<option
name=
"number"
value=
"Default"
/>
<option
name=
"number"
value=
"Default"
/>
<option
name=
"presentableId"
value=
"Default"
/>
<option
name=
"presentableId"
value=
"Default"
/>
<updated>
1559227081243
</updated>
<updated>
1559227081243
</updated>
<workItem
from=
"1559227084365"
duration=
"1
5096
000"
/>
<workItem
from=
"1559227084365"
duration=
"1
6429
000"
/>
</task>
</task>
<servers
/>
<servers
/>
</component>
</component>
<component
name=
"TimeTrackingManager"
>
<component
name=
"TimeTrackingManager"
>
<option
name=
"totallyTimeSpent"
value=
"1
5096
000"
/>
<option
name=
"totallyTimeSpent"
value=
"1
6429
000"
/>
</component>
</component>
<component
name=
"ToolWindowManager"
>
<component
name=
"ToolWindowManager"
>
<frame
x=
"-7"
y=
"-7"
width=
"1550"
height=
"838"
extended-state=
"6"
/>
<frame
x=
"-7"
y=
"-7"
width=
"1550"
height=
"838"
extended-state=
"6"
/>
...
@@ -198,8 +195,8 @@
...
@@ -198,8 +195,8 @@
</entry>
</entry>
<entry
file=
"file://$PROJECT_DIR$/Vector.c"
>
<entry
file=
"file://$PROJECT_DIR$/Vector.c"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"3
76
"
>
<state
relative-caret-position=
"3
42
"
>
<caret
line=
"
74
"
column=
"
14"
lean-forward=
"true
"
selection-start-line=
"
74
"
selection-start-column=
"
14
"
selection-end-line=
"
74
"
selection-end-column=
"
14
"
/>
<caret
line=
"
211
"
column=
"
97
"
selection-start-line=
"
211
"
selection-start-column=
"
97
"
selection-end-line=
"
211
"
selection-end-column=
"
97
"
/>
</state>
</state>
</provider>
</provider>
</entry>
</entry>
...
...
This diff is collapsed.
Click to expand it.
Vector.c
+
35
−
10
View file @
408805fa
...
@@ -24,7 +24,9 @@ vec *new_vec(double x, double y){
...
@@ -24,7 +24,9 @@ vec *new_vec(double x, double y){
vec
*
add_vec
(
const
vec
*
const
v1
,
const
vec
*
const
v2
){
vec
*
add_vec
(
const
vec
*
const
v1
,
const
vec
*
const
v2
){
//Création d'un vecteur nul
vec
*
add_vec
=
new_vec
(
0
.
0
,
0
.
0
);
vec
*
add_vec
=
new_vec
(
0
.
0
,
0
.
0
);
//Addition des x et des y faite dans le nouveau vecteur
add_vec
->
x
=
v1
->
x
+
v2
->
x
;
add_vec
->
x
=
v1
->
x
+
v2
->
x
;
add_vec
->
y
=
v1
->
y
+
v2
->
y
;
add_vec
->
y
=
v1
->
y
+
v2
->
y
;
...
@@ -33,7 +35,10 @@ vec *add_vec(const vec *const v1, const vec *const v2){
...
@@ -33,7 +35,10 @@ vec *add_vec(const vec *const v1, const vec *const v2){
}
}
vec
*
sub_vec
(
const
vec
*
const
v1
,
const
vec
*
const
v2
){
vec
*
sub_vec
(
const
vec
*
const
v1
,
const
vec
*
const
v2
){
//Création d'un vecteur nul
vec
*
sub_vec
=
new_vec
(
0
.
0
,
0
.
0
);
vec
*
sub_vec
=
new_vec
(
0
.
0
,
0
.
0
);
//Soustraction des x et des y dans le nouveau vecteur
sub_vec
->
x
=
v1
->
x
-
v2
->
x
;
sub_vec
->
x
=
v1
->
x
-
v2
->
x
;
sub_vec
->
y
=
v1
->
y
-
v2
->
y
;
sub_vec
->
y
=
v1
->
y
-
v2
->
y
;
...
@@ -42,8 +47,9 @@ vec *sub_vec(const vec *const v1, const vec *const v2){
...
@@ -42,8 +47,9 @@ vec *sub_vec(const vec *const v1, const vec *const v2){
}
}
vec
*
mul_vec
(
double
alpha
,
const
vec
*
const
v2
)
{
vec
*
mul_vec
(
double
alpha
,
const
vec
*
const
v2
)
{
//Création d'un vecteur nul
vec
*
mul_vec
=
new_vec
(
0
.
0
,
0
.
0
);
vec
*
mul_vec
=
new_vec
(
0
.
0
,
0
.
0
);
//Multiplication du x et du y par le scalaire dans le nouveau vecteur
mul_vec
->
x
=
alpha
*
v2
->
x
;
mul_vec
->
x
=
alpha
*
v2
->
x
;
mul_vec
->
y
=
alpha
*
v2
->
y
;
mul_vec
->
y
=
alpha
*
v2
->
y
;
...
@@ -53,6 +59,7 @@ vec *mul_vec(double alpha, const vec *const v2) {
...
@@ -53,6 +59,7 @@ vec *mul_vec(double alpha, const vec *const v2) {
double
norm
(
const
vec
*
const
v1
){
double
norm
(
const
vec
*
const
v1
){
//La norme correspond a la racine carré de (x^2 + y^2), ici on fait puissance 1/2 qui est équivalent à racine carrée
double
norm
=
pow
((
pow
(
v1
->
x
,
2
.
0
)
+
pow
(
v1
->
y
,
2
.
0
)),
0
.
5
);
double
norm
=
pow
((
pow
(
v1
->
x
,
2
.
0
)
+
pow
(
v1
->
y
,
2
.
0
)),
0
.
5
);
return
norm
;
return
norm
;
...
@@ -61,6 +68,7 @@ double norm(const vec *const v1){
...
@@ -61,6 +68,7 @@ double norm(const vec *const v1){
double
distance
(
const
vec
*
const
v1
,
const
vec
*
const
v2
){
double
distance
(
const
vec
*
const
v1
,
const
vec
*
const
v2
){
//La distance correspond à la racine carré de (x2 - x1)^2 + (y2 -y1)^2
double
dist
=
pow
(
pow
((
v2
->
x
-
v1
->
x
),
2
.
0
)
+
pow
((
v2
->
y
-
v1
->
y
),
2
.
0
),
0
.
5
);
double
dist
=
pow
(
pow
((
v2
->
x
-
v1
->
x
),
2
.
0
)
+
pow
((
v2
->
y
-
v1
->
y
),
2
.
0
),
0
.
5
);
return
dist
;
return
dist
;
...
@@ -77,31 +85,37 @@ void print_vec(const vec *const v){
...
@@ -77,31 +85,37 @@ void print_vec(const vec *const v){
}
}
//FONCTION TEST//
int
Test_new_vec
(){
int
Test_new_vec
(){
//Vecteur quelconque
vec
*
vector
=
new_vec
(
2
.
0
,
3
.
1
);
vec
*
vector
=
new_vec
(
2
.
0
,
3
.
1
);
//Vérification des valeurs attribuées
if
(
vector
->
x
==
2
.
0
&&
vector
->
y
==
3
.
1
){
if
(
vector
->
x
==
2
.
0
&&
vector
->
y
==
3
.
1
){
printf
(
"Test_new_vec IS OK
\n
"
);
printf
(
"Test_new_vec IS OK
\n
"
);
}
}
else
{
else
{
printf
(
"Test_new_vec has an ERROR
\n
"
);
printf
(
"Test_new_vec has an ERROR
\n
"
);
}
}
//Libération de la mémoire
free
(
vector
);
free
(
vector
);
}
}
int
Test_add_vec
(){
int
Test_add_vec
(){
//2 Vecteur quelconque
vec
*
v1
=
new_vec
(
2
.
5
,
3
.
2
);
vec
*
v1
=
new_vec
(
2
.
5
,
3
.
2
);
vec
*
v2
=
new_vec
(
4
.
6
,
1
.
5
);
vec
*
v2
=
new_vec
(
4
.
6
,
1
.
5
);
//Addition des 2 vecteurs dans un nouveau
vec
*
v3
=
add_vec
(
v1
,
v2
);
vec
*
v3
=
add_vec
(
v1
,
v2
);
//Vérification des additions
if
(
v3
->
x
==
7
.
1
&&
v3
->
y
==
4
.
7
){
if
(
v3
->
x
==
7
.
1
&&
v3
->
y
==
4
.
7
){
printf
(
"Test_add_vec IS OK
\n
"
);
printf
(
"Test_add_vec IS OK
\n
"
);
}
}
else
{
else
{
printf
(
"Test_add_vec has an ERROR
\n
"
);
printf
(
"Test_add_vec has an ERROR
\n
"
);
}
}
//Libération de la mémoire
free
(
v1
);
free
(
v1
);
free
(
v2
);
free
(
v2
);
free
(
v3
);
free
(
v3
);
...
@@ -109,11 +123,13 @@ int Test_add_vec(){
...
@@ -109,11 +123,13 @@ int Test_add_vec(){
int
Test_sub_vec
(){
int
Test_sub_vec
(){
//2 Vecteur quelconque
vec
*
v1
=
new_vec
(
2
.
5
,
3
.
2
);
vec
*
v1
=
new_vec
(
2
.
5
,
3
.
2
);
vec
*
v2
=
new_vec
(
4
.
6
,
1
.
5
);
vec
*
v2
=
new_vec
(
4
.
6
,
1
.
5
);
//Soustraction des 2 vecteurs dans un nouveau
vec
*
v3
=
sub_vec
(
v1
,
v2
);
vec
*
v3
=
sub_vec
(
v1
,
v2
);
//Vérification des soustractions
if
(
v3
->
x
==
(
v1
->
x
-
v2
->
x
)
&&
v3
->
y
==
(
v1
->
y
-
v2
->
y
)){
if
(
v3
->
x
==
(
v1
->
x
-
v2
->
x
)
&&
v3
->
y
==
(
v1
->
y
-
v2
->
y
)){
printf
(
"Test_sub_vec IS OK
\n
"
);
printf
(
"Test_sub_vec IS OK
\n
"
);
}
}
...
@@ -121,6 +137,7 @@ int Test_sub_vec(){
...
@@ -121,6 +137,7 @@ int Test_sub_vec(){
printf
(
"Test_sub_vec has an ERROR
\n
"
);
printf
(
"Test_sub_vec has an ERROR
\n
"
);
}
}
//Libération de la mémoire
free
(
v1
);
free
(
v1
);
free
(
v2
);
free
(
v2
);
free
(
v3
);
free
(
v3
);
...
@@ -128,51 +145,59 @@ int Test_sub_vec(){
...
@@ -128,51 +145,59 @@ int Test_sub_vec(){
int
Test_mul_vec
(){
int
Test_mul_vec
(){
//Vecteur quelconque
vec
*
mul
=
new_vec
(
2
.
5
,
5
.
0
);
vec
*
mul
=
new_vec
(
2
.
5
,
5
.
0
);
//Utilisation de la multiplication de vecteur par 2
mul
=
mul_vec
(
2
,
mul
);
mul
=
mul_vec
(
2
,
mul
);
//Vérification des valeurs rendu
if
(
mul
->
x
==
5
.
0
&&
mul
->
y
==
10
.
0
){
if
(
mul
->
x
==
5
.
0
&&
mul
->
y
==
10
.
0
){
printf
(
"Test_mul_vec IS OK
\n
"
);
printf
(
"Test_mul_vec IS OK
\n
"
);
}
}
else
{
else
{
printf
(
"Test_mul_vec has an ERROR
\n
"
);
printf
(
"Test_mul_vec has an ERROR
\n
"
);
}
}
//Libération de la mémoire
free
(
mul
);
free
(
mul
);
}
}
int
Test_norm
(){
int
Test_norm
(){
//Vecteur quelconque
vec
*
v1
=
new_vec
(
8
,
6
);
vec
*
v1
=
new_vec
(
8
,
6
);
//Calcul de la norme
double
test
=
norm
(
v1
);
double
test
=
norm
(
v1
);
//Vérification de la valeur attendu
if
(
test
==
10
){
if
(
test
==
10
){
printf
(
"Test_norm IS OK
\n
"
);
printf
(
"Test_norm IS OK
\n
"
);
}
}
else
{
else
{
printf
(
"Test_norm has an ERROR
\n
"
);
printf
(
"Test_norm has an ERROR
\n
"
);
}
}
//Libération de la mémoire
free
(
v1
);
free
(
v1
);
}
}
int
Test_distance
(){
int
Test_distance
(){
//2 Vecteur quelconque
vec
*
v1
=
new_vec
(
1
.
0
,
1
.
0
);
vec
*
v1
=
new_vec
(
1
.
0
,
1
.
0
);
vec
*
v2
=
new_vec
(
2
.
0
,
1
.
0
);
vec
*
v2
=
new_vec
(
2
.
0
,
1
.
0
);
//Calcul de la distance
double
test
=
distance
(
v1
,
v2
);
double
test
=
distance
(
v1
,
v2
);
//Vérification de la valeur attendu
if
(
test
==
1
.
0
){
if
(
test
==
1
.
0
){
printf
(
"Test_distance IS OK
\n
"
);
printf
(
"Test_distance IS OK
\n
"
);
}
}
else
{
else
{
printf
(
"Test_distance has an ERROR
\n
"
);
printf
(
"Test_distance has an ERROR
\n
"
);
}
}
//Libération de la mémoire
free
(
v1
);
free
(
v1
);
free
(
v2
);
free
(
v2
);
}
}
//Fonction regroupant tout les tests
int
main_tests
(){
int
main_tests
(){
Test_new_vec
();
Test_new_vec
();
...
@@ -184,7 +209,7 @@ int main_tests(){
...
@@ -184,7 +209,7 @@ int main_tests(){
}
}
//On peut choisir de faire les tests ou d'afficher un vecteur quelconque si on lance le programme
int
main
(
int
argc
,
char
*
argv
[]){
int
main
(
int
argc
,
char
*
argv
[]){
if
(
argc
==
2
)
{
if
(
argc
==
2
)
{
if
(
strcmp
(
argv
[
1
],
"test"
)
==
0
)
{
if
(
strcmp
(
argv
[
1
],
"test"
)
==
0
)
{
...
...
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