|
|
On 5 Dec 2001 10:52:54 -0500, Ron Parker wrote:
> On Wed, 05 Dec 2001 10:05:06 -0500, Timothy R. Cook wrote:
>> Is there a way to rotate an object around its local coordinate
>> axes? What I have is this:
>
> In general, you do local transformations before global ones. If it's
> too late for that, you need to transform by the inverse of whatever the
> global one was, then do the local, then transform by the global one again.
>
> I once wrote some macros to handle local and global transforms in a
> somewhat intuitive way. They didn't work in 3.1, due to a parser bug
> in the transform{} statement, but they should work in 3.5. If you'd
> like, I can dig them up; they're on this server somewhere.
Here they are. But of course, if you're using Moray they won't be of any
use to you.
#macro trans_rotate( trans, rot, islocal )
#declare trans=transform {
#if (islocal) rotate rot #end
transform{trans}
#if (!islocal) rotate rot #end
}
#end
#macro trans_scale( trans, scl, islocal )
#declare trans=transform {
#if (islocal) scale scl #end
transform{trans}
#if (!islocal) scale scl #end
}
#end
#macro trans_translate( trans, tr, islocal )
#declare trans=transform {
#if (islocal) translate tr #end
transform{trans}
#if (!islocal) translate tr #end
}
#end
#declare My_trans=transform{ scale 1 } // identity matrix
trans_rotate( My_trans, 45*y, no ) // global rotate
trans_translate( My_trans, x, yes ) // local translate
--
#macro R(P)z+_(P)_(P)_(P+1)_(P+1)+z#end#macro Q(C,T)bicubic_patch{type 1u_steps
6v_steps 6R(1)R(3)R(5)R(7)pigment{rgb z}}#end#macro _(Y)#local X=asc(substr(C,Y
,1))-65;<T+mod(X,4)div(X,4)9>-2#end#macro O(T)Q("ABEFUQWS",T)Q("WSXTLOJN",T)#
end O(0)O(3)Q("JNKLCGCD",0)light_source{x 1}// ron### [at] povrayorg
Post a reply to this message
|
|