POV-Ray : Newsgroups : povray.newusers : object parameters : Re: object parameters Server Time
26 Apr 2024 23:09:37 EDT (-0400)
  Re: object parameters  
From: Cousin Ricky
Date: 13 Feb 2023 12:16:40
Message: <63ea7078$1@news.povray.org>
On 2023-02-13 12:26(-4), seNex wrote:
> is there a way to get the parameter of an object after its declaration? For
> example if I create a sphere named mysphere with center <x,y,z> and radius 1,
> can I use a
> function to write these to new variables? Like:
> 
> 
> #declare mysphere=sphere{<x,y,z>,1};
> 
> #declare sphere_center=centerfunction(mysphere);
> #declare sphere_radius=radiusfunktion(mysphere);

There are no direct functions of this kind in POV-Ray, but you can
estimate the parameters by taking the bounding extents of the object:

#declare mysphere_center =
  (max_extent (mysphere) + min_extent (mysphere)) / 2;
#declare sphere_radius =
  (max_extent (mysphere).x - min_extent (mysphere).x) / 2;

Be aware that this is not perfectly reliable.  The functions
max_extent() and min_extent() are only estimates, and tend to grow
larger than the objects as transformations and CSG operations are
applied to the object.  But for a simple primitive such as a sphere, it
should work.


Post a reply to this message

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