daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Xi = Array{Float64}([0.0, 450.0, 450.0, 0.0, 0.0, 450.0, 450.0, 0.0])
  2. Yi = Array{Float64}([0.0, 0.0, 600.0, 600.0, 0.0, 0.0, 600.0, 600.0])
  3. Zi = Array{Float64}([0.0, 0.0, 0.0, 0.0, 400.0, 400.0, 400.0, 400.0])
  4. Xj = Array{Float64}([0.0, 450.0, 450.0, 0.0, 0.0, 450.0, 450.0, 0.0])
  5. Yj = Array{Float64}([0.0, 0.0, 600.0, 600.0, 0.0, 0.0, 600.0, 600.0])
  6. Zj = Array{Float64}([0.0, 0.0, 0.0, 0.0, 400.0, 400.0, 400.0, 400.0])
  7. L = Array{Float64}([400.0, 400.0, 400.0, 400.0, 450.0, 600.0, 450.0, 600.0])
  8. Rot = Array{Float64}([90.0, 90.0, 90.0, 90.0, 0.0, 0.0, 0.0, 0.0])
  9.    
  10. function jt_transcoord(Xi, Yi, Zi, Xj, Yj, Zj, Rot, L)
  11. r = Vector(length(Xi))
  12. for i in 1:length(Xi)
  13.     rxX = (Xj[i] - Xi[i]) / L[i]
  14.     rxY = (Yj[i] - Yi[i]) / L[i]
  15.     rxZ = (Zj[i] - Zi[i]) / L[i]
  16.         if rxX == 0 && rxY == 0
  17.             r[i] = [0 0 rxZ; cosd(Rot[i]) -rxZ*sind(Rot[i]) 0; sind(Rot[i]) rxZ*cosd(Rot[i]) 0]
  18.         else
  19.             R=sqrt(rxX^2+rxY^2)
  20.             r21=(-rxX*rxZ*cosd(Rot[i])+rxY*sind(Rot[i]))/R
  21.             r22=(-rxY*rxZ*cosd(Rot[i])-rxX*sind(Rot[i]))/R
  22.             r23=R*cosd(Rot[i])
  23.             r31=(rxX*rxZ*sind(Rot[i])+rxY*cosd(Rot[i]))/R
  24.             r32=(rxY*rxZ*sind(Rot[i])-rxX*cosd(Rot[i]))/R
  25.             r33=-R*sind(Rot[i])
  26.             r[i] = [rxX rxY rxZ;r21 r22 r23;r31 r32 r33]
  27.         end
  28. end
  29. return r
  30. end
  31.    
  32. Xi = convert(SharedArray, Xi)
  33. Yi = convert(SharedArray, Yi)
  34. Zi = convert(SharedArray, Zi)
  35. Xj = convert(SharedArray, Xj)
  36. Yj = convert(SharedArray, Yj)
  37. Zj = convert(SharedArray, Zj)
  38. L = convert(SharedArray, L)
  39. Rot = convert(SharedArray, Rot)
  40.    
  41. function jt_transcoord_parallel(Xi, Yi, Zi, Xj, Yj, Zj, Rot, L)
  42. r = SharedArray{Float64}(zeros((length(Xi),1)))
  43. @parallel for i in 1:length(Xi)
  44.     rxX = (Xj[i] - Xi[i]) / L[i]
  45.     rxY = (Yj[i] - Yi[i]) / L[i]
  46.     rxZ = (Zj[i] - Zi[i]) / L[i]
  47.         if rxX == 0 && rxY == 0
  48.             r[i] = [0 0 rxZ; cosd(Rot[i]) -rxZ*sind(Rot[i]) 0; sind(Rot[i]) rxZ*cosd(Rot[i]) 0]
  49.         else
  50.             R=sqrt(rxX^2+rxY^2)
  51.             r21=(-rxX*rxZ*cosd(Rot[i])+rxY*sind(Rot[i]))/R
  52.             r22=(-rxY*rxZ*cosd(Rot[i])-rxX*sind(Rot[i]))/R
  53.             r23=R*cosd(Rot[i])
  54.             r31=(rxX*rxZ*sind(Rot[i])+rxY*cosd(Rot[i]))/R
  55.             r32=(rxY*rxZ*sind(Rot[i])-rxX*cosd(Rot[i]))/R
  56.             r33=-R*sind(Rot[i])
  57.             r[i] = [rxX rxY rxZ;r21 r22 r23;r31 r32 r33]
  58.         end
  59. end
  60. return r
  61. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top