POV-Ray : Newsgroups : povray.newusers : Displacing camera in 2D? Server Time
31 Oct 2024 16:15:46 EDT (-0400)
  Displacing camera in 2D? (Message 1 to 5 of 5)  
From: remigagne
Subject: Displacing camera in 2D?
Date: 17 Sep 2007 14:35:00
Message: <web.46eec6f4d509387a899005320@news.povray.org>
Hi all,

I have a scene that renders correctly at 1000 x 1000 with this true
orthographic camera:

camera { orthographic
 location <-28, -14.5, -28> * 1000
 right    1000 * x
 up       1000 * y
 look_at  <0, 0, 0> }

I'm now trying to create new 100 x 100 sub-portions of this scene.  For
example, if I render at 100 x 100 using this camera:

camera { orthographic
 location <-28, -14.5, -28> * 1000
 right    100 * x
 up       100 * y
 look_at  <0, 0, 0> }

I get a 100 x 100 image that's *identical* to the (450, 450) to (550, 550)
center of the original 1000 x 1000 image, which is perfect.  But how can I
generalize this to render any portion of the scene?  For example, how can I
generate a 100 x 100 image centered on the (30, 400) portion of the
original?

I think I can translate the camera and look_at point, doing something like:

camera { orthographic
 #declare dx = ?;
 #declare dy = ?;
 #declare dz = ?;
 location (<-28, -14.5, -28> * 1000) + <dx, dy, dz>
 right    100 * x
 up       100 * y
 look_at  <dx, dy, dz> }

I just can't wrap my head around the math required to calculate dx, dy & dz,
given a center pixel location of (30, 400).  Any advice?

A little more background: the scene is in a predefined pov file with no
camera.  I'm generating new pov files programmatically; these simply
include the original scene and a dynamically calculated camera (based on
user input).

Thanks in advance!


Remi


Post a reply to this message

From: Le Forgeron
Subject: Re: Displacing camera in 2D?
Date: 17 Sep 2007 16:27:36
Message: <46eee338$1@news.povray.org>
Le 17.09.2007 20:32, remigagne nous fit lire :
> Hi all,
> 
> I have a scene that renders correctly at 1000 x 1000 with this true
> orthographic camera:
> 
> camera { orthographic
>  location <-28, -14.5, -28> * 1000
>  right    1000 * x
>  up       1000 * y
>  look_at  <0, 0, 0> }
> 
> I'm now trying to create new 100 x 100 sub-portions of this scene.  For
> example, if I render at 100 x 100 using this camera:
> 
> camera { orthographic
>  location <-28, -14.5, -28> * 1000
>  right    100 * x
>  up       100 * y
>  look_at  <0, 0, 0> }
> 
> I get a 100 x 100 image that's *identical* to the (450, 450) to (550, 550)
> center of the original 1000 x 1000 image, which is perfect.  But how can I
> generalize this to render any portion of the scene?  For example, how can I
> generate a 100 x 100 image centered on the (30, 400) portion of the
> original?
> 
> I think I can translate the camera and look_at point, doing something like:
> 
> camera { orthographic
>  #declare dx = ?;
>  #declare dy = ?;
>  #declare dz = ?;
>  location (<-28, -14.5, -28> * 1000) + <dx, dy, dz>
>  right    100 * x
>  up       100 * y
>  look_at  <dx, dy, dz> }
> 
> I just can't wrap my head around the math required to calculate dx, dy & dz,
> given a center pixel location of (30, 400).  Any advice?
> 

Notice that direction here is originally as +z.
Therefore, dz = 0.
And you should simplify your orthographic camera by remplacing the
look_at with direction.

If dx=dy=0 give you a center at (500,500) of the big one, the new
camera will be centered on 500+dx,500+dy.

So, if you want the center at (XX,YY), dx = XX-500 and dy = YY-500.

(30,400) -->>>> dx = -470, dy = -100.

-- 
The superior man understands what is right;
the inferior man understands what will sell.
-- Confucius


Post a reply to this message

From: Tim Attwood
Subject: Re: Displacing camera in 2D?
Date: 17 Sep 2007 19:17:54
Message: <46ef0b22@news.povray.org>
> I'm now trying to create new 100 x 100 sub-portions of this scene.  For
> example, if I render at 100 x 100 using this camera:

POV has command line options for partially rendering a scene.
(3.1.2.2.2 Partial Output Options)
Also in the windows version you can drag a box onto the render
window to partially render a portion of your image.
This doesn't crop the images for you though, so it might not be
what you want.


Post a reply to this message

From: Alain
Subject: Re: Displacing camera in 2D?
Date: 18 Sep 2007 00:13:51
Message: <46ef507f$1@news.povray.org>
remigagne nous apporta ses lumieres en ce 2007/09/17 14:32:
> Hi all,
> 
> I have a scene that renders correctly at 1000 x 1000 with this true
> orthographic camera:
> 
> camera { orthographic
>  location <-28, -14.5, -28> * 1000
>  right    1000 * x
>  up       1000 * y
>  look_at  <0, 0, 0> }
> 
> I'm now trying to create new 100 x 100 sub-portions of this scene.  For
> example, if I render at 100 x 100 using this camera:
> 
> camera { orthographic
>  location <-28, -14.5, -28> * 1000
>  right    100 * x
>  up       100 * y
>  look_at  <0, 0, 0> }
> 
> I get a 100 x 100 image that's *identical* to the (450, 450) to (550, 550)
> center of the original 1000 x 1000 image, which is perfect.  But how can I
> generalize this to render any portion of the scene?  For example, how can I
> generate a 100 x 100 image centered on the (30, 400) portion of the
> original?
> 
> I think I can translate the camera and look_at point, doing something like:
> 
> camera { orthographic
>  #declare dx = ?;
>  #declare dy = ?;
>  #declare dz = ?;
>  location (<-28, -14.5, -28> * 1000) + <dx, dy, dz>
>  right    100 * x
>  up       100 * y
>  look_at  <dx, dy, dz> }
> 
> I just can't wrap my head around the math required to calculate dx, dy & dz,
> given a center pixel location of (30, 400).  Any advice?
> 
> A little more background: the scene is in a predefined pov file with no
> camera.  I'm generating new pov files programmatically; these simply
> include the original scene and a dynamically calculated camera (based on
> user input).
> 
> Thanks in advance!
> 
> 
> Remi
> 
> 
> 
It would be easier if your camera was parallel to an axis, like the z axis.
You first need to evaluate how many pov-units fit in your 1000 original pixels.
It can be evaluated empiricaly using a plane with a checker pattern. It can be 
calculated from the direction vector that default to 1. It's about the same as 
the distance between the location and the look_at point, or about 42169 
pov-units whide! The field of view extend 0.5 units left and right from the 
camera axis at 1 unit in front of the camera, multiplied by the distance to the 
look_at point.
So, for each 1 pixel of movement, you need to move the camera 42.17 units. You 
could use the vrotate(<Udx,Udy,0>, Your_Angle) macro on the <Udx, Udy, 0> vector 
of the user to get the <dx,dy,dz> translate vector you need.
You can add translate<dx,dy,dz> to your camera after everything else. This way, 
your camera won't change it's orientation: the location and look_at will change 
in exactly the same direction and distance. Easier to maintain and less chance 
of making a typo.

-- 
Alain
-------------------------------------------------
You know you've been raytracing too long when you have ever "Hand-Coded" a 
bezier patch.
Stephan Ahonen


Post a reply to this message

From: remigagne
Subject: Re: Displacing camera in 2D?
Date: 25 Sep 2007 20:35:00
Message: <web.46f9a81847bea764899005320@news.povray.org>
Sorry for the delayed response, but I just got everything working.  Thanks
so much for all your feedback!

The hint that hit it home was the simple observation that everything is
easier with a camera parallel to axis.  So, instead of positioning my
camera to get the right view angle, I left it looking straight down the Z
axis, then rotated the entire scene itself.  Seems strange, but it worked
like a charm!

Also, if the image is 100x100 and orthographic camera up=100*y and
right=100*x, translating the camera that looks down z by one unit in either
x or y gives exactly a one pixel difference in output.  Wonderful!

Thanks again for all the help.


Remi

Alain <ele### [at] netscapenet> wrote:
> It would be easier if your camera was parallel to an axis, like the z axis.
> You first need to evaluate how many pov-units fit in your 1000 original pixels.
> It can be evaluated empiricaly using a plane with a checker pattern. It can be
> calculated from the direction vector that default to 1. It's about the same as
> the distance between the location and the look_at point, or about 42169
> pov-units whide! The field of view extend 0.5 units left and right from the
> camera axis at 1 unit in front of the camera, multiplied by the distance to the
> look_at point.
> So, for each 1 pixel of movement, you need to move the camera 42.17 units. You
> could use the vrotate(<Udx,Udy,0>, Your_Angle) macro on the <Udx, Udy, 0> vector
> of the user to get the <dx,dy,dz> translate vector you need.
> You can add translate<dx,dy,dz> to your camera after everything else. This way,
> your camera won't change it's orientation: the location and look_at will change
> in exactly the same direction and distance. Easier to maintain and less chance
> of making a typo.
>
> --
> Alain
> -------------------------------------------------
> You know you've been raytracing too long when you have ever "Hand-Coded" a
> bezier patch.
> Stephan Ahonen


Post a reply to this message

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