POV-Ray : Newsgroups : povray.general : arrow, bullets, frisbies, flying pigs Server Time
11 Aug 2024 23:16:45 EDT (-0400)
  arrow, bullets, frisbies, flying pigs (Message 1 to 2 of 2)  
From: Tom Melly
Subject: arrow, bullets, frisbies, flying pigs
Date: 12 Apr 1999 08:01:02
Message: <3711d26e.0@news.povray.org>
Well, i spent the weekend with this and got nowhere useful.

If, you have an object and you want to move it in the direction that it's
pointing, how do you calculate the new position from the old position?

For example, assume that ObjArrow is an arrow that, with a rotation of 0,
points in the Y direction. To move the arrow, you just increase the Y
translation.

or
#declare n = 0;
#while n < 10
 object {ObjArrow translate <0, n, 0>}
  #declare n = n +1;
#end

However, I want to be able to do this for more complex rotations, and ensure
that my object move in the direction of its "surface normal", so to speak.

I assume that there are lots of cos and sin etc, and it's doing my head in
(although I can just about manage the equations for 2 dimensions).

Can anyone help and/or refer me to a good shrink and/or marriage guidence
counsellor?


Post a reply to this message

From: Gilles Tran
Subject: Re: arrow, bullets, frisbies, flying pigs
Date: 12 Apr 1999 08:58:05
Message: <3711E07A.7AF4C51D@inapg.inra.fr>
This macro (right from the MakeTree macro where it's used to align branch
segments) could do the trick. There may be other of this kind at
http://twysted.net and of course it is mandatory to mention John VanSickle's
"Thoroughly Useful Macros" at http://www.erols.com/vansickl/macs.htm

Gilles Tran
//=========================================
// macro mAlign
//-----------------------------------------
// returns a matrix operation that aligns an object or texture along P2-P1
// the object is translated to P1
// translate to P2-P1 if you want the object to be on P2
#macro mAlign(P1,P2)
#local yV1=vnormalize(P2-P1);
#local xV1=vnormalize(vcross(yV1,z));
#local zV1=vcross(xV1,yV1);
matrix <xV1.x,xV1.y,xV1.z,yV1.x,yV1.y,yV1.z,zV1.x,zV1.y,zV1.z,P1.x,P1.y,P1.z>

#end


Tom Melly wrote:

> Well, i spent the weekend with this and got nowhere useful.
>
> If, you have an object and you want to move it in the direction that it's
> pointing, how do you calculate the new position from the old position?
>
> For example, assume that ObjArrow is an arrow that, with a rotation of 0,
> points in the Y direction. To move the arrow, you just increase the Y
> translation.
>
> or
> #declare n = 0;
> #while n < 10
>  object {ObjArrow translate <0, n, 0>}
>   #declare n = n +1;
> #end
>
> However, I want to be able to do this for more complex rotations, and ensure
> that my object move in the direction of its "surface normal", so to speak.
>
> I assume that there are lots of cos and sin etc, and it's doing my head in
> (although I can just about manage the equations for 2 dimensions).
>
> Can anyone help and/or refer me to a good shrink and/or marriage guidence
> counsellor?


Post a reply to this message

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