|
|
David Wallace <dar### [at] earthlinknet> wrote:
> If I have a complex transform like:
>
> <code>
> #macro ReorientCenter(Point1,Axis1,Point2,Axis2)
> #local vX1=vnormalize(Axis1);
> #local vX2=vnormalize(Axis2);
> #local vY=vnormalize(vcross(vX1,vX2));
> #local vZ1=vnormalize(vcross(vX1,vY));
> #local vZ2=vnormalize(vcross(vX2,vY));
> translate -Point1
> matrix < vX1.x, vY.x,vZ1.x, vX1.y,vY.y,vZ1.y, vX1.z,vY.z, vZ1.z, 0,0,0 >
> matrix < vX2.x,vX2.y,vX2.z, vY.x,vY.y, vY.z, vZ2.x,vZ2.y,vZ2.z, 0,0,0 >
> translate Point2
> #end
> </code>
>
> How would I retrieve the resulting matrix so that I could use it in a file like
> this:
>
> #write (lFile, "object { Lamb matrix <",mxx, mxy, mxz, myx, myy, myz, mzx, mzy,
> mzz, mtx, mty ,mtz,"> }n")
>
> My guess would be this:
>
> <code>
.....
> </code>
>
> Does anyone have an easier solution?
Apart from some possible optimizations, an illegal keyword and questionable
use of a global variable and, your guess seems ok. (Which POV-Ray version
are you using btw. ?)
- But why do you want to do it that way instead of just writing out the
transformations to the file directly ?
Like this:
#macro AppendReorientCenter(FileName, Point1, Axis1, Point2, Axis2)
#local vX1 = vnormalize(Axis1);
#local vX2 = vnormalize(Axis2);
#local vY = vnormalize(vcross(vX1, vX2));
#local vZ1 = vcross(vX1, vY);
#local vZ2 = vcross(vX2, vY);
#fopen File FileName append
#write(File, "ntransform {")
#write(File, "n translate ", -Point1)
#write(File, "n matrix <")
#write(File, "n ", vX1.x, ", ", vY.x, ", ", vZ1.x, ", ")
#write(File, "n ", vX1.y, ", ", vY.y, ", ", vZ1.y, ", ")
#write(File, "n ", vX1.z, ", ", vY.z, ", ", vZ1.z, ", ")
#write(File, "n ", 0, ", ", 0, ", ", 0)
#write(File, "n >")
#write(File, "n matrix <")
#write(File, "n ", vX2.x, ", ", vX2.y, ", ", vX2.z, ", ")
#write(File, "n ", vY.x, ", ", vY.y, ", ", vY.z, ", ")
#write(File, "n ", vZ2.x, ", ", vZ2.y, ", ", vZ2.z, ", ")
#write(File, "n ", 0, ", ", 0, ", ", 0)
#write(File, "n >")
#write(File, "n translate ", Point2)
#write(File, "n}")
#fclose File
#end // macro AppendReorientCenter
#declare YourFileName = "ReorientCenterTrans.txt";
#fopen FileHandle YourFileName write
#fclose FileHandle
AppendReorientCenter(
YourFileName,
<1, 3, 4>, <1, 5, 7>, <6, 4, 2>, <1, 9, 1>
)
Post a reply to this message
|
|