A Point in e Frame#
Let’s simulate below 3D plot displaying the origin, point P, their projections on axes, line vectors, and an orthonormal frame in different colors and styles.
Prerequisites#
Import following libraries on your notebook
[8]:
import plotly.graph_objects as go
import numpy as np
Note
The functions create_line_trace
, create_point_trace
, create_arrow_trace
, and and
others were written in previous tutorials. Please include them in your notebook on top before
starting to follow this tutorial. You can download it by clicking the Download icon on the
Navigation Bar.
Steps#
Step 1: Define the Origin and Point P#
Here, we define the coordinates of the origin (\(O\)) as \([0, 0, 0]\) and the coordinates of point \(P\) as \([2, 3, 4]\).
[10]:
origin = [0, 0, 0]
point_p = [2, 3, 4]
Step 2: Create Traces for Points#
We create traces for the origin (\(O\)) and
point \(P\) using the create_point_trace
function, specifying their colors, sizes, and names.
[11]:
traces = []
traces.append(create_point_trace(origin, color='black', size=3, name='O'))
traces.append(create_point_trace(point_p, color='green', size=3, name='P'))
Step 3: Create Traces for Point Projections on Axes#
We create traces for the projections of point P onto the coordinate axes \((x_1, x_2, x_3)\) using the create_point_trace
function.
[12]:
traces.append(create_point_trace([point_p[0], 0, 0], color='green', size=3, name='x1'))
traces.append(create_point_trace([0, point_p[1], 0], color='green', size=3, name='x2'))
traces.append(create_point_trace([0, 0, point_p[2]], color='green', size=3, name='x3'))
Step 4: Create Line Traces#
We create line traces to represent the vectors \(OP\), \(P\) to \(e_1\), \(P\) to \(e_2\), and \(P\) to \(e_3\) using the create_line_trace
function.
[13]:
traces.append(create_line_trace(origin, point_p, color='blue', name='OP'))
traces.append(create_line_trace(point_p, [point_p[0], 0, 0], color='blue', width=2, dash='dash', name='P to e1'))
traces.append(create_line_trace(point_p, [0, point_p[1], 0], color='blue', width=2, dash='dash', name='P to e2'))
traces.append(create_line_trace(point_p, [0, 0, point_p[2]], color='blue', width=2, dash='dash', name='P to e3'))
Step 5: Create Orthonormal Frame Traces#
We create traces for the orthonormal frame \((e)\) using the create_orthonormal_frame_traces
function and extend the traces list with these frame traces.
[16]:
frame_traces = create_orthonormal_frame_traces(frame_name='e', origin=origin, length=5, color='red')
traces.extend(frame_traces)
Step 6: Set Layout and Create the Figure#
We set the layout using the create_3d_layout
function,
specifying the title and axis titles. Then, we create a Plotly figure (fig
) with the defined
traces and layout.
[17]:
layout = create_3d_layout(title='Point P in 3D Inertial Frame e', xaxis_title='e1 Axis', yaxis_title='e2 Axis', zaxis_title='e3 Axis')
fig = go.Figure(data=traces, layout=layout)
fig.show()