POV-Ray : Newsgroups : povray.advanced-users : Calculating an angle Server Time
1 Nov 2024 03:15:26 EDT (-0400)
  Calculating an angle (Message 1 to 9 of 9)  
From: Tim Nikias v2 0
Subject: Calculating an angle
Date: 22 Sep 2003 18:15:54
Message: <3f6f749a$1@news.povray.org>
What I'm trying to do for my Worm is the following:
I know the position of the neck, so to speak the
point where the head will be attached. I know the
distance between the neck and the eyes.
And finally, I know a position where the Worm
should look at.

What I'm trying to do is to calculate an angle for
neck, so that the eyes, when looking straight-forward,
will look at the focal-point.
I somehow can't manage to get my head around
the problem so that I actually get the correct
angle. I seem to end up with an angle which would
point eyes sitting the neck to the object, but eyes
sitting on the head will actually look too far below
or above the point.

And yes, I do know of the difference between
radians and degrees in POV-Rays functions,
so that's not the reason for looking at wrong
positions. Any clues? Preferrably with an explanation
of the approach?

Thanks in advance,
Tim

-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: no_lights (@) digitaltwilight.de



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.520 / Virus Database: 318 - Release Date: 19.09.2003


Post a reply to this message

From: Warp
Subject: Re: Calculating an angle
Date: 22 Sep 2003 19:32:35
Message: <3f6f8693@news.povray.org>
I don't know if it will be of any help in this case, but have you
browsed the sections 7.19 (transforms.inc) and 7.10 (math.inc) of
the POV-Ray documentation? There might be functions/macros there
which might help you.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Ricky Reusser
Subject: Re: Calculating an angle
Date: 23 Sep 2003 00:56:03
Message: <3f6fd262@news.povray.org>
Tim Nikias v2.0 wrote:

> What I'm trying to do is to calculate an angle for
> neck, so that the eyes, when looking straight-forward,
> will look at the focal-point.
> I somehow can't manage to get my head around
> the problem so that I actually get the correct
> angle. I seem to end up with an angle which would
> point eyes sitting the neck to the object, but eyes
> sitting on the head will actually look too far below
> or above the point.

Are you using degrees instead of radians in the functions?  ;-)  Sorry. 
Maybe I'm misunderstanding, but it sounds like you're using trig to figure
out the position of things.  That's the hard way.  All you need is
something like a macro that puts three orientation vectors and a position
vector into a matrix transformation.  I haven't really worked on this type
of stuff for a while, but I imagine that's in pov's function includes by
now.  If you're already doing this, are you orienting the eyes last?  I
worked on a similar problem with Luxo Jr. a while ago and had a pretty hard
time getting the whole head to orient to the focus without twisting at a
funny angle in special cases, but I never used any trig.

Something like

#macro make_transformation(xv,yv,zv,pv)
        transform{
                matrix
                <        
                        xv.x, xv.y, xv.z,
                        yv.x, yv.y, yv.z,
                        zv.x, zv.y, zv.z,
                        pv.x, pv.y, pv.z
                >
        }
#end

Forgive me if this is nothing new and just let me know if I'm
misunderstanding.

 - Ricky


Post a reply to this message

From: Mark Weyer
Subject: Re: Calculating an angle
Date: 23 Sep 2003 05:01:56
Message: <3F700D09.5080102@informatik.uni-freiburg.de>
> What I'm trying to do for my Worm is the following:
> I know the position of the neck, so to speak the
> point where the head will be attached. I know the
> distance between the neck and the eyes.
> And finally, I know a position where the Worm
> should look at.

What you need is not the point where the eyes are, but the point
straight up from the neck that is the same height as the eyes
(if the head itself is upright). Lets call that the brain point,
or in the case of a worm the ganglion point.

> What I'm trying to do is to calculate an angle for
> neck, so that the eyes, when looking straight-forward,
> will look at the focal-point.
> I somehow can't manage to get my head around
> the problem so that I actually get the correct
> angle. I seem to end up with an angle which would
> point eyes sitting the neck to the object, but eyes
> sitting on the head will actually look too far below
> or above the point.

Fine. First calculate the angle for eyes sitting on the neck.
Now consider the real solution. You have three points: neck,
ganglion and object. That the ganglion looks at the object
(which is equivalent to the eyes looking at the object) means
that these points form a triangle rectangluar at the ganglion.
The angle which you need to correct the above angle is the
angle at the object. Now for the correct ganglion point (which
we still do not know), the sine of the correction angle is
   |ganglion-neck| / |object-neck|,
which we can calculate. So you can determine the correction
angle as well.


-- 
merge{#local i=-11;#while(i<11)#local
i=i+.1;sphere{<i*(i*i*(.05-i*i*(4e-7*i*i+3e-4))-3)10*sin(i)30>.5}#end
pigment{rgbt 1}interior{media{emission x}}hollow}//  Mark Weyer


Post a reply to this message

