POV-Ray : Newsgroups : povray.general : Convert translate/rotate list to single translate/rotate-Statement : Re: Convert translate/rotate list to single translate/rotate-Statement Server Time
29 Jul 2024 00:33:50 EDT (-0400)
  Re: Convert translate/rotate list to single translate/rotate-Statement  
From: clipka
Date: 7 Dec 2013 15:23:31
Message: <52a383c3@news.povray.org>
Am 07.12.2013 20:25, schrieb Juergen:
> Le_Forgeron <jgr### [at] freefr> wrote:
>> Le 07/12/2013 18:24, Juergen nous fit lire :
>>
>> Do you need to know the t* & r*, or just to have them available as a
>> transform for your macro ?
>>
>> Look around
>> http://wiki.povray.org/content/Documentation:Tutorial_Section_2.2#Matrix
>>
>> If you really need t* & r*, then you need to learn how to transform each
>> operation as a weighted 4D matrix, multiply them in order and interpret
>> it (if possible) to extract r* & t*.
>>
>> But I doubt it would be possible.
>> (The single transform with a single 4D matrix is no problem, but it
>> seldom turn to be only a translate+rotate )
>
> Currently I need the concret values for the translate ans rotate.
>
> The actual situation is, that I've two macros
>
> AnimTranslate(arVertics, vTrans)  and  AnimRotate(arVertics, vRot)
>
> to modity the mesh. arVertics ist an array with the vertics ofthe mesh.
> AnimTranslate() simply adds the offset to each vector, AnimRotate() internally
> uses "vrotate" to make the rotation.

Do you need to have AnimTranslate and AnimRotate as separate macros, or 
would it be ok if you had just one AnimTransform macro?

In the latter case, you'll want to use the following construct:


#declare MyTransform = transform {
   translate <1,2,3>
   rotate <30,50,-20>
   translate<-2,4,-5>
   rotate<-40,130,70>
   ......// lots of more transforms
   rotate <10,0,40>
}

#macro AnimTransform(arVertics, tTransform)
   ...
   #declare vNew = vtransform(vOld, tTransform);
   ...
#end


If you need to apply the inverse transform, you can also use:

#declare MyInvTransform = transform { MyTransform inverse }


You might think of a transform as a container of rotations, translations 
and scales to be applied in sequence; internally however, the sequence 
is compiled into a single equivalent matrix transform for better 
performance.


Post a reply to this message

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