POV-Ray : Newsgroups : povray.general : Transformations help : Re: Transformations help Server Time
31 Jul 2024 08:19:30 EDT (-0400)
  Re: Transformations help  
From: Tim Attwood
Date: 19 Jun 2007 04:56:59
Message: <46779a5b$1@news.povray.org>
A shearing transform combines rotations and scaling.
The length of the new axis vectors are the scaling
factors, and the directions of the vectors are the
rotations.  I moved the box to rest one end on the
origin so that you know where it is after stretching...
then the new x axis is just with one point translated
(subtracted) to rest on the origin, and contains the
wall length scaling. The yaxis is still up, so that is
just y still. The new z axis is a vector which is perpendicular
to the wall, that is: it is perpendicular to the new x and y axis.
With math that is the cross product, and POV has
that function as vcross. The vnormalize function makes
sure that the length of that vector is one, so that there is
no scaling. So then you apply the shear, and translate
the wall to sit it on Point1.

#macro StretchyWall(Point1, Point2, Width, Height)
   intersection {
      plane { y,0
         rotate x * 85
         translate z * Width/2
      }
      plane { y,0
         rotate x * -85
         translate z * -Width/2
      }
      box {<0,0,-Width/2,>, <1,Height,Width/2,>}
      #local xaxis = Point2 - Point1;
      #local yaxis = <0,1,0>;
      #local zaxis = vnormalize(vcross(xaxis,yaxis));
      Shear_Trans(xaxis,yaxis,zaxis)
      translate Point1
   }
#end


Post a reply to this message

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