POV-Ray : Newsgroups : povray.binaries.animations : CHROMADEPTH code tests-- animation : Re: CHROMADEPTH code tests-- animation Server Time24 Jun 2021 14:36:54 EDT (-0400)
 From: Kenneth Date: 23 Feb 2018 04:35:00 Message:
```"Bald Eagle" <cre### [at] netscapenet> wrote:
> So, after looking over the animation for a bit more, and considering what
> you're probably actually trying to do:
>
> 1.  I'm not actually clear on how you're working out all that color map and
> scaling math.
> I think I'd find the distance to the farthest corner (not necessarily
> max_extent) and the nearest corner.  Divide both distances by farthest corner
> distance.   That gives you 1 and less than 1.
> define color map, and then scale back up by distance to the farthest corner.
> I think that should give you that thin shell of varying color extending from
> nearest corner to farthest corner.

Well, that's exactly what min_extent and max_extent are *supposed* to do (along
with my code for creating the scaled-up thin shell.) :-/ Although, it's not
clear to me as to how to get the near and far corners of an object without using
those functions to begin with. Some fancy vector math, I'm guessing?

>
> 2. You're not really looking for "which" corner is nearest or farthest,
> programmatically, you're looking for the largest and smallest distances.
>
> So, just calculate all 8 distances and use min() and max().

I do see what you're getting at. But there remains that little thorny problem of
too much extra space between object and bounding-box, when the object happens to
be rotated. (See the orthographic camera views I posted in Mike H's thread.)
That space still slightly throws off an accurate gauge of the object's spatial
volume-- with a correspondingly inaccurate color_map 'spread.'

HOWEVER... your suggestion has given me another idea-- and I'm surprised at
myself for not having thought of it already: To use POV-Ray's trace() function
to find the *exact* outer-surface-size of the object-- the trace 'shoot-from'
origin being the 'MAIN camera' position-- then again from 180-degrees
'antipodal'(?) to that line of sight. Maybe 20-40 trace rays....and using the
bounding-box coordinates as simply a way to restrict the tracing volume, to be
efficient. From those found points, it's an easy matter of finding the object's
spatial extent and its center location--then the color_map spread should
*exactly* cover the object.

I'll try to code that up and see...
```