POV-Ray : Newsgroups : povray.general : Positioning a camera Server Time
29 Nov 2024 21:41:36 EST (-0500)
  Positioning a camera (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: Cesar
Subject: Positioning a camera
Date: 16 Apr 2005 17:40:00
Message: <web.426185608db3e684b2caa48d0@news.povray.org>
Hi! I hope I'm posting in the right place...

I'm rendering a scene and the position of the camera is calculated by a C++
program, and I'm having some trouble.

I used to set location and look-at, but now I need different movements, so I
decided to calculate location, direction, up and right. Then I started
having problems. I allways get the error that says the vectors are not
perpendicular. But I apply the same transform to the up right and direction
vectors, one after the other, how can they not ne perpendicular? Could
there be a precision problem (and the inner product be sligthly different
then zero)?

How could I solve this problem? Maybe I could transform the camera inside
povray, with "translate" and "rotate" but I'll need the up and right
vectors later in the C++ program, so I wanted to have the same values used
in povray.

Any suggestions?

Thanks!

Cesar


Post a reply to this message

From: Chris B
Subject: Re: Positioning a camera
Date: 16 Apr 2005 19:02:56
Message: <426199a0$1@news.povray.org>
"Cesar" <ces### [at] terracombr> wrote in message
news:web.426185608db3e684b2caa48d0@news.povray.org...
> Hi! I hope I'm posting in the right place...
>
> I'm rendering a scene and the position of the camera is calculated by a
C++
> program, and I'm having some trouble.
>
> I used to set location and look-at, but now I need different movements, so
I
> decided to calculate location, direction, up and right. Then I started
> having problems. I allways get the error that says the vectors are not
> perpendicular. But I apply the same transform to the up right and
direction
> vectors, one after the other, how can they not ne perpendicular? Could
> there be a precision problem (and the inner product be sligthly different
> then zero)?
>
> How could I solve this problem? Maybe I could transform the camera inside
> povray, with "translate" and "rotate" but I'll need the up and right
> vectors later in the C++ program, so I wanted to have the same values used
> in povray.
>
> Any suggestions?
>
> Thanks!
>
> Cesar
>
>

In POVRay you could use VAngleD(V1,V2)with the up and right vectors that
your C++ program calculated to compute the angle between the vectors and use
#debug to output the result to the message window (converted to a string
with vstr()). If it is just a rounding problem you might want to use
VPerp_Adjust(V1, Axis) to adjust one of the vectors so they're
perpendicular. If it's not a rounding problem, fix the bug in your app. :-)

Chris B.


Post a reply to this message

From: Cesar
Subject: Re: Positioning a camera
Date: 17 Apr 2005 07:45:01
Message: <web.42624bdf1c98b29b6ef2a7230@news.povray.org>
> In POVRay you could use VAngleD(V1,V2)with the up and right vectors that
> your C++ program calculated to compute the angle between the vectors and use
> #debug to output the result to the message window (converted to a string
> with vstr()). If it is just a rounding problem you might want to use
> VPerp_Adjust(V1, Axis) to adjust one of the vectors so they're
> perpendicular. If it's not a rounding problem, fix the bug in your app. :-)
>
> Chris B.

I honestly don't think it's a bug in my app. The vectors are, for example:

direction <0,  1, 0>
up <0.198669, 0, 0.980067>
right <1.30349, 0, -0.26423>

and povray complains about perpendicularity.

direction is obvliously perpendicular to the other two, so the question is
if up and right are perpendicular. I calculated the dot product betweem
them and the result is

1.034100000000106e-07

So that tells me they are perpendicular. But the error is so small! povray
has a problem with it? I guess I could use doubles instead of floats in my
app... could that work?

While I try to figure this out, I guess I'll use those functions you
suggested as they will probably make it work. Thanks.


Post a reply to this message

