POV-Ray : Newsgroups : povray.general : Transformations help : Transformations help Server Time
31 Jul 2024 08:19:16 EDT (-0400)
  Transformations help  
From: SharkD
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

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