/* Values in tensor[3,3] output are misaligned (perhaps related to the vec3 input bug that revealed the vec4-based implementation) Running this program will produce: x = 0.200000, pos = <0.200000,0.894427,-1.800000>, norm = <0.099015,0.442807,-0.891133>, blah = <0.033005,0.147602,-0.297044> out = [0.200000 0.894427 -1.800000] [0.099015 0.442807 -0.891133] [0.033005 0.147602 -0.297044] x = 0.400000, pos = <0.400000,0.774597,-0.600000>, norm = <0.377964,0.731925,-0.566947>, blah = <0.125988,0.243975,-0.188982> out = [0.400000 0.774597 -0.600000] [0.377964 0.731925 -0.566947] [0.125988 0.243975 -0.188982] x = 0.600000, pos = <0.600000,0.632456,0.600000>, norm = <0.566947,0.597614,0.566947>, blah = <0.188982,0.199205,0.188982> out = [0.600000 0.632456 0.600000] [0.566947 0.597614 0.566947] [0.188982 0.199205 0.188982] x = 0.800000, pos = <0.800000,0.447214,1.800000>, norm = <0.396059,0.221404,0.891133>, blah = <0.132020,0.073801,0.297044> out = [0.800000 0.447214 1.800000] [0.396059 0.221404 0.891133] [0.132020 0.073801 0.297044] So values are being stored okay in the "tensor[3,3] out" but looking at the output with: unu save -f text -i out.nrrd shows: 0.2 0.89442718 -1.8 0 0.099014752 0.44280744 -0.89113277 0 0.033004917 0.40000001 0.77459669 -0.5999999 0 0.37796447 0.73192507 -0.56694663 0 0.12598816 0.60000002 0.63245553 0.60000014 0 0.56694669 0.59761429 0.5669468 0 0.18898223 0.80000001 0.44721359 1.8000002 0 0.39605898 0.22140369 0.89113277 0 0.13201967 The values of the second row are shifted over by one, and the last two values of the third row are missing. */ input int len = 4; function bool pten(tensor[3,3] M) { print(" [", M[0,0], " ", M[0,1], " ", M[0,2], "]\n [", M[1,0], " ", M[1,1], " ", M[1,2], "]\n [", M[2,0 ], " ", M[2,1], " ", M[2,2], "]\n"); return true; } strand foo (real x) { output tensor[3,3] out = zeros[3,3]; update { vec3 pos = [x,sqrt(1-x),lerp(-3,3,0,x,1)]; vec3 norm = normalize(pos); vec3 blah = norm/3; print("x = ", x, ", pos = ", pos, ", norm = ", norm, ", blah = ", blah, "\n"); out = [pos,norm,blah]; print("out ="); bool noop = pten(out); stabilize; } } initially { foo(real(ii)/(len+1)) | ii in 1..len };
Click to toggle
does not end with </html> tag
does not end with </body> tag
The output has ended thus: "); bool noop = pten(out); stabilize; } } initially { foo(real(ii)/(len+1)) | ii in 1..len };