Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Xi = Array{Float64}([0.0, 450.0, 450.0, 0.0, 0.0, 450.0, 450.0, 0.0])
- Yi = Array{Float64}([0.0, 0.0, 600.0, 600.0, 0.0, 0.0, 600.0, 600.0])
- Zi = Array{Float64}([0.0, 0.0, 0.0, 0.0, 400.0, 400.0, 400.0, 400.0])
- Xj = Array{Float64}([0.0, 450.0, 450.0, 0.0, 0.0, 450.0, 450.0, 0.0])
- Yj = Array{Float64}([0.0, 0.0, 600.0, 600.0, 0.0, 0.0, 600.0, 600.0])
- Zj = Array{Float64}([0.0, 0.0, 0.0, 0.0, 400.0, 400.0, 400.0, 400.0])
- L = Array{Float64}([400.0, 400.0, 400.0, 400.0, 450.0, 600.0, 450.0, 600.0])
- Rot = Array{Float64}([90.0, 90.0, 90.0, 90.0, 0.0, 0.0, 0.0, 0.0])
- function jt_transcoord(Xi, Yi, Zi, Xj, Yj, Zj, Rot, L)
- r = Vector(length(Xi))
- for i in 1:length(Xi)
- rxX = (Xj[i] - Xi[i]) / L[i]
- rxY = (Yj[i] - Yi[i]) / L[i]
- rxZ = (Zj[i] - Zi[i]) / L[i]
- if rxX == 0 && rxY == 0
- r[i] = [0 0 rxZ; cosd(Rot[i]) -rxZ*sind(Rot[i]) 0; sind(Rot[i]) rxZ*cosd(Rot[i]) 0]
- else
- R=sqrt(rxX^2+rxY^2)
- r21=(-rxX*rxZ*cosd(Rot[i])+rxY*sind(Rot[i]))/R
- r22=(-rxY*rxZ*cosd(Rot[i])-rxX*sind(Rot[i]))/R
- r23=R*cosd(Rot[i])
- r31=(rxX*rxZ*sind(Rot[i])+rxY*cosd(Rot[i]))/R
- r32=(rxY*rxZ*sind(Rot[i])-rxX*cosd(Rot[i]))/R
- r33=-R*sind(Rot[i])
- r[i] = [rxX rxY rxZ;r21 r22 r23;r31 r32 r33]
- end
- end
- return r
- end
- Xi = convert(SharedArray, Xi)
- Yi = convert(SharedArray, Yi)
- Zi = convert(SharedArray, Zi)
- Xj = convert(SharedArray, Xj)
- Yj = convert(SharedArray, Yj)
- Zj = convert(SharedArray, Zj)
- L = convert(SharedArray, L)
- Rot = convert(SharedArray, Rot)
- function jt_transcoord_parallel(Xi, Yi, Zi, Xj, Yj, Zj, Rot, L)
- r = SharedArray{Float64}(zeros((length(Xi),1)))
- @parallel for i in 1:length(Xi)
- rxX = (Xj[i] - Xi[i]) / L[i]
- rxY = (Yj[i] - Yi[i]) / L[i]
- rxZ = (Zj[i] - Zi[i]) / L[i]
- if rxX == 0 && rxY == 0
- r[i] = [0 0 rxZ; cosd(Rot[i]) -rxZ*sind(Rot[i]) 0; sind(Rot[i]) rxZ*cosd(Rot[i]) 0]
- else
- R=sqrt(rxX^2+rxY^2)
- r21=(-rxX*rxZ*cosd(Rot[i])+rxY*sind(Rot[i]))/R
- r22=(-rxY*rxZ*cosd(Rot[i])-rxX*sind(Rot[i]))/R
- r23=R*cosd(Rot[i])
- r31=(rxX*rxZ*sind(Rot[i])+rxY*cosd(Rot[i]))/R
- r32=(rxY*rxZ*sind(Rot[i])-rxX*cosd(Rot[i]))/R
- r33=-R*sind(Rot[i])
- r[i] = [rxX rxY rxZ;r21 r22 r23;r31 r32 r33]
- end
- end
- return r
- end
Add Comment
Please, Sign In to add comment