Created
July 30, 2022 01:01
-
-
Save PeterBorisenko/27970a4df442ce5836055213a2654ab2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math as m | |
import numpy as np | |
def nsin(a): | |
return -1 * m.sin(a) | |
dcmOps= [[m.cos, m.sin, nsin],[nsin, m.cos, m.sin],[m.sin, nsin, m.cos]]; | |
def dcmRotate(angle, axis): | |
dcm= np.zeros([3,3]) | |
if axis >= 0 and axis < 3: | |
for n in range(0,len(dcmOps)): | |
for m in range(0,len(dcmOps[n])): | |
if n == axis and m == axis: | |
dcm[n,m]= 1 | |
elif n == axis or m == axis: | |
dcm[n,m]= 0 | |
else: | |
dcm[n,m]= dcmOps[n][m](angle) | |
return dcm | |
def dcmFromEulerAngles(ea, sequence=[3,2,1]): | |
if len(sequence) == len(ea) == 3: | |
dcm= np.identity(3) | |
for n in range(0, len(sequence)): | |
dcm= np.matmul(dcmRotate(ea[n], sequence[n]-1), dcm) | |
return dcm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment