|
![](/i/fill.gif) |
Here is a macro I didn't write. I have lost the original comments but I
think it might be attributable to Giles Tran.
In any case I use it a lot and it works nicely for placing objects in
arbitrary orientations. I don't have a big brain so I can't comment on your
image issue, but maybe you will get lucky and the image will be aligned
along with the cylinder :-)
Would the author of this please stand up to take credit? Its wonderful!
//
// used to align an object to an arbitrary orientation
//
// a1 - the axis in the object before transformation
// a2 - the desired orientation after transformation
//
#macro Align( a1, a2 )
#local vX1 = vnormalize( a1 );
#local vX2 = vnormalize( a2 );
#local vY = vnormalize( vcross( vX1, vX2 ) );
#local vZ1 = vnormalize( vcross( vX1, vY ) );
#local vZ2 = vnormalize( vcross( vX2, vY ) );
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 >
#end
"Matt Moose" <mrr### [at] spherica demon co uk> wrote in message
news:3a90fab8.9496988@news.povray.org...
> (Using Povray v. 3.1g.watcom.win32)
>
> Dear brainy types,
>
> Problem: Got a unit cylinder lying on the x-axis, from x=-0.5 to 0.5,
> with a bitmap projected onto its side in the xz plane. Good so far,
> very happy with that. However I would then like to take the
> illustrated cylinder's start & end points and move them to 2 totally
> different unrelated coordinates p1 & p2, which can be a variable
> distance apart. The image must face the camera (towards -Z), whatever
> the final orientation of the object.
>
> It's required to keep the image locked to the side of the cylinder so
> it can point in the right direction.
>
> I can easily translate the object's start point to p1, but can't get
> my head around determining the amount of pre-rotation and pre-scaling
> required at the origin in order to move the endpoint to p2, _and_
> have the image still facing -Z !
>
> Have I missed an easier way?
>
> Thanks in advance,
>
> Matt.
Post a reply to this message
|
![](/i/fill.gif) |