#version 3.8; global_settings {assumed_gamma 1.0 } #local v1 = 1; #local v1x = v1 * x; #local v1y = v1 * y; #local v1z = v1 * z; #local v1f = v1 * <0,0,0,1,0>; #local v1t = v1 * <0,0,0,0,1>; #debug concat ("v1x = ", vstr(5, v1x, ", ", 0, -1), "\n") #debug concat ("v1y = ", vstr(5, v1y, ", ", 0, -1), "\n") #debug concat ("v1z = ", vstr(5, v1z, ", ", 0, -1), "\n") #debug concat ("v1f = ", vstr(5, v1f, ", ", 0, -1), "\n") #debug concat ("v1t = ", vstr(5, v1t, ", ", 0, -1), "\n") #local v5 = <1, 2, 3, 4, 5>; #local v5x = v5 * x; #local v5y = v5 * y; #local v5z = v5 * z; #local v5f = v5 * <0,0,0,1,0>; #local v5t = v5 * <0,0,0,0,1>; #debug concat ("v5x = ", vstr(5, v5x, ", ", 0, -1), "\n") #debug concat ("v5y = ", vstr(5, v5y, ", ", 0, -1), "\n") #debug concat ("v5z = ", vstr(5, v5z, ", ", 0, -1), "\n") #debug concat ("v5f = ", vstr(5, v5f, ", ", 0, -1), "\n") #debug concat ("v5t = ", vstr(5, v5t, ", ", 0, -1), "\n") //#error "No objects in scene" #declare DataFilename = "TestedValues.txt"; #declare DataFilename2 = "Misidentified_Values.txt"; #fopen DataFile DataFilename write #fopen DataFile2 DataFilename2 write #declare Vectors = 0; #declare Correct = 0; #declare Misidentified = 0; #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); #local v15D = <1, 1, 1, 1, 1>; #local v0v5 = v0*v15D; #if (D2) //#debug "2D " #local Size = 2; #else #if (D3) //#debug "3D " #local Size = 3; #else #if (D4) //#debug "4D " #local Size = 4; #else #local sqv0 = v0 * v0; #local v0p1 = v0 + 1; //#local Result = rgb (sqv0+1) + (sqv0+1); #local rgbv1 = rgb (v0-1); #local Result = rgb (sqv0+1) + (sqv0+1) + rgbv1; //#if (Result.transmit = Result.filter & Result.filter != Result.z) #if ( Result.x = Result.y & Result.y = Result.z & Result.z != Result.transmit & Result.transmit = Result.filter& v0v5.x = v0v5.y & v0v5.y = v0v5.z & v0v5.z = v0v5.filter & v0v5.filter = v0v5.transmit ) //#debug "Scalar" #local Size = 1; #else //#debug "5D " #local Size = 5; #end #end // if #end // if #end // if Size #end // end macro #macro PermuteVectorComponents (NumComponents) #declare LastSize = 0; #local N = 10; #local P = 10; #local Base = array [5] {-N, -1, 0, 1, P}; #local Total = pow (5, NumComponents); #for (I, 0, Total) #local Index = I; #local V = array [NumComponents] //{<1, 0, 0, 0, 0>, <0, 1, 0, 0, 0>, <0, 0, 1, 0, 0>, <0, 0, 0, 1, 0>, <0, 0, 0, 0, 1>}; //#local Vector = <0, 0, 0, 0, 0>; #for (J, 0, NumComponents-1) #local Digit = mod (Index, 5); #local V[J] = Base[Digit]; //#local Vector = Vector + V[J]; #local Index = div (Index, 5); #end #local Vector = < #for (C, 0, NumComponents-1) V[C] #if (C < NumComponents-1) , #end #end >; //#debug concat ("Vector = ", vstr(NumComponents, Vector, ", ", 0, 3), " \n") #local Vsize = VectorDimTest(Vector); #if (Vsize > LastSize) #debug "---------------------\n" #end #if (Vsize = NumComponents) #local Result = " [OK]"; #declare Correct = Correct + 1; #else #local Result = "***** MISIDENTIFIED! ****"; #declare Misidentified = Misidentified + 1; #write ( DataFile2, concat (vstr(NumComponents, Vector, ", ", 0, -1),", \n") ) #end //#if (Vsize = 1) //#debug "Scalar " //#debug concat (" Value = ", str(Vector, 0, 0), "\n") //#write ( DataFile, concat (" Value = ", str(Vector, 0, 0), " identified as a scalar. Actual size is ",str(NumComponents, 0, 0), ". ", Result, "\n") ) //#else //#debug concat (str(Vsize, 0, 0), "D ") //#debug concat (" Value = <", vstr(Vsize, Vector, ", ", 1, 0), "> \n") #write ( DataFile, concat (" Value = ", vstr(NumComponents, Vector, ", ", 0, -1), " identified as a vector of size ", str(Vsize, 0, 0), ". Actual size is ",str(NumComponents, 0, 0), ".", Result, " \n") ) //#end //#for (C, 1, Vsize) // Component (C) //#end #local LastSize = Vsize; #declare Vectors = Vectors + 1; #end #end PermuteVectorComponents (2) PermuteVectorComponents (3) PermuteVectorComponents (4) PermuteVectorComponents (5) #debug concat (str(Vectors, 0, 0), " vectors written to ", DataFilename, ". \n") #debug concat (str(Correct, 0, 0), " identified correctly. \n") #debug concat (str(Misidentified, 0, 0), " misidentified. \n") #fclose DataFile #fclose DataFile2 #error "No objects in scene" #macro WritePermutedVectors (Components, Smallest, Largest, DataFilename) #fopen DataFile DataFilename write #local Vectors = 0; #for (VS, Smallest, Largest) #local N = 10; #local P = 10; #local Base = array [5] {-N, -1, 0, 1, P}; #local Total = pow (5, NumComponents); #for (I, 0, Total) #local Index = I; #local V = array [NumComponents] //{<1, 0, 0, 0, 0>, <0, 1, 0, 0, 0>, <0, 0, 1, 0, 0>, <0, 0, 0, 1, 0>, <0, 0, 0, 0, 1>}; //#local Vector = <0, 0, 0, 0, 0>; #for (J, 0, NumComponents-1) #local Digit = mod (Index, 5); #local V[J] = Base[Digit]; //#local Vector = Vector + V[J]; #local Index = div (Index, 5); #end #local Vector = < #for (C, 0, NumComponents-1) V[C] #if (C < NumComponents-1) , #end #end >; //#debug concat ("Vector = ", vstr(NumComponents, Vector, ", ", 0, 3), " \n") #write ( DataFile, "<",vstr(3, Nodes[NodeCount],",",0,-1),">,\n") #local Vectors = Vectors + 1; #end #end #fclose DataFile #debug concat (str(Vectors, 0, 0), " written to ", DataFilename, ". \n") #end