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
fe8f4d02
Commit
fe8f4d02
authored
3 years ago
by
Florian Burgener
Browse files
Options
Downloads
Patches
Plain Diff
Scaled object name drawing distance
parent
57f0ea8f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CelestialObject.c
+7
-1
7 additions, 1 deletion
CelestialObject.c
PlanetarySystem.c
+13
-10
13 additions, 10 deletions
PlanetarySystem.c
with
20 additions
and
11 deletions
CelestialObject.c
+
7
−
1
View file @
fe8f4d02
...
@@ -63,5 +63,11 @@ void celestial_object_draw_name(CelestialObject *object, Vector2 reference_frame
...
@@ -63,5 +63,11 @@ void celestial_object_draw_name(CelestialObject *object, Vector2 reference_frame
return
;
return
;
}
}
draw_text
(
object
->
name
,
vector2_add
(
scaled_position
,
vector2_create
(
object
->
drawing_disc_radius
+
8
,
7
)));
uint32_t
drawing_disc_radius
=
object
->
drawing_disc_radius
;
if
(
zoom_factor
<
1
)
{
drawing_disc_radius
*=
zoom_factor
;
}
draw_text
(
object
->
name
,
vector2_add
(
scaled_position
,
vector2_create
(
drawing_disc_radius
+
8
,
7
)));
}
}
This diff is collapsed.
Click to expand it.
PlanetarySystem.c
+
13
−
10
View file @
fe8f4d02
...
@@ -35,27 +35,30 @@ const double EARTH_SEMI_MAJOR_AXIS = 149.598262 * 1E9;
...
@@ -35,27 +35,30 @@ const double EARTH_SEMI_MAJOR_AXIS = 149.598262 * 1E9;
const
double
MARS_SEMI_MAJOR_AXIS
=
227
.
943824
*
1E9
;
const
double
MARS_SEMI_MAJOR_AXIS
=
227
.
943824
*
1E9
;
PlanetarySystem
*
planetary_system_create
()
{
PlanetarySystem
*
planetary_system_create
()
{
PlanetarySystem
*
p
s
=
(
PlanetarySystem
*
)
malloc
(
sizeof
(
PlanetarySystem
));
PlanetarySystem
*
s
ystem
=
(
PlanetarySystem
*
)
malloc
(
sizeof
(
PlanetarySystem
));
p
s
->
objects_length
=
9
;
s
ystem
->
objects_length
=
9
;
p
s
->
objects
=
(
CelestialObject
**
)
malloc
(
sizeof
(
PlanetarySystem
*
)
*
p
s
->
objects_length
);
s
ystem
->
objects
=
(
CelestialObject
**
)
malloc
(
sizeof
(
PlanetarySystem
*
)
*
s
ystem
->
objects_length
);
p
s
->
zoom_factor
=
1
;
s
ystem
->
zoom_factor
=
1
;
p
s
->
reference_frame_object_index
=
0
;
s
ystem
->
reference_frame_object_index
=
0
;
// The moon is initialized with real life values.
// Naboo, Jupiter and Endor are all fake planets.
// Note that Jupitaire follows the orbit of Jupyter but its mass is different.
char
names
[][
100
]
=
{
"Sun"
,
"Mercury"
,
"Venus"
,
"Earth"
,
"Mars"
,
"Moon"
,
"Naboo"
,
"Jupitaire"
,
"Endor"
};
char
names
[][
100
]
=
{
"Sun"
,
"Mercury"
,
"Venus"
,
"Earth"
,
"Mars"
,
"Moon"
,
"Naboo"
,
"Jupitaire"
,
"Endor"
};
double
masses
[]
=
{
SUN_MASS
,
MERCURY_MASS
,
VENUS_MASS
,
EARTH_MASS
,
MARS_MASS
,
7
.
34767309
*
1E22
,
1000000
,
1898
.
6
*
1E10
,
1E23
,
100
*
1E9
};
double
masses
[]
=
{
SUN_MASS
,
MERCURY_MASS
,
VENUS_MASS
,
EARTH_MASS
,
MARS_MASS
,
7
.
34767309
*
1E22
,
1000000
,
1898
.
6
*
1E10
,
1E23
,
100
*
1E9
};
double
semi_major_axes
[]
=
{
0
,
MERCURY_SEMI_MAJOR_AXIS
,
VENUS_SEMI_MAJOR_AXIS
,
EARTH_SEMI_MAJOR_AXIS
,
MARS_SEMI_MAJOR_AXIS
,
384
.
399
*
1E6
,
800
.
598262
*
1E9
,
778
.
340821
*
1E9
,
100
*
1E9
};
double
semi_major_axes
[]
=
{
0
,
MERCURY_SEMI_MAJOR_AXIS
,
VENUS_SEMI_MAJOR_AXIS
,
EARTH_SEMI_MAJOR_AXIS
,
MARS_SEMI_MAJOR_AXIS
,
384
.
399
*
1E6
,
800
.
598262
*
1E9
,
778
.
340821
*
1E9
,
100
*
1E9
};
double
eccentricities
[]
=
{
0
,
MERCURY_ECCENTRICITY
,
VENUS_ECCENTRICITY
,
EARTH_ECCENTRICITY
,
MARS_ECCENTRICITY
,
0
.
054
9
,
0
.
8
,
0
.
04
839266
,
0
.
34
};
double
eccentricities
[]
=
{
0
,
MERCURY_ECCENTRICITY
,
VENUS_ECCENTRICITY
,
EARTH_ECCENTRICITY
,
MARS_ECCENTRICITY
,
0
.
054
9
,
0
.
8
,
0
.
04
839266
,
0
.
34
};
double
disc_radiuses
[]
=
{
50
,
10
,
20
,
10
,
12
,
5
,
12
,
12
,
12
};
double
disc_radiuses
[]
=
{
50
,
10
,
20
,
10
,
12
,
5
,
12
,
12
,
12
};
int32_t
colors
[]
=
{
0xFF
FFFF
,
0xDBCECA
,
0x8B7D82
,
0x6b93d6
,
0xBC2732
,
0x7D7B67
,
0x00
55
00
,
0x00
55
00
,
0x00
55
00
};
int32_t
colors
[]
=
{
0xFF
CC33
,
0xDBCECA
,
0x8B7D82
,
0x6b93d6
,
0xBC2732
,
0x7D7B67
,
0x00
77
00
,
0x00
77
00
,
0x00
77
00
};
for
(
int32_t
i
=
0
;
i
<
p
s
->
objects_length
;
i
+=
1
)
{
for
(
int32_t
i
=
0
;
i
<
s
ystem
->
objects_length
;
i
+=
1
)
{
CelestialObject
*
object
=
celestial_object_create
(
names
[
i
],
masses
[
i
],
semi_major_axes
[
i
],
eccentricities
[
i
],
disc_radiuses
[
i
],
colors
[
i
]);
CelestialObject
*
object
=
celestial_object_create
(
names
[
i
],
masses
[
i
],
semi_major_axes
[
i
],
eccentricities
[
i
],
disc_radiuses
[
i
],
colors
[
i
]);
p
s
->
objects
[
i
]
=
object
;
s
ystem
->
objects
[
i
]
=
object
;
}
}
p
s
->
objects
[
5
]
->
current_position
.
x
+=
p
s
->
objects
[
3
]
->
current_position
.
x
;
s
ystem
->
objects
[
5
]
->
current_position
.
x
+=
s
ystem
->
objects
[
3
]
->
current_position
.
x
;
return
p
s
;
return
s
ystem
;
}
}
CelestialObject
*
planetary_system_get_star
(
PlanetarySystem
*
planetary_system
)
{
CelestialObject
*
planetary_system_get_star
(
PlanetarySystem
*
planetary_system
)
{
...
...
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