|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Imagine two vectors, A and B.
C is a regular weighted average of the two vectors, say clock*A +
(1-clock)*B.
With this type of average the vector-point is linearly "interpolated", but
the rotation and length of the vector is not.
To make the length of C linearly interpolated is easy, but how do I linearly
interpolate the "rotation"?
I need a general method that can average not just two, but multiple vectors.
How can I do this?
Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated January 6)
/ Also visit http://www.povrayusers.org
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
A start:
camera { location <0,2,-6>*.8 look_at 0 angle 35 translate y*.5}
light_source { y*100, 1 }
plane { y,0 pigment { checker rgb 1, rgb .5 } }
#declare A = <-1,1.5,0>;
#declare B = <1,.5,.5>;
cylinder { 0,A,.025 pigment { rgb x } }
cylinder { 0,B,.025 pigment { rgb x } }
#declare An = vnormalize(A);
#declare Bn = vnormalize(B);
#declare Al = vlength(A);
#declare Bl = vlength(B);
#declare Angle = degrees(acos(vdot(An,Bn)));
#declare Perp = vcross(A,B);
#declare Clock=0;
#while(Clock<=1)
#declare Len = Al*(1-Clock)+Bl*Clock;
#declare C = vaxis_rotate(An, Perp, Angle*Clock)*Len;
cylinder { 0,C,.02 pigment { rgb x+y } }
#declare Clock=Clock+.1;
#end
--
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
PS: If you need an explanation about the math used, just ask.
--
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Warp" wrote:
> PS: If you need an explanation about the math used, just ask.
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].
How can that be done?
Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated January 6)
/ Also visit http://www.povrayusers.org
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Rune" wrote:
> What I need is a weighted average on n vectors V[N], each
> with their own weight W[N].
Well, let me just reveal that what I ultimately want to do is to take an
average of multiple matrixes. Got any ideas?
Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated January 6)
/ Also visit http://www.povrayusers.org
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Rune wrote:
> Imagine two vectors, A and B.
> C is a regular weighted average of the two vectors, say clock*A +
> (1-clock)*B.
>
> With this type of average the vector-point is linearly "interpolated", but
> the rotation and length of the vector is not.
>
> To make the length of C linearly interpolated is easy, but how do I linearly
> interpolate the "rotation"?
>
> I need a general method that can average not just two, but multiple vectors.
> How can I do this?
Make normalized copies of the two vectors, a and b.
Find the angle, A, between them: 2*asin(vlength(b-a)/2).
The vector you want is (a+b)/2 + tan(-A/2+A*clock)*vlength((a+b)/2)*vnorm(b-a)
Where clock goes from 0 to 1 from vector a to vector b.
--
David Fontaine <dav### [at] faricynet> ICQ 55354965
My raytracing gallery: http://davidf.faricy.net/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
David Fontaine wrote:
> Make normalized copies of the two vectors, a and b.
> Find the angle, A, between them: 2*asin(vlength(b-a)/2).
> The vector you want is (a+b)/2 + tan(-A/2+A*clock)*vlength((a+b)/2)*vnorm(b-a)
> Where clock goes from 0 to 1 from vector a to vector b.
This math is untested BTW.
--
David Fontaine <dav### [at] faricynet> ICQ 55354965
My raytracing gallery: http://davidf.faricy.net/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Btw, the code I posted probably doesn't make what you want. Sorry.
--
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I just tackled this problem myself:
given vectors v0, v1 (I assume they are at the origin)
#declare vn = vnormalize(vcross(v0,v1));
#declare v2 =
vaxis_rotate(v0,vn,clock*degrees(acos(vdot(vo,v1)/(vlength(v0)*vlength(v1)))));
v2 is in the right direction, so normalize it and adjust the length normally.
Josh
Rune wrote:
> Imagine two vectors, A and B.
> C is a regular weighted average of the two vectors, say clock*A +
> (1-clock)*B.
>
> With this type of average the vector-point is linearly "interpolated", but
> the rotation and length of the vector is not.
>
> To make the length of C linearly interpolated is easy, but how do I linearly
> interpolate the "rotation"?
>
> I need a general method that can average not just two, but multiple vectors.
> How can I do this?
>
> Rune
> --
> \ Include files, tutorials, 3D images, raytracing jokes,
> / The POV Desktop Theme, and The POV-Ray Logo Contest can
> \ all be found at http://rsj.mobilixnet.dk (updated January 6)
> / Also visit http://www.povrayusers.org
--
Josh English -- Lexiphanic Lethomaniac
eng### [at] spiritonecom
The POV-Ray Cyclopedia http://www.spiritone.com/~english/cyclopedia/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|