I am looking for a pythonic solution of
https://en.wikipedia.org/wiki/Frenet%E2%80%93Serret_formulas
A solution with Julia is available at
https://github.com/federicomor/frenet-trihedron
Hi!
This is roughly the translation of the above Julia code to Python:
------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from datetime import datetime
# Define the curve parameters
n = 200
t = np.linspace(0, 6 * np.pi, n)
def f(t):
return t * np.cos(t)
def g(t):
return t * np.sin(t)
def h(t):
return t
def f1(t):
return np.cos(t) - t * np.sin(t)
def f2(t):
return -2 * np.sin(t) - t * np.cos(t)
def g1(t):
return np.sin(t) + t * np.cos(t)
def g2(t):
return 2 * np.cos(t) - t * np.sin(t)
def h1(t):
return 1
def h2(t):
return 0
x = f(t)
y = g(t)
z = h(t)
# Graphical Parameters
molt = 3.0
limx = [np.min(x) - 1, np.max(x) + 1]
limy = [np.min(y) - 1, np.max(y) + 1]
limz = [np.min(z) - 1, np.max(z) + 2]
cam_height = 30
cam_angle = np.linspace(0, 90, num=len(t))
# Create the animation
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
def update(i):
ax.clear()
ax.plot(x, y, z, label="Curve")
draw_trihedron(ax, t[i], i, molt)
ax.set_xlim(limx)
ax.set_ylim(limy)
ax.set_zlim(limz)
ax.view_init(elev=cam_angle[i], azim=0)
print(f"{int(100 * i / len(t))}% -> ")
def draw_trihedron(ax, t, i, molt):
trihedron_size = molt
trihedron = np.array([[0, 0, 0],
[trihedron_size, 0, 0],
[0, trihedron_size, 0],
[0, 0, trihedron_size]])
R = np.array([[f1(t), g1(t), h1(t)],
[f2(t), g2(t), h2(t)],
[0, 0, 1]])
trihedron_rotated = trihedron.dot(R.T)
ax.plot(trihedron_rotated[:, 0], trihedron_rotated[:, 1], trihedron_rotated[:, 2], color='r')
ani = FuncAnimation(fig, update, frames=len(t), interval=100)
plt.show()
# Save the animation as a GIF
now = datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
ani.save(f"{now}.gif", writer='imagemagick', fps=15)
print("END!")
You need to install numpy and matplotlib to run the above code:
pip install matplotlib numpy
Also you may need imagemagick or ffmpeg:
sudo apt-get install imagemagick
sudo apt-get install ffmpeg
I want to know more about Uranium ore deposits in world.
11 August 2024 6,720 0 View
I want to know more about diamond ore deposits in world.
11 August 2024 2,167 1 View
We assume that the difference is huge and that it is not possible to compare the two spaces. The R^4 mathematical space considers time as an external controller and the space itself is immobile in...
10 August 2024 6,678 14 View
If Banks do not provide credit facility, what are the options available for FPOs and impact on producer’s income?
10 August 2024 8,198 5 View
I used eye tracking to examine how participants from two different populations (A and B) react to an image. Participants in population A exhibit larger pupil sizes over time, but they also have...
10 August 2024 3,229 0 View
What are a “Farmers Producer Organization” (FPO) and its essential features?
10 August 2024 477 5 View
I have been doing the m6A dot blot for a while with no improvement, I am extracting the RNA, and I can see the dots although the three biological replicas give a different reading on the memberan...
10 August 2024 8,539 5 View
How do interactions between the biosphere, the carbon cycle, and the water cycle impact global warming and interaction between the atmosphere and the hydrosphere?
09 August 2024 3,291 2 View
I have input a moment load in module load Abaqus, i put my moment load on the node surface (using reference point). I have define moment in history output and make a set for moment too. But the...
08 August 2024 4,831 4 View
How is energy cycled through the Earth's climate system and how do matter cycle and energy flow through the rock cycle?
08 August 2024 8,162 0 View
I'm currently exploring the application of Python in textile engineering, specifically in areas like data analysis, process automation, and the development of smart textiles. I'm interested in...
10 August 2024 7,429 2 View
Request Python code from this article : Gender equity of authorship in pulmonary medicine over the past decade. THANKS!
08 August 2024 6,242 2 View
Visual Studio Code (VS Code) has become a popular choice among developers for several reasons: 1. **Free and Open Source**: VS Code is free to use and open source, making it accessible to...
07 August 2024 7,013 4 View
Are there any statistical methods to justify your sampling technique using SPSS or AMOS?
05 August 2024 9,153 4 View
I need the python code to forecast what crop production will be in the next decade considering climate and crop production variables as seen in the attached.csv file.
05 August 2024 2,977 3 View
Better ways to analyze the qualitative and quantitative data in a sequential explanatory mixed method approaches
04 August 2024 2,703 6 View
Hello everyone, I am currently working on a research project that aims to integrate machine learning techniques into an open source SIEM tool to automate the creation of security use cases from...
04 August 2024 3,196 2 View
Just bounced on me. Before statistically analysing significant difference, shouldn't we see if data fits normal distribution first? Is 3 replicates enough to testify the hypothesis of normal...
31 July 2024 8,141 13 View
I am currently considering a research project focusing on a comparative analysis of starch metabolism in orchids and roses. I am particularly interested in identifying the types and quantities of...
30 July 2024 4,267 2 View
Can an analytical method's limit of quantification (LOQ) be outside its linear dynamic range, or is it always required to be within it? Please provide a thorough explanation supported by verified...
29 July 2024 7,198 9 View