POV-Ray : Newsgroups : povray.general : stare_at? Server Time
15 Nov 2024 13:22:11 EST (-0500)
  stare_at? (Message 1 to 7 of 7)  
From: Phil Clute
Subject: stare_at?
Date: 20 Jan 1999 01:06:59
Message: <36A573C0.11FF06E4@tiac.net>
First of all ignore my last message! Entitled ty. It was just a dumb
mistake!
One of many I assure you. My appologies for wasting news-group space.
And now for the real stuff...
As a learning project I've started making an Eye.inc, it's basically an
eye object
where you can change the iris texture and pupil size at this point. But
I would
also like to be able to point the eye in a direction as though it's
looking at another
object. I know, I know rotate is the obvious answer, but it would be
cool if I could
use a vector like look_at in camera{}so that I could just specify a
point. This
would be handy when animating and a bit simpler to follow, or at least
that's the
idea.
    Am I making this more complicated than it needs to be?
Speaking of complicated...I have a crazy idea of detecting light-sources
so that
the pupil can adjust appropriately, automatically... I did say it was
crazy. Any
suggestions here would be helpful too...but don't strain yourself, this
is just for
my learning purposes anyhow.
            thanks in advance


Post a reply to this message

From: Karsten Senz
Subject: Re: stare_at?
Date: 20 Jan 1999 05:24:09
Message: <36A5AEE2.C729BC05@wi-bw.tfh-wildau.de>
Phil Clute wrote:
> 
> First of all ignore my last message! Entitled ty. It was just a dumb
> mistake!
> One of many I assure you. My appologies for wasting news-group space.
> And now for the real stuff...
> As a learning project I've started making an Eye.inc, it's basically an
> eye object
> where you can change the iris texture and pupil size at this point. But
> I would
> also like to be able to point the eye in a direction as though it's
> looking at another
> object. I know, I know rotate is the obvious answer, but it would be
> cool if I could
> use a vector like look_at in camera{}so that I could just specify a
> point. This
> would be handy when animating and a bit simpler to follow, or at least
> that's the
> idea.

You could convert that stare_at point into rotations ?

I suppose you use y for the up direction but that doesn't matter at all.
So you have the position of "your" eye: <eye_x,eye_y, eye_z>
(by the way you should create "your" eye at the origin and translate it
later to that position)

and you have that stare_at point <stare_at_x,stare_at_y,stare_at_z>

what we need first is the length from stare_at_x to eye_x and from
stare_at_z to eye_z :

length_x = stare_at_x - eye_x;
length_z = stare_at_z - eye_z;

now we can easily get the rotation of y by :

rotation_y = atan2(length_z,length_x);


now the eye should look in the right direction but not at the point. We
have to make another adjustment.
we need the heigth of the stare_at point

length_y = stare_at_y - eye_y;

and do another rotation :

rotation_z = atan2(length_y,length_x);


in the eye definition you may have :

object eye
{
  union
  {
  ...
  // the parts of "your" eye created at origin
  }
  rotate<0.0,rotation_y,rotation_z> // first rotate
  translate<eye_x,eye_y,eye_z>
}

If the steps are not clear write me and I will make a sketch because I'm
no native English and often miss the right terms.



I hope that helps and if it does not work you expected, I hope you even
got an idea how to get it work


Post a reply to this message

From: Johannes Hubert
Subject: Re: stare_at?
Date: 20 Jan 1999 10:00:50
Message: <36a5efa2.0@news.povray.org>
Phil Clute wrote in message <36A573C0.11FF06E4@tiac.net>...
>First of all ignore my last message! Entitled ty. It was just a dumb
>mistake!

You know that you can cancel postings made by yourself (and thus get rid of
such mistakes...)?
Most modern newsreaders offer that option...

Johannes.


Post a reply to this message

From: Ilmari Karonen
Subject: Re: stare_at?
Date: 20 Jan 1999 12:09:50
Message: <36a60dde.0@news.povray.org>
Karsten Senz wrote in message <36A5AEE2.C729BC05@wi-bw.tfh-wildau.de>...
>Phil Clute wrote:>> object. I know, I know rotate is the obvious answer,
but it would be>> cool if I could>> use a vector like look_at in camera{}so
that I could just specify a>So you have the position of "your" eye:
<eye_x,eye_y, eye_z>>and you have that stare_at point
<stare_at_x,stare_at_y,stare_at_z>>length_x = stare_at_x - eye_x;>length_z =
stare_at_z - eye_z;>rotation_y = atan2(length_z,length_x);>length_y =
stare_at_y - eye_y;>rotation_z = atan2(length_y,length_x);
Shouldn't that be something like:

