|
|
Wasn't it Anders K. who wrote:
>I think you misunderstand the problem. "t" is defined as <0, 0, 0, 1>, and
>the ".t" operator extracts the fourth component of the vector. It has
>nothing to do with filter or transmit.
>
>To make it more clear, this script:
> #debug concat(str((<1, 0, 0> + t*1).t, 0, -1), "\n")
> #debug concat(str((<1, 0, 0> + 1*t).t, 0, -1), "\n")
>outputs:
> 1.000000
> 0.000000
>even though the two results should be identical.
Oh, right. It's a precedence bug.
What we'd expect to happen is for the multiplication to happen first,
but it doesn't, the addition happens first; and for that to happen the 1
may need to be expanded to a 5d vector.
If we add brackets to the t*1 and 1*t we get the "right" answer 1.000000
in both cases
#debug concat(str((<1, 0, 0> + (t*1)).t, 0, -1), "\n") // 1.000000
#debug concat(str((<1, 0, 0> + (1*t)).t, 0, -1), "\n") // 1.000000
If we force the addition to happen first, then we get the wrong answer
#debug concat(str(((<1, 0, 0> + t)*1).t, 0, -1), "\n") // 1.000000
#debug concat(str(((<1, 0, 0> + 1)*t).t, 0, -1), "\n") // 0.000000
What's happening is that in the second case the "1" gets expanded to
<1,1,1,1,1>. This gets added to <1,0,0,0,0> to give <2,1,1,1,1>.
<2,1,1,1,1> * <0,0,0,1,0> gives <0,0,0,0,1>.
#declare Test = <2,1,1,1,1>*<0,0,0,1,0>;
V5Show("Test ",Test) // Test: 0.00, 0.00, 0.00, 0.00, 1.00
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|