POV-Ray : Newsgroups : povray.binaries.images : Symetric rotations : Re: Symetric rotations Server Time
17 Aug 2024 04:14:32 EDT (-0400)
  Re: Symetric rotations  
From: Tor Olav Kristensen
Date: 19 Nov 2001 20:22:57
Message: <3BF9B000.A12153C8@hotmail.com>
Tor Olav Kristensen wrote:
>...
> Dan, I had a second look at your code today.
> 
> And it took a while before I understood
> what you were up to.
> 
> - It seems you have made a kind of
> reorient macro, but with an added feature
> to also control how a "local" coordinate
> system within the object is repositioned.
> 
> Earlier I have been thinking along those
> lines too. (And I think that John VanSickle
> has made some similar macros.)
> 
> Now I have rewritten your "Here to there"
> macros a little. (And I also introduced
> some v3.5 features.)
>...

>...
> // Former H2tr macro:
> #macro Here2ThereTransform(vA1, vA2, vB1, vB2)
> 
>   #local vX1 = vnormalize(vA1);
>   #local vZ1 = vnormalize(vcross(vX1, vA2));
>   #local vY1 = vcross(vZ1, vX1);
>   #local vX2 = vnormalize(vB1);
>   #local vZ2 = vnormalize(vcross(vX2, vB2));
>   #local vY2 = vcross(vZ2, vX2);
>   #local TransA = transform { MatrixFromVectors(vX1, vY1, vZ1) }
>   #local TransAinv = transform { TransA inverse }
>   #local Fn = function { transform { TransAinv } }
> 
>   transform {
>     TransAinv
>     MatrixFromVectors(
>       Fn(vX2.x, vX2.y, vX2.z),
>       Fn(vY2.x, vY2.y, vY2.z),
>       Fn(vZ2.x, vZ2.y, vZ2.z)
>     )
>     TransA
>   }
> 
> #end // macro Here2ThereTransform
>...


I just returned from a little trip to North 
Norway today. - And while sitting on the airport
bus I convinced myself that the Here2ThereTransform()
macro I posted can be simplified further to this:


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#macro Here2ThereTransform(vA1, vA2, vB1, vB2)

  #local vX1 = vnormalize(vA1);
  #local vZ1 = vnormalize(vcross(vX1, vA2));
  #local vY1 = vcross(vZ1, vX1);                 
  #local vX2 = vnormalize(vB1);
  #local vZ2 = vnormalize(vcross(vX2, vB2));
  #local vY2 = vcross(vZ2, vX2);
  #local TA = transform { MatrixFromVectors(vX1, vY1, vZ1) inverse }
  #local TB = transform { MatrixFromVectors(vX2, vY2, vZ2) }

  transform { TA TB }

#end // macro Here2ThereTransform

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

I've just done some simple tests and it seems 
to work ok.


Tor Olav


Post a reply to this message

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