POV-Ray : Newsgroups : povray.advanced-users : look_at for objects? Server Time
30 Jul 2024 08:21:03 EDT (-0400)
  look_at for objects? (Message 5 to 14 of 14)  
<<< Previous 4 Messages Goto Initial 10 Messages
From: David Fontaine
Subject: Re: look_at for objects?
Date: 16 Mar 2000 17:14:16
Message: <38D15BC9.6E466D29@faricy.net>
David Fontaine wrote:

> Yes!

I'm so enthusiastic cause nobody beat me to it with one of VanSickle's
macros... ;-)

--
___     _______________________________________________
 | \     |_          <dav### [at] faricynet> <ICQ 55354965>
 |_/avid |ontaine        http://www.faricy.net/~davidf/

"The only difference between me and a madman is that I'm not mad." -Dali


Post a reply to this message

From: Andrew Clinton
Subject: Re: look_at for objects?
Date: 16 Mar 2000 18:15:36
Message: <38D194D6.C2DE1E1B@ibm.net>
Thank you :)

This is how I'm going to make the Megapov motion blur work - move the
objects backwards rather than move the camera forwards!

Andrew C


David Fontaine wrote:

> David Fontaine wrote:
>
> > Yes!
>
> I'm so enthusiastic cause nobody beat me to it with one of VanSickle's
> macros... ;-)
>
> --
> ___     _______________________________________________
>  | \     |_          <dav### [at] faricynet> <ICQ 55354965>
>  |_/avid |ontaine        http://www.faricy.net/~davidf/
>
> "The only difference between me and a madman is that I'm not mad." -Dali


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: look_at for objects?
Date: 16 Mar 2000 18:19:22
Message: <38D16ACC.469F9197@hotmail.com>
David Fontaine wrote:

> Yes!

8< Snip

> // Reorient from <0,0,1> to p
> #macro PointTo(p)
>    #if (0+p.x=0 & 0+p.y=0 & 0+p.z=0)
>       #local RotX=0;
>    #else
>       #local RotX=-atan2(p.y,sqrt(pow(p.x,2)+pow(p.z,2)))*180/pi;

8< Snip

Just a little suggestion for the last of these lines:

#local RotX = degrees(-atan2(p.y, vlength(p*(x+z)));

Regards

Tor Olav

--
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html


Post a reply to this message

From: Alberto
Subject: Re: look_at for objects?
Date: 16 Mar 2000 18:36:02
Message: <38D1704D.86519C22@ma.usb.ve>
Ahhh...

You may try this

#macro PointTo(p)
  #local Rd = vlength(p);
  #if(Rd = 0)
    #local   Rotx = 0;
    #local   Roty = 0;
  #else
    #local   Rotx = 180*asin(p.y/Rd)/pi;
    #if(p.z = 0)
      #local Roty = 0;
    #else
      #local Roty = 180*atan2(p.x, p.z)/pi;
    #end
  #end
  rotate <Rotx, Roty, 0>
#end

Alberto


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: look_at for objects?
Date: 16 Mar 2000 19:05:45
Message: <38D175AC.93FF07A2@hotmail.com>
Alberto wrote:

> Ahhh...
>
> You may try this
>
> #macro PointTo(p)
>   #local Rd = vlength(p);
>   #if(Rd = 0)
>     #local   Rotx = 0;
>     #local   Roty = 0;
>   #else
>     #local   Rotx = 180*asin(p.y/Rd)/pi;
>     #if(p.z = 0)
>       #local Roty = 0;
>     #else
>       #local Roty = 180*atan2(p.x, p.z)/pi;
>     #end
>   #end
>   rotate <Rotx, Roty, 0>
> #end
>
> Alberto

If that works then maybe this also works:

#macro PointTo(p)
  #local RotVector = <0, 0, 0>;
  #local Rd = vlength(p);
  #if(Rd != 0)
    #local RotVector = x*degrees(asin(p.y/Rd));
    #if(p.z != 0)
      #local RotVector = RotVector + y*degrees(atan2(p.x, p.z));
    #end
  #end
  rotate RotVector
#end

But I haven't tested it...

Tor Olav


Post a reply to this message

From: John VanSickle
Subject: Re: look_at for objects?
Date: 17 Mar 2000 07:30:46
Message: <38D22658.60BC678F@erols.com>
Andrew Clinton wrote:
> 
> Hello,
> 
> Is there any macro available that will perform on an object the same
> function as the look_at command does in a camera?
> 
> In other words, I have an object at <0,0,0> and oriented in the +z
> direction, and I wish to perform an x-rotation then a y-rotation so that
> the object is now pointing at a given point (as in the look_at point for
> the Camera).  I've been using John VanSickle's Reorient macro, but in
> some cases the object receives an undesireable z-rotation so that it
> becomes tilted wrong.

My matrix page at

  http://users.erols.com/vansickl/matrix.htm

has some sample code that may be useful.

Regards,
John


Post a reply to this message

