POV-Ray : Newsgroups : povray.general : Transformation to align two axes? Server Time
30 Jul 2024 12:27:59 EDT (-0400)
  Transformation to align two axes? (Message 1 to 5 of 5)  
From: CShake
Subject: Transformation to align two axes?
Date: 11 Mar 2009 20:26:33
Message: <49b856b9$1@news.povray.org>
I'm having trouble thinking through a transformation problem, and I'm 
pretty sure this isn't too crazy of a problem.
The idea is that I have an object centered at the origin, let's say a 
thin oval with the major and minor radii along the x and z axes, (so the 
normal on the flat face is in y). I want to rotate this so the x and y 
axes are pointing in the direction of two arbitrary (normalized and 
perpendicular) vectors.

transforms.inc has the Point_At_Trans(newY) that will do half this 
problem, but if I want to then rotate the x axis to align with another 
vector, it will mess up the original translation.

The object can then be translated to be centered at a given point, but 
that part is easy.


Post a reply to this message

From: clipka
Subject: Re: Transformation to align two axes?
Date: 11 Mar 2009 22:30:01
Message: <web.49b872905a6edcc2801985dd0@news.povray.org>
CShake <cshake+pov### [at] gmailcom> wrote:
> I'm having trouble thinking through a transformation problem, and I'm
> pretty sure this isn't too crazy of a problem.
> The idea is that I have an object centered at the origin, let's say a
> thin oval with the major and minor radii along the x and z axes, (so the
> normal on the flat face is in y). I want to rotate this so the x and y
> axes are pointing in the direction of two arbitrary (normalized and
> perpendicular) vectors.

Why rotate when you can shear? :)

  transform { Shear_Trans(newX,VCross(newX,newZ),newZ) }

There. Shear_Trans is your friend, too :)


Post a reply to this message

From: Tim Attwood
Subject: Re: Transformation to align two axes?
Date: 11 Mar 2009 22:51:29
Message: <49b878b1$1@news.povray.org>
> I'm having trouble thinking through a transformation problem, and I'm 
> pretty sure this isn't too crazy of a problem.
> The idea is that I have an object centered at the origin, let's say a 
> thin oval with the major and minor radii along the x and z axes, (so the 
> normal on the flat face is in y). I want to rotate this so the x and y 
> axes are pointing in the direction of two arbitrary (normalized and 
> perpendicular) vectors.
> 
> transforms.inc has the Point_At_Trans(newY) that will do half this 
> problem, but if I want to then rotate the x axis to align with another 
> vector, it will mess up the original translation.
> 
> The object can then be translated to be centered at a given point, but 
> that part is easy.

I think what you want is Shear_Trans. 
As long as the vectors you supply are normal and perpendicular
the object just gets rotated. You can use VPerp_To_Plane to 
get the third vector...

#include "transforms.inc"
#include "math.inc"

object { 
   Foo
   Shear_Trans(Xvec,YVec,VPerp_To_Plane(Xvec,YVec))
}


Post a reply to this message

From: CShake
Subject: Re: Transformation to align two axes?
Date: 11 Mar 2009 23:23:45
Message: <49b88041$1@news.povray.org>
clipka wrote:
> Why rotate when you can shear? :)
> 
>   transform { Shear_Trans(newX,VCross(newX,newZ),newZ) }
> 
> There. Shear_Trans is your friend, too :)
> 

Thanks, that works perfectly. I knew there was something stupid simple 
to use, but was afraid of all the Shear transforms because it always 
makes me think of distortion.


Post a reply to this message

From: Alain
Subject: Re: Transformation to align two axes?
Date: 12 Mar 2009 16:38:44
Message: <49b972d4$1@news.povray.org>
CShake nous illumina en ce 2009-03-11 23:23 -->
> clipka wrote:
>> Why rotate when you can shear? :)
>>
>>   transform { Shear_Trans(newX,VCross(newX,newZ),newZ) }
>>
>> There. Shear_Trans is your friend, too :)
>>
> 
> Thanks, that works perfectly. I knew there was something stupid simple 
> to use, but was afraid of all the Shear transforms because it always 
> makes me think of distortion.
It IS a distortion, as is any unevent scaling. It change the basic shape of the 
object, but in a very controled way.

-- 
Alain
-------------------------------------------------
Q: If pro is opposite of con,then what is the opposite of progress?

A: Congress!
Men's restroom, House of Representatives, Washington , DC


Post a reply to this message

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