POV-Ray : Newsgroups : povray.binaries.images : Symetric rotations : Re: Symetric rotations Server Time
19 Nov 2024 20:41:43 EST (-0500)
  Re: Symetric rotations  
From: Tor Olav Kristensen
Date: 13 Nov 2001 21:50:11
Message: <3BF1DBA4.2E9C4490@hotmail.com>
Dan Johnson wrote:
> 
> Tor Olav Kristensen wrote:
> 
> >
> > Sorry, I think that I misunderstood your problem.
> 
> Most people don't understand me.  Including myself.
> Thanks for the input maybe I will try working more on it in a few
> months.  It was more of an interesting toy to begin with.  When I am
> serious about transforms I usually use a much more powerful transform
> macro.  H2t it by far the most used macro I have ever written(By me at
> least).  I think the code below will effectively demonstrate how ez it
> makes things.  Perfectly face bonded tetrahedra.  If you keep using
> Move1 you will get a tetrahelix.
>...

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.)

Can you please have a look at these macros
to see if they still work as you intended ?


Tor Olav


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

// A common macro:
#macro MatrixFromVectors(vA, vB, vC)

  matrix <
    vA.x, vA.y, vA.z,
    vB.x, vB.y, vB.z,
    vC.x, vC.y, vC.z,
       0,    0,    0
  >

#end // macro macro MatrixFromVectors


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


// Former H2t macro
#macro H2T_Transform(pCtrI, pRef1I, pRef2I, pCtrF, pRef1F, pRef2F)

  transform {
    translate -pCtrI
    Here2ThereTransform(
      pRef1I - pCtrI, pRef2I - pCtrI,
      pRef1F - pCtrF, pRef2F - pCtrF
    )
    translate  pCtrF
  }

#end // macro H2T_Transform

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


Post a reply to this message

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