POV-Ray : Newsgroups : povray.general : Vector Function required?! Can you help me find or write it? Server Time
8 Aug 2024 08:16:40 EDT (-0400)
  Vector Function required?! Can you help me find or write it? (Message 1 to 6 of 6)  
From: Matt Moose
Subject: Vector Function required?! Can you help me find or write it?
Date: 20 Feb 2001 10:38:32
Message: <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

From: Spock
Subject: Re: Vector Function required?! Can you help me find or write it?
Date: 20 Feb 2001 11:12:21
Message: <3a929765$1@news.povray.org>
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] sphericademoncouk> 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

From: GrimDude
Subject: Re: Vector Function required?! Can you help me find or write it?
Date: 20 Feb 2001 16:18:17
Message: <3a92df19@news.povray.org>
You could also use direct trigonometry on this, which Pov allows.

Grim
"Spock" <spo### [at] nospamcom> wrote in message
news:3a929765$1@news.povray.org...
> 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] sphericademoncouk> 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

From: Bill DeWitt
Subject: Re: Vector Function required?! Can you help me find or write it?
Date: 20 Feb 2001 16:37:15
Message: <3a92e38b$1@news.povray.org>
I have a macro that will transform an object so that it's two 'z' ends
will meet any arbitrary points. If you can use that let me know.


"Matt Moose" <mrr### [at] sphericademoncouk> 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

From: David Fontaine
Subject: Re: Vector Function required?! Can you help me find or write it?
Date: 20 Feb 2001 18:02:41
Message: <3A92F733.1C737A28@faricy.net>
I have such a macro for you: http://davidf.faricy.net/povre.html


reposition(Vector1,Vector2)
   reorients an object so it points along Vector2 instead of Vector1
   scales object according to vector length ratio
   NOTE: the reposition macros are specifically designed to keep the
object's axial rotation
      the same (ie, if you were to make a line perpendicular to the
initial vector that intersected
      the y axis, this line will still intersect the y axis after
applying the reposition macro). If you
      need a macro that will reposition your object like a ball and
socket joint, use John
      Vansickle's ReOrient macro from John Vansickle's Thoroughly Useful
Macros
      ( http://users.erols.com/vansickl/macs.htm ).

reposition2(Vector1,Vector2)
   reorients an object so it points along Vector2 instead of Vector1
   does not scale objects


--
David Fontaine  <dav### [at] faricynet>  ICQ 55354965
My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

From: Matt Moose
Subject: Re: Vector Function required?! Can you help me find or write it?
Date: 22 Feb 2001 19:53:10
Message: <3a95b49a.4071086@news.povray.org>
Thanks everybody, I'll give some of this advice a go.

Matt. (posting from BT account)


On Tue, 20 Feb 2001 15:40:13 GMT, mrr### [at] sphericademoncouk (Matt
Moose) wrote:

>(Using Povray v. 3.1g.watcom.win32)
>
>Dear brainy types,
>
[rest snipped]


Post a reply to this message

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