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
Instead of checking only the mRNA level, I want to check the active protein level of MMP-1 in Liver tissue from mice. How can I do that?
03 March 2021 1,763 2 View
I want to analyses the proportion of swimming sperm of three species of fish in two salinities. To analyse the proportion of swimming sperm in a Generalized Linear Model, I would use a Binary...
03 March 2021 2,297 3 View
03 March 2021 8,272 1 View
Hi. Please tell me what guidelines should i need to follow for questionaries' type research work in India. It is not hospital based work, we are conduction basic institutional based qualitative...
03 March 2021 2,037 3 View
Hi, I implemented a code to gabor filter cifar10 data but the images after being filtered and stacked are not clear like the original images. I think the problem is in the way I am using the...
03 March 2021 6,317 1 View
i am try to classify the x-ray images. During classification , can i block unwanted images (except x-ray image).
03 March 2021 7,100 1 View
03 March 2021 5,360 2 View
The term miscibility refers to the single-phase state in thermodynamics. I do not mean the compatibility of different components. To determine the miscibility I know several techniques such as...
03 March 2021 4,107 4 View
If the detection range is in ng/ml but the reference range is in ug/ml for a molecule or protein in serum or plasma .how to dilute and what is the initial volume to be taken for quantitative analysis
02 March 2021 7,670 3 View
02 March 2021 5,204 3 View
Hi, I am trying to construct a multi-layer fibril structure from a single layer in PyMol by translating the layer along the fibril axis. For now, I am able to use the Translate command in PyMol...
02 March 2021 4,569 4 View
I want to do a parameter study of a aixsymmetric cylinder in Abaqus. I want to create several jobs where I get the stresses for 3 different points in my model. These points are defined. I wrote a...
01 March 2021 10,078 1 View
Which is suitable for use with Python? MySQL or SQL Server? What is your suggestion?
01 March 2021 3,422 3 View
Please, if Gaussian Parameter optimization is possible in this code structure
28 February 2021 278 3 View
I wanted to add an extra parameter to the existing Johnson cook equation in the ABAQUS simulation. How to add those extra parameters. Ref: A modified Johnson-Cook material model with strain...
28 February 2021 4,841 3 View
If I want to compare characteristics of 2 groups of patients, one group is recruited from a random sample of the general public while another group is from a sample with a fixed gender (male to...
26 February 2021 3,526 3 View
System Description Cuda 11.2 GeForce GTX 1080ti tensorflow version 2.4.1 keras version 2.2.0 python version 3.8 I was getting the below error when I try to run my code on the...
25 February 2021 6,673 2 View
Good morning, I could not find literature about this so I am asking. I am organizing data for a questionnaire (N=100) that foresees some personal questions like level of education. For the aim...
25 February 2021 2,090 4 View
I am learning how to use SPM for PET and PET-MR analysis, but I haven't found any great resources that explain how contrasts work. I have a series of PET images where our hypothesis argues that...
24 February 2021 1,534 2 View
23 February 2021 7,826 2 View