# Demo entry 6758415

transformation

Submitted by anonymous on Aug 13, 2018 at 19:28
Language: Python 3. Code size: 2.4 kB.

```# -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 21:06:55 2018

@author: Chef_Lieu
"""

import numpy as np
import pandas as pd

dmax=100
tt1=[i*0.5*np.pi/90 for i in range(dmax+1)]
tt2=-20.0*np.pi/180.0
tt3=[np.arctan(-np.tan(i)/np.cos(tt2)) for i in tt1]
lx=-0.18
ly=45.0
lz=-0.08
decalage=6.0
def T40(tt1,tt2,tt3,lx,ly,lz):
T10=np.matrix([[1,0,0,0],[0,np.cos(tt1),np.sin(tt1),0],[0,-np.sin(tt1),np.cos(tt1),0],[0,0,0,1]])
T21=np.matrix([[1,0,0,-lx],[0,1,0,-ly],[0,0,1,-lz],[0,0,0,1]])
T32=np.matrix([[np.cos(tt2),0,-np.sin(tt2),0],[0,1,0,0],[np.sin(tt2),0,np.cos(tt2),0],[0,0,0,1]])
T43=np.matrix([[1,0,0,0],[0,np.cos(tt3),np.sin(tt3),0],[0,-np.sin(tt3),np.cos(tt3),0],[0,0,0,1]])
return T43*T32*T21*T10
def T04(tt1,tt2,tt3,lx,ly,lz):
T01=np.linalg.inv(np.matrix([[1,0,0,0],[0,np.cos(tt1),np.sin(tt1),0],[0,-np.sin(tt1),np.cos(tt1),0],[0,0,0,1]]))
T12=np.linalg.inv(np.matrix([[1,0,0,-lx],[0,1,0,-ly],[0,0,1,-lz],[0,0,0,1]]))
T23=np.linalg.inv(np.matrix([[np.cos(tt2),0,-np.sin(tt2),0],[0,1,0,0],[np.sin(tt2),0,np.cos(tt2),0],[0,0,0,1]]))
T34=np.linalg.inv(np.matrix([[1,0,0,0],[0,np.cos(tt3),np.sin(tt3),0],[0,-np.sin(tt3),np.cos(tt3),0],[0,0,0,1]]))
return T01*T12*T23*T34
def T03(tt1,ly):
S1=np.sin(tt1)
C1=np.cos(tt1)
S2=np.sin(-tt1)
C2=np.cos(-tt1)
T01=(np.matrix([[1,0,0,0],[0,C1,S1,0],[0,-S1,C1,0],[0,0,0,1]])).I
T12=(np.matrix([[1,0,0,0],[0,1,0,-ly],[0,0,1,0],[0,0,0,1]])).I
T23=(np.matrix([[1,0,0,0],[0,C2,S2,0],[0,-S2,C2,0],[0,0,0,1]])).I
return T01*T12*T23

p0=np.array([[2.7],[0.0+decalage],[5.9],[1]])
p1=np.array([[2.7],[-2.5+decalage],[5.9],[1]])
#p0=np.array([[0.],[1.],[0.],[1]])
lst1=[(np.dot(T03(tt1[i],ly),p0)).flatten().A.flatten().tolist() for i in range(dmax+1)]
lst2=[(np.dot(T40(tt1[i],tt2,tt3[i],lx,ly,lz),lst1[i]).T).flatten().A.flatten().tolist() for i in range(0,dmax+1)]
data_df = pd.DataFrame(lst2)
writer = pd.ExcelWriter('lst2.xlsx')
data_df.to_excel(writer,'page_1',float_format='%.15f')
writer.save()

lst11=[(np.dot(T03(tt1[i],ly),p1)).flatten().A.flatten().tolist() for i in range(dmax+1)]
lst22=[(np.dot(T40(tt1[i],tt2,tt3[i],lx,ly,lz),lst11[i]).T).flatten().A.flatten().tolist() for i in range(0,dmax+1)]
data_df = pd.DataFrame(lst22)
writer = pd.ExcelWriter('lst22.xlsx')
data_df.to_excel(writer,'page_1',float_format='%.15f')
writer.save()
```

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.