POV-Ray : Newsgroups : povray.general : looking for a box macro : Re: looking for a box macro Server Time
7 Aug 2024 21:26:21 EDT (-0400)
  Re: looking for a box macro  
From: Duncan Gray
Date: 8 Jun 2001 16:17:04
Message: <3b2132c0@news.povray.org>
Rich wrote:
> Unfortunately, most of the boxes are rotated incorrectly along their
length,
> depending on the angle between the points I'm assuming.  Here is a sample
> scene showing what I mean:

Here you go - try this for size:

#macro Wall(Point1,Point2,Width,Height,np)
  #local direct=(Point2-Point1);
  #local y_rot=180*atan2(direct.x,direct.z)/pi;
  #local direct=vrotate(direct,-<0,y_rot,0>);
  #local x_rot=-180*atan2(direct.y,direct.z)/pi;
  #local direct=vrotate(direct,-<x_rot,0,0>);
  box { <-Width/2,0,0>,<Width/2,Height,direct.z>
        rotate <x_rot,y_rot,0>
        pigment { color rgb .5 }
        translate Point1
    }
#end


The 'np' parameter is not used - this is just there so you can directly drop
this routine into the sample code you provided. I have added the pigment
statement here, again to match how you have modified Warp's code.

Sorry - I'm no good with vectors, cross and dot products, etc. I fall back
on basic pythag and do it the not-so-elegant way.

Hope this helps.

--
Duncan Gray
(warning: may contain traces of nut)


Post a reply to this message

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