Skip to content

Commit

Permalink
docs(kepler-problem): add annimations of kepler orbits
Browse files Browse the repository at this point in the history
  • Loading branch information
emptymalei committed Sep 23, 2024
1 parent f5933b2 commit c5a8a57
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions docs/tutorials/kepler_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,31 @@ def visualize_orbit(dataframe: pd.DataFrame) -> go.Figure:
:param dataframe: dataframe containing the trajectory data
"""
fig = px.line_polar(
dataframe.assign(
phi_degree=dataframe.phi / (2 * np.pi) * 360,
),
df_chart = dataframe.assign(
phi_degree=dataframe.phi / (2 * np.pi) * 360,
)
range_r = 0, df_chart.r.max() * 1.1
fig = px.scatter_polar(
df_chart,
r="r",
theta="phi_degree",
hover_data=["t", "r", "phi"],
text="t",
start_angle=0,
animation_frame="t",
color_discrete_sequence=["red"],
range_r=range_r,
)

trajectory_traces = list(
px.line_polar(
df_chart,
r="r",
theta="phi_degree",
hover_data=["t", "r", "phi"],
start_angle=0,
range_r=range_r,
).select_traces(),
)

fig.update_layout(
Expand All @@ -87,12 +104,13 @@ def visualize_orbit(dataframe: pd.DataFrame) -> go.Figure:
},
)

fig.add_traces(trajectory_traces)

return fig


# %%
fig = visualize_orbit(df_p_1)

fig.show()

# %% [markdown]
Expand Down

0 comments on commit c5a8a57

Please sign in to comment.