From: Christoph Hormann
Subject: Re: Positioning a camera
Date: 17 Apr 2005 08:05:02
Message: <d3tj4b$bej$1@chho.imagico.de>
Cesar wrote:
> 
> I honestly don't think it's a bug in my app. The vectors are, for example:
> 
> direction <0,  1, 0>
> up <0.198669, 0, 0.980067>
> right <1.30349, 0, -0.26423>
> 
> and povray complains about perpendicularity.

And does so rightly,

0.198669*1.30349 + 0.980067*(-0.26423) = 4.86e-8 != 0.0

Specifying the up and right vector the way you did it usually does not 
make sense.  You usually orient the camera with look_at or rotations and 
leave up and right as default (except aspect ratio).  See the docs, 
"3.3.1.1.5 Up and Right Vectors" for more explanation.

And no, using doubles in your program won't help since you transfer the 
numbers in decimal ascii.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 27 Feb. 2005 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Cesar
Subject: Re: Positioning a camera
Date: 17 Apr 2005 09:40:00
Message: <web.4262667f1c98b29b6ef2a7230@news.povray.org>
> And does so rightly,
>
> 0.198669*1.30349 + 0.980067*(-0.26423) = 4.86e-8 != 0.0
>
> Specifying the up and right vector the way you did it usually does not
> make sense.  You usually orient the camera with look_at or rotations and
> leave up and right as default (except aspect ratio).  See the docs,
> "3.3.1.1.5 Up and Right Vectors" for more explanation.
>
> And no, using doubles in your program won't help since you transfer the
> numbers in decimal ascii.
>
> Christoph
>
> --
> POV-Ray tutorials, include files, Sim-POV,
> HCR-Edit and more: http://www.tu-bs.de/~y0013390/
> Last updated 27 Feb. 2005 _____.//^>_*_<^/.______

Ok... Could I use look-at and use my recently calculated up-vector as sky?
Would that work? Or I have to use "angle" to make it right? Problems aside,
this subject brings me to another question: is there a way to make povray
accept the non-perpendicular vectors and generate a distorted image? I
could be interested in that...


Post a reply to this message

From: Alain
Subject: Re: Positioning a camera
Date: 17 Apr 2005 11:06:53
Message: <42627b8d@news.povray.org>
Cesar nous apporta ses lumieres en ce 2005-04-17 09:37:
>>And does so rightly,
>>
>>0.198669*1.30349 + 0.980067*(-0.26423) = 4.86e-8 != 0.0
>>
>>Specifying the up and right vector the way you did it usually does not
>>make sense.  You usually orient the camera with look_at or rotations and
>>leave up and right as default (except aspect ratio).  See the docs,
>>"3.3.1.1.5 Up and Right Vectors" for more explanation.
>>
>>And no, using doubles in your program won't help since you transfer the
>>numbers in decimal ascii.
>>
>>Christoph
>>
>>--
>>POV-Ray tutorials, include files, Sim-POV,
>>HCR-Edit and more: http://www.tu-bs.de/~y0013390/
>>Last updated 27 Feb. 2005 _____.//^>_*_<^/.______
> 
> 
> Ok... Could I use look-at and use my recently calculated up-vector as sky?
> Would that work? Or I have to use "angle" to make it right? Problems aside,
> this subject brings me to another question: is there a way to make povray
> accept the non-perpendicular vectors and generate a distorted image? I
> could be interested in that...
> 
> 
When POV Ray complains about non perpendicular, it's just a warning. It will still
render the scene. 
Yes, it can lead to skewed or distorted image. It's similar to those cameras where you
can shift and 
rotate the objective relative to the film plane. (at least in my view)

Alain


Post a reply to this message

From: Rune
Subject: Re: Positioning a camera
Date: 18 Apr 2005 05:08:25
Message: <42637909$1@news.povray.org>
Cesar wrote:
> Ok... Could I use look-at and use my recently calculated up-vector as
> sky? Would that work?

That should work, yes.

(with look_at = location + [your calculated direction])

I don't agree with Christoph though that your original approach doesn't make 
sense. You just need to really make sure the vectors are perpendicular.

Untested code:

