POV-Ray : Newsgroups : povray.general : Transformations help Server Time
5 Nov 2024 07:20:16 EST (-0500)
  Transformations help (Message 1 to 4 of 4)  
From: SharkD
Subject: Transformations help
Date: 18 Jun 2007 21:55:03
Message: <web.467736f6ab9c0994f850a8b00@news.povray.org>
In the following scene I am trying to create a macro that builds a wall
between two points. I am having trouble with the transformations. You'll
see that it works for the current input points, but doesn't work for all
points. I was wondering if anyone might help with getting the
transformations right. Thanks!



#include "math.inc"
#include "colors.inc"
#include "transforms.inc"

#ifndef (Included)
 #declare Vect1 = vrotate(<20,-20,20>, <0,0,0,>);
 #declare Vect2 = vrotate(<-10,10,-10>, <0,0,0,>);

 camera
 {
  up y
  right x * image_width / image_height
  location <0, 0, 0,> + vrotate(<0,0,-1,>,<15,-15,0,>) * 64
  look_at <0, 0, 0,>
 }

 camera
 {
  orthographic
  sky y
  up y * 64 * image_height / image_width
  right x * 64
  location vrotate(-z,<0,0,0,>) * 128
  look_at 0
 }

 sky_sphere {
   pigment {
     gradient y
     color_map {
       [0.0 rgb <0.6,0.7,1.0>]
       [0.7 rgb <0.0,0.1,0.8>]
     }
   }
 }

 light_source
 {
  <3000, 6000, -7000>
  rgb 1
  parallel
 }
#end

// ----------------------------------------
#macro StretchyWall(Point1, Point2, Width, Height)
 union
 {
  intersection
  {
   plane
   {
    y,0
    rotate x * 85
    translate z * Width/2
   }

   plane
   {
    y,0
    rotate x * -85
    translate z * -Width/2
   }

   box {<-1/2,0,-Width/2,>, <1/2,Height,Width/2,>}
  }

  #local Vector = Point1 - Point2;
  scale x * vlength(Vector)

  // Here's where I need help
  Shear_Trans(x, vrotate(y,<0,0,-(90-VAngleD(Vector,y))>), z)
  rotate z * (90 - VAngleD(y,Vector))
  rotate y * VRotationD(x,<Vector.x,0,Vector.z,>,y)

  translate ((Point1 + Point2)/2)
 }
#end

// ----------------------------------------
#ifndef (Included)

 sphere
 {
  Vect1, 1
  pigment {color Red}
 }

 sphere
 {
  Vect2, 1
  pigment {color Red}
 }


 object
 {
  StretchyWall(Vect1, Vect2, 4, 8)
  pigment {color White}
 }

 #declare Axis_Markers = union
 {
  sphere
  {
   0,0.005
   pigment{color rgb <0,0,0,>}
  }
  cylinder
  {
   0,x,0.005
   pigment{color rgb <1,0,0,>}
  }
  cylinder
  {
   0,y,0.005
   pigment{color rgb <0,1,0,>}
  }
  cylinder
  {
   0,z,0.005
   pigment{color rgb <0,0,1,>}
  }
 }

 object
 {
  Axis_Markers
  scale 32
 }
#end


Post a reply to this message

From: Penelope20k
Subject: Re: Transformations help
Date: 19 Jun 2007 04:29:43
Message: <467793f7$1@news.povray.org>
I will subjest you to change the way you create your box
Cause you use not the appropriate variables for orient your wall.
(you cant orient your wall by not using the section parameters ..)



Hence

if you condider your defining your wall as

point A .. the point in the middle of the depht of your wall (corner bottom
left)
point B  .. the point on the middle of depht of wall (corner up right)

then your wall will be in that direction and shear in the Y direction

hence

CREATE_WALL (point A, point B, Lenght, Depth)  , the height is not require
cause = yb-ya

hence

box {0, lenght*x+depth*z+height*y}
will create thet right dimension wall

