Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
phys_planetes
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
boris.stefanov
phys_planetes
Commits
98b728cc
Commit
98b728cc
authored
3 years ago
by
BobLeHibou
Browse files
Options
Downloads
Patches
Plain Diff
ADD: constants
parent
c89f47c3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
planet/constants.h
+28
-2
28 additions, 2 deletions
planet/constants.h
planet/planet.c
+2
-2
2 additions, 2 deletions
planet/planet.c
planet/planet.h
+2
-3
2 additions, 3 deletions
planet/planet.h
with
32 additions
and
7 deletions
planet/constants.h
+
28
−
2
View file @
98b728cc
...
@@ -3,35 +3,61 @@
...
@@ -3,35 +3,61 @@
// display
// display
#define DISPLAY_RADIUS_DIV 1.0e23
#define DISPLAY_PLANET_RADIUS_DIV 1.0e23
#define DISPLAY_MAX_ORBIT_RADIUS
// logic
#define PLANET_COUNT 4
// physical constants
#define G 6.67e-11
#define G 6.67e-11
#define M_SOLEIL 1.989e30
#define M_SOLEIL 1.989e30
// mass
// mass
#define M_TERRE 5.9742e24
#define M_MERCURE 3.3011e23
#define M_MERCURE 3.3011e23
#define M_VENUS 4.8675e24
#define M_VENUS 4.8675e24
#define M_TERRE 5.9742e24
#define M_MARS 6.4171e23
#define M_MARS 6.4171e23
#define M_JUPITER 1.8982e27
#define M_SATURN 5.6834e26
#define M_URANUS 8.6810e25
#define M_NEPTUNE 1.02413e26
#define M_PLUTO 1.303e22
// major axis
// major axis
#define A_MERCURE 5.7909e10
#define A_MERCURE 5.7909e10
#define A_VENUS 1.0821e11
#define A_VENUS 1.0821e11
#define A_TERRE 1.4960e11
#define A_TERRE 1.4960e11
#define A_MARS 2.2794e11
#define A_MARS 2.2794e11
#define A_JUPITER 7.7857e11
#define A_SATURN 1.43353e12
#define A_URANUS 2.870972e12
#define A_NEPTUNE 4.50e12
#define A_PLUTO 5.90638e12
// excentricity
// excentricity
#define E_MERCURE 0.205630
#define E_MERCURE 0.205630
#define E_VENUS 0.006772
#define E_VENUS 0.006772
#define E_TERRE 0.0167086
#define E_TERRE 0.0167086
#define E_MARS 0.0934
#define E_MARS 0.0934
#define E_JUPITER
#define E_SATURN
#define E_URANUS
#define E_NEPTUNE
#define E_PLUTO
// perihelion
// perihelion
#define PER_MERCURE 4.60012e10
#define PER_MERCURE 4.60012e10
#define PER_VENUS 1.07477e11
#define PER_VENUS 1.07477e11
#define PER_TERRE 1.47095e11
#define PER_TERRE 1.47095e11
#define PER_MARS 2.06700e11
#define PER_MARS 2.06700e11
#define PER_JUPITER 7.40520e11
#define PER_SATURN 1.35255e12
#define PER_URANUS 2.73556e12
#define PER_NEPTUNE 4.46e12
#define PER_PLUTO 4.43682e12
#endif //PLANET_CONSTANTS_H
#endif //PLANET_CONSTANTS_H
This diff is collapsed.
Click to expand it.
planet/planet.c
+
2
−
2
View file @
98b728cc
...
@@ -55,7 +55,7 @@ system_t create_system(double delta_t) {
...
@@ -55,7 +55,7 @@ system_t create_system(double delta_t) {
}
}
void
show_system
(
struct
gfx_context_t
*
ctxt
,
system_t
*
system
)
{
void
show_system
(
struct
gfx_context_t
*
ctxt
,
system_t
*
system
,
const
double
show_radius
)
{
// draw sun
// draw sun
const
coordinates
xy_sun
=
vec2_to_coordinates_centered
(
const
coordinates
xy_sun
=
vec2_to_coordinates_centered
(
vec2_normalize
(
system
->
star
.
pos
),
vec2_normalize
(
system
->
star
.
pos
),
...
@@ -65,7 +65,7 @@ void show_system(struct gfx_context_t* ctxt, system_t* system) {
...
@@ -65,7 +65,7 @@ void show_system(struct gfx_context_t* ctxt, system_t* system) {
// draw planets
// draw planets
for
(
uint32_t
i
=
0
;
i
<
system
->
nb_planets
;
++
i
)
{
for
(
uint32_t
i
=
0
;
i
<
system
->
nb_planets
;
++
i
)
{
const
coordinates
xy
=
vec2_to_coordinates_centered
(
const
coordinates
xy
=
vec2_to_coordinates_centered
(
vec2_mul
(
vec2_norm
(
system
->
planets
[
i
].
pos
)
/
(
PER_MARS
*
1
.
25
)
,
vec2_normalize
(
system
->
planets
[
i
].
pos
)),
vec2_mul
(
vec2_norm
(
system
->
planets
[
i
].
pos
)
/
show_radius
,
vec2_normalize
(
system
->
planets
[
i
].
pos
)),
ctxt
->
width
,
ctxt
->
width
,
ctxt
->
height
);
ctxt
->
height
);
draw_full_circle
(
ctxt
,
xy
.
column
,
xy
.
row
,
20
,
COLOR_BLUE
);
draw_full_circle
(
ctxt
,
xy
.
column
,
xy
.
row
,
20
,
COLOR_BLUE
);
...
...
This diff is collapsed.
Click to expand it.
planet/planet.h
+
2
−
3
View file @
98b728cc
...
@@ -16,13 +16,12 @@ typedef struct _system {
...
@@ -16,13 +16,12 @@ typedef struct _system {
planet_t
*
planets
;
// An array of orbiting planets
planet_t
*
planets
;
// An array of orbiting planets
}
system_t
;
}
system_t
;
// These functions are not mandatory to implement,
// it's rather a hint of what you should have.
planet_t
create_planet
(
double
mass
,
vec2
pos
);
planet_t
create_planet
(
double
mass
,
vec2
pos
);
system_t
create_system
(
double
delta_t
);
system_t
create_system
(
double
delta_t
);
void
show_system
(
struct
gfx_context_t
*
ctxt
,
system_t
*
system
);
//void show_system(struct gfx_context_t* ctxt, system_t* system);
void
show_system
(
struct
gfx_context_t
*
ctxt
,
system_t
*
system
,
const
double
show_radius
);
void
update_system
(
system_t
*
system
,
double
delta_t
);
void
update_system
(
system_t
*
system
,
double
delta_t
);
...
...
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