|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+import plotly.graph_objects as go
|
|
|
2
|
+import numpy as np
|
|
|
3
|
+
|
|
|
4
|
+# Define the curvature function
|
|
|
5
|
+def kappa(x):
|
|
|
6
|
+ return (1-((-((-1)**np.floor(x/np.pi*2)*(np.exp(-1/((x/np.pi*2)-np.floor((x/np.pi*2))))
|
|
|
7
|
+ /(np.exp(-1/((x/np.pi*2)-np.floor((x/np.pi*2))))+np.exp(-1/(1-(x/np.pi*2)+np.floor((x/np.pi*2))))))) +
|
|
|
8
|
+ ((-1)**np.floor((x/np.pi*2)/1)*(np.exp(-1/(1-(x/np.pi*2)+np.floor((x/np.pi*2))))/(np.exp(-1/((x/np.pi*2)-
|
|
|
9
|
+ np.floor((x/np.pi*2))))+np.exp(-1/(1-(x/np.pi*2)+np.floor((x/np.pi*2))))))))/2 + .5))
|
|
|
10
|
+
|
|
|
11
|
+# Generate x values
|
|
|
12
|
+x_vals = np.linspace(0, 4*np.pi, 1000)
|
|
|
13
|
+
|
|
|
14
|
+# Compute kappa values
|
|
|
15
|
+kappa_vals = kappa(x_vals)
|
|
|
16
|
+
|
|
|
17
|
+# Integrate kappa values to get theta values (angles)
|
|
|
18
|
+theta_vals = np.cumsum(kappa_vals) * (x_vals[1]-x_vals[0])
|
|
|
19
|
+
|
|
|
20
|
+# Compute x and y coordinates of the curve
|
|
|
21
|
+x_coords = np.cumsum(np.cos(theta_vals)) * (x_vals[1]-x_vals[0])
|
|
|
22
|
+y_coords = np.cumsum(np.sin(theta_vals)) * (x_vals[1]-x_vals[0])
|
|
|
23
|
+
|
|
|
24
|
+# Create a plot using plotly
|
|
|
25
|
+fig = go.Figure()
|
|
|
26
|
+
|
|
|
27
|
+# Add line to the figure for the curve
|
|
|
28
|
+fig.add_trace(go.Scatter(x=x_coords, y=y_coords, mode='lines', name='Curve'))
|
|
|
29
|
+
|
|
|
30
|
+# Update layout
|
|
|
31
|
+fig.update_layout(
|
|
|
32
|
+ autosize=True,
|
|
|
33
|
+ xaxis=dict(scaleanchor='y', scaleratio=1) # this line sets the aspect ratio
|
|
|
34
|
+)
|
|
|
35
|
+fig.show()
|