POV-Ray : Newsgroups : povray.advanced-users : Request: transform from a rectangle. : Re: Request: transform from a rectangle. Server Time
29 Jul 2024 08:22:43 EDT (-0400)
  Re: Request: transform from a rectangle.  
From: Rune
Date: 30 Sep 2002 15:21:20
Message: <3d98a430@news.povray.org>
Greg M. Johnson wrote:
>>  To reorient something and really know what
>> it's going to look like, you need to align
>> to two axis.
>
> I failed miserably in my attempt at this.
> Is there a generic solution already out there?

Not sure if this is exactly what you're looking for, but:

Suppose that you want the z axis aligned to Z_vector and the y axis
aligned to Normal_vector. If the Z_vector and the Normal_vector are not
perpendicular, you want the Z_vector to be dominant.

Now you can align the object using some code like this (untested code):

#include "math.inc"
#include "transforms.inc"
#declare ObjectZ = vnormalize(Z_vector);
#declare ObjectY = VPerp_Adjust(Normal_vector,Z_vector);
#declare ObjectX = vcross(ObjectY,ObjectZ);
#declare Trans = Matrix_Trans(ObjectX,ObjectY,ObjectZ,<0,0,0>);
object {MyObject transform {Trans}}

Well, that's the method I use all the time anyway.

Rune
--
3D images and anims, include files, tutorials and more:
rune|vision:  http://runevision.com (updated Sep 8)
POV-Ray Ring: http://webring.povray.co.uk


Post a reply to this message

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