Skip to content
Snippets Groups Projects
Commit 5c08ca52 authored by Camille Chapeland's avatar Camille Chapeland
Browse files

added rotate_curve function which was still in the notebook files to the utils/function.py

parent 23d68e30
No related branches found
No related tags found
1 merge request!4Error analysis
......@@ -3,6 +3,8 @@ import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import CubicSpline
from scipy.spatial.transform import Rotation as R
'''
This file contains the functions required for running the shape sensing notebooks.
......@@ -279,3 +281,24 @@ def path_info(P, name):
print("Shape of", name, P.shape, "with physical length", P_length)
return
def rotate_curve(Curve):
# Extract last point of curve
last_point = Curve[-1]
# Define last point constrained at z=0
rotated_last_point = np.array([last_point[0],last_point[1],0])
# Compute the angle between both vectors
unit_vector_1 = last_point / np.linalg.norm(last_point)
unit_vector_2 = rotated_last_point / np.linalg.norm(rotated_last_point)
dot_product = np.dot(unit_vector_1, unit_vector_2)
angle = np.arccos(dot_product)
# Rotate the entire curve by the angle
r = R.from_euler('y',angle)
rotated_curve = r.apply(Curve)
return rotated_curve
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment