POV-Ray : Newsgroups : povray.general : Objects in camera : Re: Objects in camera Server Time
5 Aug 2024 14:16:26 EDT (-0400)
  Re: Objects in camera  
From: Warp
Date: 3 Sep 2002 21:18:42
Message: <3d755f71@news.povray.org>
Tom A. <tar### [at] my-dejacom> wrote:
> Does anyone know of a way to determine if a particular point is in the
> camera's viewpoint?

  The task is simple: Project the point onto the viewing plane and see
if it's inside the limits of the image. (Scanline rendering uses this
in order to draw polygons on screen: They are first projected onto the
viewing plane and then drawn as 2D polygons.)

  Implementing this task is a bit more difficult.

  If your camera is located at the origin and looking at the positive z axis,
the formulas for projecting a 3D point onto the viewing plane are simple:

  x' = x*d/z
  y' = y*d/z

where x, y and z are the coordinates of the point and d is the length of
the direction vector of the camera.
  x' and y' will be the coordinates of the projected points in such way
that x'=0, y'=0 means the middle of the screen, y'=1 means the upper
edge of the screen and x'=4/3 means the right edge of the screen, given
that your camera ratio is 4/3 (I think! I am not sure about this since I
don't remember how POV-Ray uses the up and right vectors to do these
calculations; if you do try these formulas, you should try projecting
things on screen and see where do they end).

  The real problem is that the camera is most probably not at the origin
and looking at the positive z axis, which makes things more complicated.
I think that the easier way to solve this problem is to take the
transformations applied to the camera and apply the inverse transformation
to the point before projecting it. Of course this means that you must know
the transformations made to the camera and how to get their inverse (which
can be a bit complicated if you just use 'location' and 'look_at').

-- 
#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

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