POV-Ray : Newsgroups : povray.advanced-users : Help me with matrix please... : Re: Help me with matrix please... Server Time
30 Jul 2024 10:18:18 EDT (-0400)
  Re: Help me with matrix please...  
From: David Wilkinson
Date: 26 Sep 1999 11:50:35
Message: <6UDuNx9paZMoVnaRo+h0Aa9sVOA2@4ax.com>
On Sun, 26 Sep 1999 09:38:24 -0400, "TonyB" <ben### [at] panamaphoenixnet> wrote:
>
>Given 2 points in 2D* or 3D space, A and B, how can I make an object rotate
>to line itself up to the line AB? My intention is to give an object a path
>to follow over an uneven surface, and using the trace() function on the
>front and back of the object, generate the points A and B to help my object
>avoid obstacles. A third trace() would be taken from the center of the
>object, C, and the point (A,B or C) that has the highest y determines how
>high the object is placed over the path.
>
>Right now I am using (and it doesn't work right, so that's why I'm here) the
>following macro:
>
>
>#macro apunta(A,B)
> #declare X=vnormalize(B-A);
> #declare Z=vnormalize(vcross(X,y));
> #declare Y=vcross(Z,X);
> matrix
> <
>  X.x,X.y,X.z,
>  Y.x,Y.y,Y.z,
>  Z.x,Z.y,Z.z,
>  A.x,A.y,A.z
> >
>#end
>
>
>Given:
>
>
>#declare A = <0,2,1>;
>#declare B = <0,1,-1>;
>
>sphere {A,1/2 pigment {rgb <1,1,0>}}
>sphere {B,1/2 pigment {rgb <0,1,1>}}
>
>box
>{
> <1,1,2>,-<1,1,2>
> pigment {red 1}
> aim(y,B)
> translate y*(Y+2)
>}
>
From your example Tony I am not really clear what you are trying to do, but I think
that
what you want is one of John Van Sickle's macros - Reorient. Its on his web site:-
http://users.erols.com/vansickl/macs.htm

The input to his macro is two vectors.  The first is the existing axis of orientation
and
the second is the vector of orientation you are wanting.  Calling the macro generates
two
matrix definitions which will re-orientate your object. You then have to translate it
to
where you want it.

Hope this helps.
David
------------
dav### [at] cwcomnet
http://www.hamiltonite.mcmail.com
------------


Post a reply to this message

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