#version 3.8; global_settings { assumed_gamma 1.0 } #include "math.inc" #macro VectorDimTest(v0) #local vZ3D = <0, 0, 0>; #local vZ4D = <0, 0, 0, 0>; #local vZ5D = <0, 0, 0, 0, 0>; #local v1 = v0 + 1; #local v2 = v0 + 2; #local D2 = ((vZ3D + v1).z = (vZ3D + v2).z); // because when vector promotion happens, they are 0 #local D3 = ((vZ4D + v1).t = (vZ4D + v2).t); // but when the vector is the same size, all the components are the same number, and 1 != 2 #local D4 = ((vZ5D + v1).transmit = (vZ5D + v2).transmit); #if (D2) #debug "2D" #else #if (D3) #debug "3D" #else #if (D4) #debug "4D" #else #debug "5D or scalar" #end // if #end // if #end // if #end // VectorDimTest #declare Vector1 = array mixed {pi, <1, 2>, <1, 2, 3>, <1, 2, 3, 4>, <1, 2, 3, 4, 5>} //#declare Vector = array mixed {rgb pi, rgb <1, 2>, rgb <1, 2, 3>, rgb<1, 2, 3, 4>, rgb <1, 2, 3, 4, 5>} #declare Vector = array mixed { rgb pi, rgb pi + 1, rgb pi + 2, rgb <1, 2>, rgb <1, 2>+1, rgb <1, 2>+2, rgb <1, 2, 3>, rgb <1, 2, 3>+1, rgb <1, 2, 3>+2, rgb<1, 2, 3, 4>, rgb<1, 2, 3, 4>+1, rgb<1, 2, 3, 4>+2, rgb <1, 2, 3, 4, 5>, rgb <1, 2, 3, 4, 5>+1, rgb <1, 2, 3, 4, 5>+2 } //#declare Vector = array mixed {<0, 0>+1, <0, 0>+2, <0, 0, 0>+1, <0, 0, 0>+2, <0, 0, 0, 0>+1, <0, 0, 0, 0>+2, <0, 0, 0, 0, 0>+1, <0, 0, 0, 0, 0>+2} #declare VN = dimension_size (Vector, 1)-1; #for (V, 0, VN) //#debug concat ("Vector = <", vstr(1+ceil((V+1)/2), Vector [V], ", ", 0, 0), "> ") VectorDimTest(Vector [V]) #debug concat (" Vector = <", vstr(5, Vector [V], ", ", 0, 0), "> ") #debug "\n" #if (mod(V+1,3)=0) #debug "\n" #end #end #debug "\n" #debug "\n" #debug "\n" #macro VPow(V, P) #end #macro VPow5D(V, P) #end // Returns true if vectors are equal, otherwise false #macro VEq(V1, V2) (V1.x = V2.x & V1.y = V2.y & V1.z = V2.z) #end #macro VEq5D(V1, V2) ( V1.x = V2.x & V1.y = V2.y & V1.z = V2.z & V1.filter = V2.filter & V1.transmit = V2.transmit) #end // Returns true if vector is <0,0,0>, otherwise false #macro VZero(V1) (V1.x = 0 & V1.y = 0 & V1.z = 0) #end // Returns true if vector is <0,0,0,0,0>, otherwise false #macro VZero5D(V1) (V1.x = 0 & V1.y = 0 & V1.z = 0 & V1.filter = 0 & V1.transmit = 0) #end #macro VLength5D(V) sqrt(V.x*V.x + V.y*V.y + V.z*V.z + V.filter*V.filter + V.transmit*V.transmit) #end #macro VNormalize5D(V) (V/sqrt(V.x*V.x + V.y*V.y + V.z*V.z + V.filter*V.filter + V.transmit*V.transmit)) #end #macro VDot5D(V1, V2) (V1.x*V2.x + V1.y*V2.y + V1.z*V2.z + V1.filter*V2.filter + V1.transmit*V2.transmit) #end