From: Mike Andrews
Subject: Re: Calculating an angle
Date: 23 Sep 2003 06:50:01
Message: <web.3f7024e9aab3290d2e746c9a0@news.povray.org>
Hi Tim,

You could try the 'Three Point Transform' macro in

http://news.povray.org/3e54d2d5%241%40news.povray.org

or the slightly modified one by Tor Olav Kristensen further down in the
thread.

Mike Andrews.

Tim Nikias v2.0 wrote:
>What I'm trying to do for my Worm is the following:
>I know the position of the neck, so to speak the
>point where the head will be attached. I know the
>distance between the neck and the eyes.
>And finally, I know a position where the Worm
>should look at.
>
>What I'm trying to do is to calculate an angle for
>neck, so that the eyes, when looking straight-forward,
>will look at the focal-point.
>I somehow can't manage to get my head around
>the problem so that I actually get the correct
>angle. I seem to end up with an angle which would
>point eyes sitting the neck to the object, but eyes
>sitting on the head will actually look too far below
>or above the point.
>
>And yes, I do know of the difference between
>radians and degrees in POV-Rays functions,
>so that's not the reason for looking at wrong
>positions. Any clues? Preferrably with an explanation
>of the approach?
>
>Thanks in advance,
>Tim
>
>Tim Nikias v2.0
>Homepage: http://www.digitaltwilight.de/no_lights
>Email: no_lights (@) digitaltwilight.de
>
>
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www://www.grisoft.com.
>Version: 6.0.520 / Virus Database: 318 - Release Date: 19.09.2003
>


Post a reply to this message

From: Tim Nikias v2 0
Subject: Solution found!
Date: 23 Sep 2003 08:02:37
Message: <3f70365d$1@news.povray.org>
Thanks all! Mark Weyer actually used
the same approach as I did, but pointed
me to the specific place where I was
making a mistake: I somehow had the
impression that I could calculate one
angle, and then do some math (like -90
or +90) and get the correct angle,
but I always forgot about the angle inside
the triangle...

I know that this might be a complicated
approach (using matrix-transformations
or other techniques sometimes seem to
get results faster and more precise), but
there are always dozens of ways to achieve
something when using math, and I always
like the version which I can easily visualize
(and thus, easily modify).

Regards,
Tim

-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: no_lights (@) digitaltwilight.de



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.520 / Virus Database: 318 - Release Date: 18.09.2003


Post a reply to this message

From: Tim Nikias v2 0
Subject: Re: Solution found!
Date: 23 Sep 2003 18:55:03
Message: <3f70cf47@news.povray.org>
Damn. I've been so stupid all along.
My original idea should have worked
once Mark pointed my brain to where
it was lagging behind what my eyes
could easily see from a "technical"
drawing (scribbling is a better description).

Still, everything looked skewed and I
was wondering why there always were
some odd angles. And what was the
reason?
The camera wasn't look straight onto
the test-setup. Doh!

Ah well, still, thanks for the replies.

-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: no_lights (@) digitaltwilight.de


> Thanks all! Mark Weyer actually used
> the same approach as I did, but pointed
> me to the specific place where I was
> making a mistake: I somehow had the
> impression that I could calculate one
> angle, and then do some math (like -90
> or +90) and get the correct angle,
> but I always forgot about the angle inside
> the triangle...
>
> I know that this might be a complicated
> approach (using matrix-transformations
> or other techniques sometimes seem to
> get results faster and more precise), but
> there are always dozens of ways to achieve
> something when using math, and I always
> like the version which I can easily visualize
> (and thus, easily modify).
>
> Regards,
> Tim
>
> -- 
> Tim Nikias v2.0
> Homepage: http://www.digitaltwilight.de/no_lights
> Email: no_lights (@) digitaltwilight.de
>
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.520 / Virus Database: 318 - Release Date: 18.09.2003
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.520 / Virus Database: 318 - Release Date: 19.09.2003


Post a reply to this message

From: Tim Nikias v2 0
Subject: Downloadable...
Date: 23 Sep 2003 20:06:38
Message: <3f70e00e@news.povray.org>
Now, if anyone is interested, the macro is
available along with my other Look_At
Macro in my Downloads-Section.

Regards,
Tim

-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: no_lights (@) digitaltwilight.de



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.520 / Virus Database: 318 - Release Date: 19.09.2003


Post a reply to this message

From: Tim Nikias v2 0
Subject: Demo available
Date: 24 Sep 2003 07:09:48
Message: <3f717b7c$1@news.povray.org>
Uploaded a demonstration of the macro
in effect with my Worm's head to my
Section dedicated to my Longterm-
Short-Film-Project:

http://www.digitaltwilight.de/no_lights/wip/worm/look_at.mpg

The ZIP was also updated to take care of a
"Divide by Zero" Warning in the macro.

http://www.digitaltwilight.de/no_lights/download.html

Regards,
Tim


-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: no_lights (@) digitaltwilight.de



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.520 / Virus Database: 318 - Release Date: 18.09.2003


Post a reply to this message

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