POV-Ray : Newsgroups : povray.advanced-users : look_at for objects? Server Time
26 Nov 2024 13:45:21 EST (-0500)
  look_at for objects? (Message 1 to 10 of 14)  
Goto Latest 10 Messages Next 4 Messages >>>
From: Andrew Clinton
Subject: look_at for objects?
Date: 16 Mar 2000 14:33:23
Message: <38D160CC.B42C5D7B@ibm.net>
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: Alberto
Subject: Re: look_at for objects?
Date: 16 Mar 2000 16:01:08
Message: <38D14BFE.BCDF6EA5@ma.usb.ve>
Andrew Clinton wrote:

> ...and I wish to perform an x-rotation then a y-rotation ...

The instruction
rotate <xrot, yrot, 0>
will do the work.

See the povdoc section 4.3.1.3.
I hope this will help you
Alberto


Post a reply to this message

From: Andrew Clinton
Subject: Re: look_at for objects?
Date: 16 Mar 2000 16:54:04
Message: <38D181BD.BE20D01C@ibm.net>
No,no, thats not the problem.  I mean that I am given a *point* (like a
look_at point), not the rotation values.  Here is a camera:

camera {
    location <0,0,0>
    look_at <1,-2,3>
}

Pov-ray will automatically rotate the camera so that it is pointing at
<1,-2,3> while maintaining +y as the up direction (ie the horizon will
still be horizontal).  What I need to find is the x-rotation and
y-rotation that are needed to properly align an object rather than a
camera to point at the point (because look_at can't be used with
objects!).  It is very important that the object not change its z- tilt
for my purposes.

Your right, rotate <xrot,yrot,0> will work but I need the rotation
values first!

Thank you,

Andrew C


Alberto wrote:

> Andrew Clinton wrote:
>
> > ...and I wish to perform an x-rotation then a y-rotation ...
>
> The instruction
> rotate <xrot, yrot, 0>
> will do the work.
>
> See the povdoc section 4.3.1.3.
> I hope this will help you
> Alberto


Post a reply to this message

From: David Fontaine
Subject: Re: look_at for objects?
Date: 16 Mar 2000 17:12:05
Message: <38D15B46.4CEFD082@faricy.net>
Yes!
// 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;
   #end
   #if (0+p.x=0 & 0+p.z=0)
      #local RotY=0;
   #else
      #local RotY=atan2(p.x,p.z)*180/pi;
   #end
   rotate <RotX,RotY,0>
#end

or

//reorient from vector 1 to vector 2
#macro reposition2(vec1,vec2)
   #if (vlength(vec1)=0)
      #render "Warning: reposition2 initial vector length is zero.\n"
   #end
   #if (vec1.x=0 & vec1.z=0)
      #local RotY=0;
   #else
      #local RotY=atan2(vec1.x,vec1.z)*180/pi;
   #end
   #local RotX=asin((vec1.y)/vlength(vec1))*180/pi;
   rotate -RotY*y
   rotate RotX*x
   #if (vlength(vec2)=0)
      #render "Warning: reposition2 final vector length is zero.\n"
   #end
   #if (vec2.x=0 & vec2.z=0)
      #local RotY=0;
   #else
      #local RotY=atan2(vec2.x,vec2.z)*180/pi;
   #end
   #local RotX=asin((vec2.y)/vlength(vec2))*180/pi;
   rotate <-RotX,RotY,0>
#end

--
___     _______________________________________________
 | \     |_          <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: 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

Goto Latest 10 Messages Next 4 Messages >>>

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