POV-Ray : Newsgroups : povray.newusers : Finding extents of an object : Re: Finding extents of an object Server Time
18 Apr 2024 03:16:00 EDT (-0400)
  Re: Finding extents of an object  
From: Alain Martel
Date: 15 Jun 2021 16:27:12
Message: <60c90d20$1@news.povray.org>
Le 2021-06-15 à 13:14, Herbert Pflaum a écrit :
> Hi there,
> 
> I would like to render an object using POV-Ray and it works nicely for
> the most part. The issue is that I have varying objects that I'm
> rendering (the POV-Ray source is generated) and they are varying in
> their position and size. I always view them in orthographic projection
> from a 45° angle (i.e., object at 0,0,0 camera at 10,10,10 look_at 0,0,0).
> 
> This works fairly well but I would like the rendering output to be so
> that the object is not clipped but also takes up most of the screen real
> estate. I do this currently by manually varying the "angle" operator
> (i.e., for small objects, small angle and for large objects a large angle).
> 
> I want this do be done automatically but I don't know where to start.
> Any hints on how to achieve this?
> 
> Thanks,
> Herbert
> 

You can use max_extent(Object) and min_extent(Object) to relocate and 
scale your objects correctly.
Those return the far, top right and close bottom left of the bounding 
box of Object.

The way to use that is as follow (steps as comment so that you can 
copy/paste in your scene :

// 1) #declare your object.
#declare Object = { your object's definition/construction }

// 2) Find it's bounds :
#declare TopRight = max_extent(Object);
#declare BottomLeft = min_extent(Object);

// 3) Find the centre of the object :
#declare ObjCentre = (TopRight + BottomLeft ) /2;

// 4) Place your object at the origin :
#declare Object = object{Object translate -ObjCentre }

// 5) Optionally, you can scale it to fit and prevent clipping :
#declare Extent = max(TopRight.x, TopRight.y, TopRight.z);
// Find the largest dimension

#declare DimFactor = 9.9;
// Standardize the dimention :
#declare Object = object{Object scale 9.9/Extent}

// This effectively scale your object down to a size of 1 unit, then
// up by a factor of 9.9, keeping it's proportions intact
// and providing a small margin

// 6) Finally, place it in your scene :
Object

The value of «DimFactor» may need to be adjusted to have your best fit.


Post a reply to this message

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