POV-Ray : Newsgroups : povray.general : Field of View : Re: Field of View Server Time
7 Aug 2024 17:22:36 EDT (-0400)
  Re: Field of View  
From: Vadim Sytnikov
Date: 5 Aug 2001 20:16:59
Message: <3b6de1fb@news.povray.org>
Using pow() in this context is a bad idea. Simple
multiplication (e.g. len3*len3) will do the trick while
being more efficient. Not by far due to the huge
parsing overhead, but...

As to the method in general -- what you propose is
not too accurate, and the other side of the cone is not
the only cause. Viewing frustum is not a cone.

I think, the right thing would be to build a matrix of
the transform inverse to the perspective one (i.e. such
transform that turns viewing frustum into a box; preferably
oriented along some axis) and then write a macro that
will apply that transform to projected primitive's
coordinates. If result is outside of the box -- well, hope
you got it.

BTW, this somewhat resembles what POV-Ray does
internally to each emitted ray while calculating intersections.

David Fontaine <dav### [at] faricynet> wrote in message
news:3B6DB942.CE717D93@faricy.net...
> Andrew wrote:
> >
> > OK, I know I'm being lazy here, but my maths isn't that hot...
> >
> > Can anyone tell me how I would go about determining if a point will be
> > in view given its coordinates and the camera's parameters?  See, I'm
> > making Antoine's necklace, a fractal object involving a very large
> > number of primitives, and they take up way too much memory, but many are
> > off the screen.
>
> I wrote a macro to find the angle between two vectors.
>
>
> #macro vangle(vec1,vec2)
>    #local len1 = vlength(vec1);
>    #local len2 = vlength(vec2);
>    #local len3 = vlength(vec2-vec1);
>    acos((pow(len3,2)-pow(len1,2)-pow(len2,2))/(-2*len1*len2))
> #end
>
>
> So find the angle between the vector
>
>    object position - camera position
>
> and the vector
>
>    camera look_at - camera position (or just camera direction)
>
> and check if the angle is larger than your viewing angle.  Since the
> camera angle goes to the edge of the pic, not the corner, you need a
> bigger angle than the actual camera angle.  I think this should do it:
>
>    atan(sqrt((1 + pow(image_height/image_width, 2)) *
> pow(tan(camera_angle), 2)))
>
> And of course you have to add a little padding for the width of the
> objects...
>
> Of course, this tells you if the object is in a cone around the field of
> view, but it can be in the cone and outside the image.  So it's not 100%
> efficient, but it'll work (I think).
>
> --
> David Fontaine  <dav### [at] faricynet>  ICQ 55354965
> My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

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