Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ISC_123 - Travail Pratique 001 - Simulation Système Planétaire
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
florian.burgener
ISC_123 - Travail Pratique 001 - Simulation Système Planétaire
Commits
5464edb2
Commit
5464edb2
authored
3 years ago
by
florian.burgener
Browse files
Options
Downloads
Patches
Plain Diff
Fix trail length
parent
3285d3c5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
PlanetarySystem.c
+11
-9
11 additions, 9 deletions
PlanetarySystem.c
PlanetarySystem.h
+1
-1
1 addition, 1 deletion
PlanetarySystem.h
main.c
+2
-2
2 additions, 2 deletions
main.c
with
14 additions
and
12 deletions
PlanetarySystem.c
+
11
−
9
View file @
5464edb2
...
...
@@ -68,7 +68,7 @@ Vector2 calculate_gravitational_acceleration(PlanetarySystem *planetary_system,
return
a
;
}
void
planetary_system_update
(
PlanetarySystem
*
planetary_system
,
double
interval
,
bool
save_position
)
{
void
planetary_system_update
(
PlanetarySystem
*
planetary_system
,
double
interval
)
{
for
(
uint32_t
i
=
1
;
i
<
planetary_system
->
objects_length
;
i
+=
1
)
{
CelestialObject
*
object
=
planetary_system
->
objects
[
i
];
Vector2
current_position
=
object
->
current_position
;
...
...
@@ -102,16 +102,18 @@ void planetary_system_update(PlanetarySystem *planetary_system, double interval,
object
->
previous_position
=
object
->
current_position
;
object
->
current_position
=
new_position
;
if
(
object
->
points_length
<
200
&&
save_position
)
{
object
->
points
[
object
->
points_length
]
=
object
->
current_position
;
object
->
points_length
+=
1
;
}
else
if
(
save_position
)
{
for
(
int32_t
j
=
1
;
j
<
object
->
points_length
;
j
+=
1
)
{
object
->
points
[
j
-
1
]
=
object
->
points
[
j
];
}
int32_t
length
=
object
->
points_length
;
object
->
points
[
object
->
points_length
-
1
]
=
object
->
current_position
;
if
(
length
>
0
&&
vector2_norm
(
vector2_substract
(
object
->
points
[
0
],
object
->
current_position
))
<
1E9
*
1
.
5
)
continue
;
for
(
int32_t
j
=
(
length
==
200
)
?
length
-
1
:
length
;
j
>=
1
;
j
-=
1
)
{
object
->
points
[
j
]
=
object
->
points
[
j
-
1
];
}
object
->
points
[
0
]
=
object
->
current_position
;
if
(
length
<
200
)
object
->
points_length
+=
1
;
}
}
...
...
This diff is collapsed.
Click to expand it.
PlanetarySystem.h
+
1
−
1
View file @
5464edb2
...
...
@@ -17,7 +17,7 @@ typedef struct {
}
PlanetarySystem
;
PlanetarySystem
*
planetary_system_create
();
void
planetary_system_update
(
PlanetarySystem
*
planetary_system
,
double
interval
,
bool
save_position
);
void
planetary_system_update
(
PlanetarySystem
*
planetary_system
,
double
interval
);
void
planetary_system_draw
(
PlanetarySystem
*
planetary_system
);
#endif
This diff is collapsed.
Click to expand it.
main.c
+
2
−
2
View file @
5464edb2
...
...
@@ -9,7 +9,7 @@
#define WINDOW_NAME "Solar System"
#define REFRESH_RATE 200
#define TIME_ELASPING_PER_SECOND 3600 * 24 *
8
0
#define TIME_ELASPING_PER_SECOND 3600 * 24 *
1
0
#define TIME_ELASPING_PER_UPDATE 100
// https://stackoverflow.com/questions/3417837/what-is-the-best-way-to-suppress-a-unused-variable-x-warning
...
...
@@ -37,7 +37,7 @@ void update_timer() {
elapsed_time
+=
1
;
for
(
uint32_t
i
=
0
;
i
<
TIME_ELASPING_PER_SECOND
/
REFRESH_RATE
/
TIME_ELASPING_PER_UPDATE
;
i
+=
1
)
{
planetary_system_update
(
planetary_system
,
TIME_ELASPING_PER_UPDATE
,
i
==
0
);
planetary_system_update
(
planetary_system
,
TIME_ELASPING_PER_UPDATE
);
}
glutTimerFunc
(
1000
/
REFRESH_RATE
,
update_timer
,
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