#declare Eye_D = Eye_Stare_At - Eye_Location; // vector difference
object { Eye // at origin, looking along +z axis
  rotate <-degrees(atan2(Eye_D.y, vlength(Eye_D*<1,0,1>)), // height (note
negation)
          degrees(atan2(Eye_D.x, Eye_D.z))+(Eye_D.z<0 ? 180:0), // direction
          0> // no rotation around z-axis anymore
  translate Eye_Location
}

I'm not quite sure about that y-component - it might look in the wrong
direction
if Eye_D.z is exactly 0. Anyway, the point is to do the rotation around the
y-axis (or whatever is your sky vector) last.

--
Ilmari Karonen (ilt### [at] scifi)
http://www.sci.fi/~iltzu/


Post a reply to this message

From: Bob Hughes
Subject: Re: stare_at?
Date: 21 Jan 1999 02:47:29
Message: <36A6DB8D.FFB19B05@aol.com>
I've long since thought of your second "idea".
I see no way of doing it yet. Unless of course by specifying a grid of
points manually for a scene (a still scene at that for ease) and
inputing these numbers somehow as the look_at changes.
My thoughts were not exactly about a render of an eye, more so a camera
iris for animations with varying light levels and thus adjustment to the
illumination.
Heck, how many people have thought about this? Plenty I bet.
Funny thing is, in Basic programming you could choose a point and relay
the color number info. An expanded version of this is what would be
needed.
Point is, you would have to do this in a difficult manner if at all via
include and external files only way I see it. The fact that you'd want
an area, not point, equated is all the worse.
Probably the only feasible method will come from programming it in as a
feature part of POV-Ray itself, which I could see happening if it were
the point only scenario. Not so easy if the necessary "area" scenario,
and I'm not talking about point lights being accounted for in a certain
ever-narrowed direction but the brightness/dimness of textured objects
as well.


Phil Clute wrote:
> 
> Speaking of complicated...I have a crazy idea of detecting light-sources
> so that
> the pupil can adjust appropriately, automatically... I did say it was
> crazy. Any
> suggestions here would be helpful too...but don't strain yourself, this
> is just for
> my learning purposes anyhow.
>             thanks in advance

-- 
 omniVERSE: beyond the universe
  http://members.aol.com/inversez/POVring.htm
=Bob


Post a reply to this message

From: Phil Clute
Subject: Re: stare_at?
Date: 22 Jan 1999 01:55:21
Message: <36A821E9.52F5B42E@tiac.net>
>Ilmari Karonen contributed:
>#declare Eye_D = Eye_Stare_At - Eye_Location; // vector difference
>object { Eye // at origin, looking along +z axis
>  rotate <-degrees(atan2(Eye_D.y, vlength(Eye_D*<1,0,1>)), // height >(note
>negation)
>          degrees(atan2(Eye_D.x, Eye_D.z))+(Eye_D.z<0 ? 180:0), // >direction
>          0> // no rotation around z-axis anymore
>  translate Eye_Location
>}
>
I removed the negative sign from before degrees in the x component,
and got rid of the conditional statement from the y component leaving
just +(180). Because it was turning the Eye 180 degrees in the wrong
direction whenever the eye was looking in the +z direction(at origin
my eye is looking in the -z direction).

>I'm not quite sure about that y-component - it might look in the wrong
>direction
>if Eye_D.z is exactly 0. Anyway, the point is to do the rotation around >the
>y-axis (or whatever is your sky vector) last.

My sky vector is y.

My only problem now is that if my stare_at x and z vectors are both 0.0
POV barks at me about a "domain error in atan2".
Other than that, it works very nicely. 
Thank you
-- 
...coffee?...yes please! extra sugar,extra cream...Thank you.


Post a reply to this message

From: Karsten Senz
Subject: Re: stare_at?
Date: 22 Jan 1999 05:14:50
Message: <36A84FB6.DB5E8E37@wi-bw.tfh-wildau.de>
Phil Clute wrote:

> My sky vector is y.
> 
> My only problem now is that if my stare_at x and z vectors are both 0.0
> POV barks at me about a "domain error in atan2".
> Other than that, it works very nicely.
> Thank you

Having the x and z vectors 0 mean you are looking straight up or down.
You just have to find out by comparing the eye_y with the stare_at_y.

indicator = (eye_y - stare_at_y)/abs(eye_y-stare_at_y);

this way you will get a -1 for looking down and a +1 for looking
straight up. Now rotate around x or z.

rotation x*indicator*180



Again there is a big danger having eye_y == stare_at_y. So you should
check before rotating at all, that the eye's position and the stare_at
point aren't equal.


Post a reply to this message

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