From: Josh English
Subject: Re: look_at for objects?
Date: 17 Mar 2000 15:01:00
Message: <38D28FE6.11C7C0FF@spiritone.com>
#macro Orient_Z(v1,v2)
  #local nx = vnormalize(v2-v1);
  #local nz = vnormalize(vcross(nx,y)); // replace "y" with the things local
"up"
  #local ny = vcross(nz,nx)
  matrix <nx.x, nx.y, nx.z,
              ny.x, ny.y, ny.z,
              nz.x, nz.y, nz.z,
              v1.x, v1.y, v1.z>
#end

This takes an object at the origin and places it at point v1 and points it
towards v2.
It is based on John Vansickles Reorient macro. I havne't figured out how to
do autobanking

Josh

Andrew Clinton wrote:

> Hello,
>
> Is there any macro available that will perform on an object the same
> function as the look_at command does in a camera?
>
> In other words, I have an object at <0,0,0> and oriented in the +z
> direction, and I wish to perform an x-rotation then a y-rotation so that
> the object is now pointing at a given point (as in the look_at point for
> the Camera).  I've been using John VanSickle's Reorient macro, but in
> some cases the object receives an undesireable z-rotation so that it
> becomes tilted wrong.
>
> I've been banging my head for a while about this, any help would be
> appreciated!
>
> Andrew C

--
Josh English
eng### [at] spiritonecom
"May your hopes, dreams, and plans not be destroyed by a few zeros."


Post a reply to this message

From: Andrew Clinton
Subject: Re: look_at for objects?
Date: 17 Mar 2000 17:39:37
Message: <38D2DD57.58E73968@ibm.net>
Wow, several stones can kill this one bird... I count 5 macros that do
basically the same thing!  Thanks for all your help, I got it solved.

btw, if anyone's interested, I'm working on a system that will create rock
walls from height_fields that follow a spline, so that nearly seamless caves
can be made...I'm getting close to finishing it now (but it is nowhere near
perfect)

Andrew C


Andrew Clinton wrote:

> Hello,
>
> Is there any macro available that will perform on an object the same
> function as the look_at command does in a camera?
>
> In other words, I have an object at <0,0,0> and oriented in the +z
> direction, and I wish to perform an x-rotation then a y-rotation so that
> the object is now pointing at a given point (as in the look_at point for
> the Camera).  I've been using John VanSickle's Reorient macro, but in
> some cases the object receives an undesireable z-rotation so that it
> becomes tilted wrong.
>
> I've been banging my head for a while about this, any help would be
> appreciated!
>
> Andrew C


Post a reply to this message

From: Alan Kong
Subject: Re: look_at for objects?
Date: 17 Mar 2000 20:38:53
Message: <skm5dsg0ni779v6q8n1onhb4m2dc27o5uj@4ax.com>
On Fri, 17 Mar 2000 17:35:19 -0800 Andrew Clinton <cli### [at] ibmnet>
wrote:

>btw, if anyone's interested, I'm working on a system that will create rock
>walls from height_fields that follow a spline, so that nearly seamless caves
>can be made...I'm getting close to finishing it now (but it is nowhere near
>perfect)

  When you're ready, can you post demo images in p.binaries.images? TIA.

-- 
Alan - ako### [at] povrayorg - a k o n g <at> p o v r a y <dot> o r g
http://www.povray.org - Home of the Persistence of Vision Ray Tracer]


Post a reply to this message

From: mr art
Subject: Re: look_at for objects?
Date: 19 Mar 2000 13:57:12
Message: <38D52320.C4BF759D@gci.net>
I haven't seen this one listed:
#macro
v_lookat(P1,P2)<0,-degrees(asin(vnormalize(P2-P1).z)),degrees(asin(vnormalize(P2-P1).y))>#end


Andrew Clinton wrote:
> 
> Wow, several stones can kill this one bird... I count 5 macros that do
> basically the same thing!  Thanks for all your help, I got it solved.
> 
> btw, if anyone's interested, I'm working on a system that will create rock
> walls from height_fields that follow a spline, so that nearly seamless caves
> can be made...I'm getting close to finishing it now (but it is nowhere near
> perfect)
> 
> Andrew C
> 
> Andrew Clinton wrote:
> 
> > Hello,
> >
> > Is there any macro available that will perform on an object the same
> > function as the look_at command does in a camera?
> >
> > In other words, I have an object at <0,0,0> and oriented in the +z
> > direction, and I wish to perform an x-rotation then a y-rotation so that
> > the object is now pointing at a given point (as in the look_at point for
> > the Camera).  I've been using John VanSickle's Reorient macro, but in
> > some cases the object receives an undesireable z-rotation so that it
> > becomes tilted wrong.
> >
> > I've been banging my head for a while about this, any help would be
> > appreciated!
> >
> > Andrew C

-- 
Mr. Art

"Often the appearance of reality is more important 
than the reality of the appearance."
Bill DeWitt 2000


Post a reply to this message

<<< Previous 4 Messages Goto Initial 10 Messages

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