|
|
Rune <run### [at] inamecom> wrote:
: Thanks, I understand it well with two vectors, but I don't quite grasp how
: to handle n vectors... It hasn't really anything to do with the clock like
: in the example; it was just easier for me to explain what I meant that way.
: What I need is a weighted average on n vectors V[N], each with their own
: weight W[N].
Perhaps something like this:
#declare C = <0,0,0>;
#declare Clen = 0;
#declare TotalW = 0;
#declare Ind = 0;
#while(Ind<Amount)
#declare C = C+vnormalize(V[Ind])*W[Ind];
#declare Clen = Clen+vlength(V[Ind])*W[Ind];
#declare TotalW = TotalW+W[Ind];
#declare Ind=Ind+1;
#end
#declare C = vnormalize(C/TotalW)*(Clen/TotalW);
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
|