POV-Ray : Newsgroups : povray.newusers : Aligned box? : Re: Aligned box? Server Time
29 Jul 2024 14:25:43 EDT (-0400)
  Re: Aligned box?  
From: gonzo
Date: 8 Sep 2005 00:36:14
Message: <431fbfbe@news.povray.org>
Tyler Eaves wrote:
> On Wed, 07 Sep 2005 14:58:11 -0400, Mike Williams  
> <nos### [at] econymdemoncouk> wrote:

>> #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

I'm assuming you're generating P1 & P2 somewhere else?  I believe you 
either have to ensure both y points are the same before passing them to 
the macro or else remove them in the macro.  Does this work?

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




RG


Post a reply to this message

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