POV-Ray : Newsgroups : povray.general : shear matrix problem : Re: shear matrix problem Server Time
29 Jul 2024 12:29:53 EDT (-0400)
  Re: shear matrix problem  
From: Roman Reiner
Date: 14 Jul 2011 08:10:00
Message: <web.4e1edc227fd51405257ce790@news.povray.org>
In that case it should read Reorient_Trans(<1,0,0>, <d.x, 0, d.z>) where d is,
again, P2-P1.

Also b = d.x needs to be replaced with b = vlength(<d.x, 0, d.z>).

Altogether:

//Start Code
#local P1 = <-1.6, 0.1, -.5>;
#local P2 = < 1.7, 1.5, 1>;

#local Point =
sphere {
   <0,0,0>, 0.05
   pigment { rgb 1 }
}

object {Point}
object {Point translate P1  pigment {rgb <1,0,0>}}
object {Point translate P2  pigment {rgb <1,1,0>}}

#local Segment =
box {<0.00, 0.00, -0.010>, <1.00, 0.10, 0.010>}

#declare d = P2-P1;

#local a = 0;
#local b = vlength(<d.x, 0, d.z>);
union {
   #while (a < b)
     object {Segment
       translate <a, 0, 0>
       #if (mod(a,2)=0)
         pigment {rgb <0,1,0>}
       #else
         pigment {rgb <0,0,1>}
       #end
       #local a=a+1;
     }
   #end
   clipped_by {plane {x, b}}
   matrix <1  d.y/b,  0,
           0,  1,  0,
           0,  0,  1,
           0,  0,  0>
   Reorient_Trans(x, d*(1-y)) //short for Reorient_Trans(<1,0,0>, <d.x, 0, d.z>)
   translate P1
}
//End Code

[Note, that the above version shears the segments by dragging the far end up
resulting in the originally unit length segments to get longer. If you want them
to remain at unit length you need to use

   clipped_by {plane {x, vlength(d)}}
   matrix <b/vlength(d)  d.y/vlength(d),  0,
           0,  1,  0,
           0,  0,  1,
           0,  0,  0>

instead.]

Feel free to ask if you need any explanations!
Regards Roman

Thomas de Groot <tenDOTlnDOTretniATtoorgedDOTt> wrote:
> Yes, that works, but only because z remains 0 in your code. That is why
> I am not too sure about not using VDist(). The Reorient_Trans() is
> necessary for those cases where P2 (and/or P1) moves also along the
> z-axis. Or is there another way? The code should be valid for *all* 3D
> locations of P1 and P2.
>
> Thomas


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.