// Test vector arythmetic // $Id: test_vector.exper,v 1.7 2002/04/24 14:51:56 boissieu Exp $ define vector a = (1,0,0) define vector b = (0,1,0) define vector c = (0,0,1) // operations on vectors define vector v = 3.0 * a + ( b*4.0 + 5.0 * c ) // absolute value if | v - (3,4,5)| > 0.001 then error "Basic vector arythmetic " v end // access to components if xCoord(v) != 3.0 then error "Vector destructor xCoord() failed" end if yCoord(v) != 4.0 then error "Vector destructor yCoord() failed" end if zCoord(v) != 5.0 then error "Vector destructor zCoord() failed" end if | a | != 1.0 then error "|" a "| != 1.0" end if | b | != 1.0 then error "|" b "| != 1.0" end if | c | != 1.0 then error "|" c "| != 1.0" end if a == b then error "Operator == failed" end define vector u = (1,0,0) if a != u then error "Operator != failed" end bloc checkRandom111 is define vector r = vector random() if xCoord(r) < 0 || xCoord(r) >= 1.0 then error "Random().x range error" end if yCoord(r) < 0 || yCoord(r) >= 1.0 then error "Random().y range error" end if zCoord(r) < 0 || zCoord(r) >= 1.0 then error "Random().z range error" end end for 100 do checkRandom111 end for 100 do set r = vector random( (1,2,3), (4,5,6) ) if xCoord(r) < 1 || xCoord(r) >= 4.0 then error "Random(vE,vE).x range error" end if yCoord(r) < 2 || yCoord(r) >= 5.0 then error "Random(vE,vE).y range error" end if zCoord(r) < 3 || zCoord(r) >= 6.0 then error "Random(vE,vE).z range error" end end if "(3, 4, 5)" != string(v) then error "Convertion vE -> sE failed : " v end print "========= test_vector passed OK" quit