translate  z*depth/2 ...will places it at good origine for orient it

Angle between x and AB is define by
Vangle(y, <xb,yb,zb>-<xa,ya,za>) will give you the angle

hence rotate y * Vangle(y, <xb,yb,zb>-<xa,ya,za>) * pi/180 ..will place your
wall
translate <xa,ya,za> will place it













news:web.467736f6ab9c0994f850a8b00@news.povray.org...
> In the following scene I am trying to create a macro that builds a wall
> between two points. I am having trouble with the transformations. You'll
> see that it works for the current input points, but doesn't work for all
> points. I was wondering if anyone might help with getting the
> transformations right. Thanks!
>
>
>
> #include "math.inc"
> #include "colors.inc"
> #include "transforms.inc"
>
> #ifndef (Included)
>  #declare Vect1 = vrotate(<20,-20,20>, <0,0,0,>);
>  #declare Vect2 = vrotate(<-10,10,-10>, <0,0,0,>);
>
>  camera
>  {
>   up y
>   right x * image_width / image_height
>   location <0, 0, 0,> + vrotate(<0,0,-1,>,<15,-15,0,>) * 64
>   look_at <0, 0, 0,>
>  }
>
>  camera
>  {
>   orthographic
>   sky y
>   up y * 64 * image_height / image_width
>   right x * 64
>   location vrotate(-z,<0,0,0,>) * 128
>   look_at 0
>  }
>
>  sky_sphere {
>    pigment {
>      gradient y
>      color_map {
>        [0.0 rgb <0.6,0.7,1.0>]
>        [0.7 rgb <0.0,0.1,0.8>]
>      }
>    }
>  }
>
>  light_source
>  {
>   <3000, 6000, -7000>
>   rgb 1
>   parallel
>  }
> #end
>
> // ----------------------------------------
> #macro StretchyWall(Point1, Point2, Width, Height)
>  union
>  {
>   intersection
>   {
>    plane
>    {
>     y,0
>     rotate x * 85
>     translate z * Width/2
>    }
>
>    plane
>    {
>     y,0
>     rotate x * -85
>     translate z * -Width/2
>    }
>
>    box {<-1/2,0,-Width/2,>, <1/2,Height,Width/2,>}
>   }
>
>   #local Vector = Point1 - Point2;
>   scale x * vlength(Vector)
>
>   // Here's where I need help
>   Shear_Trans(x, vrotate(y,<0,0,-(90-VAngleD(Vector,y))>), z)
>   rotate z * (90 - VAngleD(y,Vector))
>   rotate y * VRotationD(x,<Vector.x,0,Vector.z,>,y)
>
>   translate ((Point1 + Point2)/2)
>  }
> #end
>
> // ----------------------------------------
> #ifndef (Included)
>
>  sphere
>  {
>   Vect1, 1
>   pigment {color Red}
>  }
>
>  sphere
>  {
>   Vect2, 1
>   pigment {color Red}
>  }
>
>
>  object
>  {
>   StretchyWall(Vect1, Vect2, 4, 8)
>   pigment {color White}
>  }
>
>  #declare Axis_Markers = union
>  {
>   sphere
>   {
>    0,0.005
>    pigment{color rgb <0,0,0,>}
>   }
>   cylinder
>   {
>    0,x,0.005
>    pigment{color rgb <1,0,0,>}
>   }
>   cylinder
>   {
>    0,y,0.005
>    pigment{color rgb <0,1,0,>}
>   }
>   cylinder
>   {
>    0,z,0.005
>    pigment{color rgb <0,0,1,>}
>   }
>  }
>
>  object
>  {
>   Axis_Markers
>   scale 32
>  }
> #end
>
>
>


Post a reply to this message

From: Tim Attwood
Subject: Re: Transformations help
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

From: SharkD
Subject: Re: Transformations help
Date: 19 Jun 2007 14:25:01
Message: <web.46781e573ab75d8bbf3c58a60@news.povray.org>
Thank you!


Post a reply to this message

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