#include "math.inc"
#declare cam_direction = <0,  1, 0>;
#declare cam_up = <0.198669, 0, 0.980067>;
#declare cam_right = <1.30349, 0, -0.26423>;

camera {
  direction cam_direction
  up VPerp_Adjust(cam_up,cam_direction)*vlength(cam_up)
  right vcross(cam_up,cam_direction)*vlength(cam_right)
}

> Problems aside, this subject brings me to another question: is there
> a way to make povray accept the non-perpendicular vectors and
> generate a distorted image? I could be interested in that...

Yes, if you turn off the vista buffer by using the -uv command line setting.

Rune
-- 
3D images and anims, include files, tutorials and more:
rune|vision:  http://runevision.com
POV-Ray Ring: http://webring.povray.co.uk


Post a reply to this message

From: Warp
Subject: Re: Positioning a camera
Date: 18 Apr 2005 05:27:11
Message: <42637d6f@news.povray.org>
Cesar <ces### [at] terracombr> wrote:
> I used to set location and look-at, but now I need different movements, so I
> decided to calculate location, direction, up and right. Then I started
> having problems. I allways get the error that says the vectors are not
> perpendicular.

  Let me guess: You are not printing enough decimals.

  By default C and C++ print only a few decimals for floating point numbers
(six, if I remember correctly). This rounds (from POV-Ray's point of view)
the values way too much. You have to print the values more accurately,
with like 15 decimals or so to be sure.
  The way to increase printing accuracy of floating point numbers depends
on whether you are printing using C or C++ streams.

-- 
                                                          - Warp


Post a reply to this message

From: Cesar
Subject: Re: Positioning a camera
Date: 18 Apr 2005 14:15:01
Message: <web.4263f7dc1c98b29bb45fb2880@news.povray.org>
>   Let me guess: You are not printing enough decimals.
>
>   By default C and C++ print only a few decimals for floating point numbers
> (six, if I remember correctly). This rounds (from POV-Ray's point of view)
> the values way too much. You have to print the values more accurately,
> with like 15 decimals or so to be sure.
>   The way to increase printing accuracy of floating point numbers depends
> on whether you are printing using C or C++ streams.
>
> --
>                                                           - Warp


Thanks for the answers! I'm using povray to simulate a camera we have in an
airship, so I'm interested in the distorted image cause then I can directly
simulate a not perfect camera, instead of introducing the erros in the
already rendered image.

I've been programming in c/c++ for years but I just realized I never had to
change printing accuracy of floating point numbers in c++, only in c.
Anyway, i found the precision() function (member of the ostream class) and
set the precision to 15 digits. Even so, povray still complains. I checked
the angles inside povray and I got things like: 90.0000001 and 89.9999993.
I think I'll work with this values and accept a most probably not
noticeable distortion (if I adjust the vectors inside povray, they will be
inconsistent with the c++ app).

Thanks again,

Cesar


Post a reply to this message

From: Sascha Ledinsky
Subject: Re: Positioning a camera
Date: 18 Apr 2005 14:44:21
Message: <42640005$1@news.povray.org>
> And no, using doubles in your program won't help since you transfer the 
> numbers in decimal ascii.

Well, in my case it did help. I had a very similar problem (my program 
set up a transformation matrix for the camera), and by swiching to 
doubles I got rid of the "Camera vectors are not perpendicular" message.

Is there any other format than decimal ascii that POV would accept?

 > And does so rightly,
 > 0.198669*1.30349 + 0.980067*(-0.26423) = 4.86e-8 != 0.0

I don't know if the vista buffer would still work if POV would accept 
vectors that are perpendicular within single precision limits. If yes, 
the test should IMHO be changed to be less pedantic.

 > You usually orient the camera with look_at or rotations and leave up
 > and right as default (except aspect ratio)

That's true for scenes that were created "by hand" with POV-SDL. When 
using external applications e.g. to animate the camera, I usually don't 
orient it with look_at...

-sascha


Post a reply to this message

Goto Latest 10 Messages Next 3 Messages >>>

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