POV-Ray : Newsgroups : povray.newusers : Aligned box? : Re: Aligned box? Server Time
29 Jul 2024 14:25:43 EDT (-0400)
  Re: Aligned box?  
From: Mike Williams
Date: 8 Sep 2005 02:11:07
Message: <oLM2cJATW9HDFwbz@econym.demon.co.uk>
Wasn't it Tyler Eaves who wrote:
>On Wed, 07 Sep 2005 14:58:11 -0400, Mike Williams  
><nos### [at] econymdemoncouk> wrote:
>
>> Wasn't it Tyler Eaves who wrote:
>>> I'm looking for some way to specify a box at an angle. The way I see  
>>> it, a
>>> box could be specified by giving 2 points, which would be the center of
>>> two oppisite faces, and would define one dimesion, call it length, and
>>> then giving the length of the width and height. This would be roughly
>>> comprable to the way a cylinder is specified. I can't seem to think of  
>>> any
>>> obvious way to do this (3d math is not a strength of mine...)
>>
>> The first thing that springs to mind is to write a macro like this:
>>
>> #include "transforms.inc"
>> #macro aligned_box(P1, P2, H, W)
>>   #local L = abs(vlength(P2-P1));
>>   box {<0,-H/2,-W/2><L,H/2,W/2>
>>     transform {Reorient_Trans(x,P2-P1)}
>>     translate P1
>>   }
>> #end
>>
>
>That comes VERY close. Actually, it works as I requested, although missing  
>an implied criteria. I didn't specify it, but I need the box to maintain a  
>vertical orientation, whereas your macro induces a rotation around the  
>P1-P2 axis. I'm guessing this is an artifact of the Reorient_Trans

Point_At_Trans seems to produce boxes that are vertically aligned more
of the time, but I can't predict which of the directions is going to be
the height and which will be the width

#include "transforms.inc"
#macro aligned_box(P1, P2, H, W)
  #local L = abs(vlength(P2-P1));
  box {<-W/2,0,-H/2><W/2,L,H/2>
    transform {Point_At_Trans(P2-P1)}
    translate P1
  }
#end

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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