|
|
Cousin Ricky <ric### [at] yahoocom> wrote:
> 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.
Thanks for the quick reply. I had tried this myself before but thought there
ought to be a more elegant solution.
Post a reply to this message
|
|