Skip to content
Snippets Groups Projects
Commit 478f4469 authored by Michele Maris's avatar Michele Maris
Browse files

u

parent b3f2564c
No related branches found
No related tags found
No related merge requests found
import numpy as np
from .roto_translation import transform,roto_trans_matrix
from .vectorized_elemental_rotations import vERotX, vERotY, vERotZ, vAX3D, vAY3D, vAZ3D
class ElipsoidTriangulation :
""" creates an elipsoid triangulated """
@property
......
__DESCRIPTION__="""
not vectorized rototranslation library
M.Maris - V0.0 - 2018 May 03 -
"""
import numpy as np
def transform(point, TransformArray):
""" apply a transformation to a 4d point """
p = np.array([0,0,0,1])
for i in range (0,len(point)-1):
p[i] = point[i]
p=np.dot(TransformArray,np.transpose(p))
for i in range (0,len(point)-1):
point[i]=p[i]
return point
def roto_trans_matrix(rotation, translation):
"""returns a rototranslation matrix
"""
xC, xS = trig(rotation[0])
yC, yS = trig(rotation[1])
zC, zS = trig(rotation[2])
dX = translation[0]
dY = translation[1]
dZ = translation[2]
Translate_matrix = np.array([[1, 0, 0, dX],
[0, 1, 0, dY],
[0, 0, 1, dZ],
[0, 0, 0, 1]])
Rotate_X_matrix = np.array([[1, 0, 0, 0],
[0, xC, -xS, 0],
[0, xS, xC, 0],
[0, 0, 0, 1]])
Rotate_Y_matrix = np.array([[yC, 0, yS, 0],
[0, 1, 0, 0],
[-yS, 0, yC, 0],
[0, 0, 0, 1]])
Rotate_Z_matrix = np.array([[zC, -zS, 0, 0],
[zS, zC, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]])
return np.dot(Rotate_Z_matrix,np.dot(Rotate_Y_matrix,np.dot(Rotate_X_matrix,Translate_matrix)))
__DESCRIPTION__="""
vectorized elemental rotations
M.Maris - V0.0 - 2023 Aug 05 -
"""
import numpy as np
# 3D versors X, Y, Z
vAX3D = np.array([1,0,0])
vAY3D = np.array([0,1,0])
vAZ3D = np.array([0,0,1])
def _vectorized_rotation_base_matrix(self,Angle) :
"""
commodity function to define a base for a vectorized rotation matrix, returns the components
I, c, s of a list of elemental 3D rotation matrices with
I.shape=(N,3,3),
c.shape=N,
s.shape=N.
with N = 1 is Angle is scalar, otherwise N=len(Angle)
Parameters
----------
:Angle: scalar or array of rotation angle(s) in radiants
"""
_angle=np.array([Angle]) if np.isscalar(Angle) else Angle
c=np.cos(_angle)
s=np.sin(_angle)
I=np.zeros([len(_angle),3,3])
I[:,0,0]=1
I[:,1,1]=1
I[:,2,2]=1
return I,c,s
def vERotX(Angle) :
"""Vectorized elemental rotations about X axis
returns a list of elemental 3D rotation matrices with shape (N,3,3)
with N = 1 if Angle is scalar, otherwise N=len(Angle)
Parameters
----------
:Angle: scalar or array of rotation angle(s) in radiants
"""
R,c,s=_vectorized_rotation_base_matrix(Angle)
R[:,1,1]= c
R[:,1,2]=-s
R[:,2,1]= s
R[:,2,2]= c
return R
def vERotY(Angle) :
"""Vectorized elemental rotations about Y axis
returns a list of elemental 3D rotation matrices with shape (N,3,3)
with N = 1 if Angle is scalar, otherwise N=len(Angle)
Parameters
----------
:Angle: scalar or array of rotation angle(s) in radiants
"""
R,c,s=_vectorized_rotation_base_matrix(Angle)
R[:,0,0]= c
R[:,0,2]= s
R[:,2,0]=-s
R[:,2,2]= c
return R
def vERotZ(Angle) :
"""Vectorized elemental rotations about Z axis
returns a list of elemental 3D rotation matrices with shape (N,3,3)
with N = 1 if Angle is scalar, otherwise N=len(Angle)
Parameters
----------
:Angle: scalar or array of rotation angle(s) in radiants
"""
R,c,s=_vectorized_rotation_base_matrix(Angle)
R[:,0,0]= c
R[:,0,1]=-s
R[:,1,0]= s
R[:,1,1]= c
return R
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment