POV-Ray : Newsgroups : povray.newusers : auto scaling an object to fit x% of image Server Time
25 Nov 2024 22:40:34 EST (-0500)
  auto scaling an object to fit x% of image (Message 1 to 3 of 3)  
From: Mutley2003
Subject: auto scaling an object to fit x% of image
Date: 11 Feb 2005 00:05:01
Message: <web.420c3c53b7391ab94342870a0@news.povray.org>
Hi

I have figured out a little macro to autocenter an object (see below), but I
would like to auto scale that object to fill x% of the image x and y
dimensions.


I know of image_height and _width and I suspect that the calculation I need
has something to do with the camera angle and other camera params, but I am
not sure how to proceed. Also, I would like this to work for a perspective
camera and an orthographic camera.

I would appreciate some help, thanks


#macro AUTOCENTER(SomeObject)
/*

 This macro redeclares the input object so as to do the autocentering
 on that object .. see help 3.2.2.8.5  Returning Values Via Parameters

 This means that a usage like AUTOCENTER(sphere{whatever} is not legal
 - you have to pass in an object.

 min_extent is not guaranteed to work with all csg objects.

*/
#local jaMin = min_extent ( SomeObject );  // corner 1
#local jaMax = max_extent ( SomeObject );  // corner 2
#local jax =(jaMin.x+jaMax.x)/2;
#local jay =(jaMin.y+jaMax.y)/2;
#local jaz =(jaMin.z+jaMax.z)/2;
#declare SomeObject = object{SomeObject translate <-jax,-jay,-jaz> }
#end // end of macro


Post a reply to this message

From: Le Forgeron
Subject: Re: auto scaling an object to fit x% of image
Date: 18 Feb 2005 07:48:25
Message: <Xns96018C73F9665jgrimbertmeandmyself@203.29.75.35>


> Hi
> 
> I have figured out a little macro to autocenter an object (see below),
> but I would like to auto scale that object to fill x% of the image x
> and y dimensions.
> 
> 
> I know of image_height and _width and I suspect that the calculation I
> need has something to do with the camera angle and other camera
> params, but I am not sure how to proceed. Also, I would like this to
> work for a perspective camera and an orthographic camera.
> 
> I would appreciate some help, thanks

Orthographic camera: the image scope is given by the right and up 
vector's length. 

 up 1*y
 right 1*x

give a 1x1 scene size, stretched over image_height and _width.

Perspective camera: have faith in the maths, for not so narrow angle, you 
have a distortion near the border: a circle is not a circle anymore!

Best hint from me: Use the source for the camera ray computation and 
reverse the math for some fixed %, assuming a central position of the 
object. Or do it the caltech way...

-- 
This is an unauthorised cybernetic announcement.

When someone says "I want a programming language in which I need only
say what I wish done," give him a lollipop.


Post a reply to this message

From: Mutley2003
Subject: Re: auto scaling an object to fit x% of image
Date: 18 Feb 2005 17:45:01
Message: <web.42166f2dc8f2865198e4127b0@news.povray.org>
Le Forgeron <jgr### [at] freelocalhost> wrote:

> Perspective camera: have faith in the maths, for not so narrow angle, you
> have a distortion near the border: a circle is not a circle anymore!
>
> Best hint from me: Use the source for the camera ray computation and
> reverse the math for some fixed %, assuming a central position of the
> object. Or do it the caltech way...

ok, maybe I can reverse the math. But what is the "caltech way"?


Post a reply to this message

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