Skip to content
Snippets Groups Projects
Commit ee4d3ba0 authored by Benjamin-Sitbon's avatar Benjamin-Sitbon
Browse files

Many ADD and Change

add main on galaxy_simulation, changed librairies and added star librairy, box still missing comments and star isn't ready
parent 27815908
No related branches found
No related tags found
No related merge requests found
......@@ -10,9 +10,15 @@
</component>
<component name="ChangeListManager">
<list default="true" id="43aff179-c306-46b9-b69f-eca5306fbf96" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/Box" beforeDir="false" afterPath="$PROJECT_DIR$/Box" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Box" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Box.c" beforeDir="false" afterPath="$PROJECT_DIR$/Box.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Box.h" beforeDir="false" afterPath="$PROJECT_DIR$/Box.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Box.o" beforeDir="false" afterPath="$PROJECT_DIR$/Box.o" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Vector" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Vector.c" beforeDir="false" afterPath="$PROJECT_DIR$/Vector.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Vector.h" beforeDir="false" afterPath="$PROJECT_DIR$/Vector.h" 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>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
......@@ -25,8 +31,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/Vector.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2348">
<caret line="210" lean-forward="true" selection-start-line="210" selection-end-line="210" />
<state relative-caret-position="2159">
<caret line="208" column="1" selection-start-line="208" selection-start-column="1" selection-end-line="208" selection-end-column="1" />
</state>
</provider>
</entry>
......@@ -34,17 +40,17 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/Vector.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="85">
<caret line="5" selection-start-line="5" selection-end-line="5" selection-end-column="33" />
<state relative-caret-position="442">
<caret line="26" lean-forward="true" selection-start-line="26" selection-end-line="26" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/Box.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="226">
<caret line="131" column="33" selection-start-line="131" selection-start-column="33" selection-end-line="131" selection-end-column="33" />
<state relative-caret-position="68">
<caret line="4" selection-start-line="4" selection-end-line="4" />
</state>
</provider>
</entry>
......@@ -52,8 +58,35 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/Box.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" selection-start-line="9" selection-end-line="9" selection-end-column="27" />
<state>
<caret column="19" selection-start-column="19" selection-end-column="19" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/Star.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="15" column="14" selection-start-line="15" selection-start-column="14" selection-end-line="15" selection-end-column="14" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/Star.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="442">
<caret line="26" selection-start-line="26" selection-end-line="26" selection-end-column="36" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/galaxy_simulation.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="51">
<caret line="3" column="17" selection-start-line="3" selection-start-column="17" selection-end-line="3" selection-end-column="17" />
</state>
</provider>
</entry>
......@@ -61,12 +94,17 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/makefile">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="15" selection-start-column="15" selection-end-column="15" />
<state relative-caret-position="34">
<caret line="2" column="20" selection-start-line="2" selection-start-column="20" selection-end-line="2" selection-end-column="41" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/../C/Projet/makefile">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
......@@ -75,19 +113,22 @@
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/Vector.h" />
<option value="$PROJECT_DIR$/Vector_Test.h" />
<option value="$PROJECT_DIR$/Vector_Test.c" />
<option value="$PROJECT_DIR$/makefile" />
<option value="$PROJECT_DIR$/Box.h" />
<option value="$PROJECT_DIR$/Vector.h" />
<option value="$PROJECT_DIR$/Vector.c" />
<option value="$PROJECT_DIR$/makefile" />
<option value="$PROJECT_DIR$/Box.c" />
<option value="$PROJECT_DIR$/Box.h" />
<option value="$PROJECT_DIR$/galaxy_simulation.c" />
<option value="$PROJECT_DIR$/Star.h" />
<option value="$PROJECT_DIR$/Star.c" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="848" />
<option name="y" value="317" />
<option name="x" value="761" />
<option name="y" value="53" />
<option name="width" value="1050" />
<option name="height" value="730" />
</component>
......@@ -137,12 +178,12 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1559227081243</updated>
<workItem from="1559227084365" duration="35037000" />
<workItem from="1559227084365" duration="44894000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="35037000" />
<option name="totallyTimeSpent" value="44894000" />
</component>
<component name="ToolWindowManager">
<frame x="-7" y="-7" width="1550" height="838" extended-state="6" />
......@@ -184,9 +225,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../C/Projet/makefile">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/Vector_Test.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="17">
......@@ -201,38 +239,65 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Vector.o">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/../C/Projet/makefile">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/Vector.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="442">
<caret line="26" lean-forward="true" selection-start-line="26" selection-end-line="26" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Box.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" selection-start-line="4" selection-end-line="4" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/makefile">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="15" selection-start-column="15" selection-end-column="15" />
<state relative-caret-position="34">
<caret line="2" column="20" selection-start-line="2" selection-start-column="20" selection-end-line="2" selection-end-column="41" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Vector.h">
<entry file="file://$PROJECT_DIR$/Star.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="85">
<caret line="5" selection-start-line="5" selection-end-line="5" selection-end-column="33" />
<state relative-caret-position="442">
<caret line="26" selection-start-line="26" selection-end-line="26" selection-end-column="36" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Box.h">
<entry file="file://$PROJECT_DIR$/galaxy_simulation.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" selection-start-line="9" selection-end-line="9" selection-end-column="27" />
<state relative-caret-position="51">
<caret line="3" column="17" selection-start-line="3" selection-start-column="17" selection-end-line="3" selection-end-column="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Vector.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2348">
<caret line="210" lean-forward="true" selection-start-line="210" selection-end-line="210" />
<state relative-caret-position="2159">
<caret line="208" column="1" selection-start-line="208" selection-start-column="1" selection-end-line="208" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Box.c">
<entry file="file://$PROJECT_DIR$/Box.h">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="19" selection-start-column="19" selection-end-column="19" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Star.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="226">
<caret line="131" column="33" selection-start-line="131" selection-start-column="33" selection-end-line="131" selection-end-column="33" />
<state relative-caret-position="255">
<caret line="15" column="14" selection-start-line="15" selection-start-column="14" selection-end-line="15" selection-end-column="14" />
</state>
</provider>
</entry>
......
File deleted
......@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include "Box.h"
#include <math.h>
box new_box(double x0, double x1, double y0, double y1){
......@@ -69,6 +70,14 @@ box *divide_in_four(box b){
}
void print_box(box b){
printf("x0: %f\n",b.x0);
printf("x1: %f\n",b.x1);
printf("y0: %f\n",b.y0);
printf("y1: %f\n",b.y1);
}
//TEST FONCTIONS//
......@@ -146,21 +155,3 @@ int box_tests(){
Test_mid_point();
Test_divide_in_four();
}
int main(int argc, char *argv[]){
if(argc == 2) {
if (strcmp(argv[1], "box_test") == 0) {
box_tests();
}
else if(strcmp(argv[1], "vector_test") == 0){
vector_tests();
vec *v = new_vec(1.0,2.0);
print_vec(v);
free(v);
}
}
else{
}
}
\ No newline at end of file
#include "Vector.c"
#include "Vector.h"
typedef struct box {
double x0, x1, y0, y1;
} box;
......@@ -18,3 +18,4 @@ double compute_length(box b);
//Affiche la box
void print_box(box b);
int box_tests();
\ No newline at end of file
No preview for this file type
Star.c 0 → 100644
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include "Star.h"
void print_star(const star *const s){
printf("POSITION:");
printf(" ");
printf("VITESSE:");
printf(" ");
printf("ACCELERATION:");
printf(" ");
printf("MASSE");
printf("\n");
print_vec(s->pos_t);
printf(" ");
print_vec(s->pos_t_dt);
printf(" ");
print_vec(s->acc);
printf(" ");
printf("%f",s->mass)
}
star *new_star_vel(vec pos, vec vel, vec acc, double mass,double dt){
star new_star;
new_star.mass = mass;
new_star.pos_t = pos;
new_star.pos_t_dt = sub_vec(pos,mul_vec(dt,vel));
new_star.acc = acc;
print_star(new_star);
}
//TEST FONCTIONS//
int Test_new_star(){
vec *p = new_vec(1.0,4.0);
vec *v = new_vec(2.0,0.5);
vec *a = new_vec(1.0,1.0);
star star_test = new_star_vel(p,v,a,1000.0,3.0);
free(p);
free(v);
free(a);
}
int star_tests(){
Test_new_star();
}
\ No newline at end of file
Star.h 0 → 100644
#include "Box.h"
typedef struct star {
vec pos_t, pos_t_dt, acc;
double mass;
} star;
//Création d’une nouvelle étoile à la position pos_t, vitesse vel, accélération acc, masse mass et dt la discrétisation temporelle:
star *new_star_vel(vec pos, vec vel, vec acc, double mass,double dt);
//On initialisera pos_t_dt à l’aide de la relation (en pseudo-code)
//pos_t_dt = pos_t - dt * vel
//Remise à zéro de l’accélération d’une étoile:
void reset_acceleration(star *s);
//Mise à jour de l’accélération d’une étoile, s, à cause de l’attraction gravitationnelle d’une autre étoile, s2:
void update_acceleration(star *s, const star *const s2);
//Mise à jour de la position d’une étoile, avec dt la discrétisation temporelle:
void update_position(star *s, double dt);
//En pseudo-code cette mise à jour est de la forme:
//pos_t = 2*pos_t - pos_t_dt + acc * dt * dt
// Affichage des champs d’une étoile pour aider au débogage:
void print_star(const star *const s);
\ No newline at end of file
Star.o 0 → 100644
File added
File deleted
......@@ -207,5 +207,3 @@ int vector_tests(){
Test_norm();
Test_distance();
}
\ No newline at end of file
......@@ -22,3 +22,5 @@ double distance(const vec *const v1, const vec *const v2);
//Affiche un vecteur
void print_vec(const vec *const v);
int vector_tests();
No preview for this file type
File added
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include "Star.h"
int main(int argc, char *argv[]) {
if (argc == 2) {
if (strcmp(argv[1],"box_test") == 0) {
box_tests();
box b = new_box(-1.0,1.0,-2.0,2.0);
print_box(b);
} else if (strcmp(argv[1],"vector_test") == 0) {
vector_tests();
vec *v = new_vec(1.0, 2.0);
print_vec(v);
free(v);
}
else if (strcmp(argv[1],"star_test") == 0) {
star_tests();
}
}
}
\ No newline at end of file
File added
All: Vector Box
Vector: Vector.o
gcc -o Vector Vector.o -lm
galaxy_simulation: vector.o Box.o Star.o galaxy_simulation.o
gcc -o galaxy_simulation Vector.o Box.o Star.o galaxy_simulation.o -lm
galaxy_simulation.o: galaxy_simulation.c
gcc -o galaxy_simulation.o -c galaxy_simulation.c
Vector.o: Vector.c
gcc -o Vector.o -c Vector.c
Box: Box.o
gcc -o Box Box.o -lm
Box.o: Box.c
gcc -o Box.o -c Box.c
Star.o: Star.c
gcc -o Star.o -c Star.c
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment