POV-Ray : Newsgroups : povray.binaries.images : Problem: Finding the elevation range of an isosurface relief : Re: Problem: Finding the elevation range of an isosurface relief Server Time
2 Aug 2024 10:26:10 EDT (-0400)
  Re: Problem: Finding the elevation range of an isosurface relief  
From: Ray Bellis
Date: 8 Aug 2007 03:52:16
Message: <46b97630$1@news.povray.org>


> How could this be achieved? The highest point could be
> tested for by shooting a series of parallel horizontal
> trace() rays from one edge of the map section, starting
> at a height well above the highest mountains in the whole
> isosurface (for example 15 kilometres), going lower each
> iteration until the first mountain peak is hit. But how
> to this for the lowest point?
>
> And, after all, I'm sure that this method would be
> outstandingly time-consuming - is there any way to do it faster?

It needn't be particular slow at all - you can use an O(LogN) binary 
sub-division algorithm:

In pseudo code:

int height = 16384;
int step = height / 2;
while (step >= 0) {
  if (hit_object_at_height(height)) {
    height += step;
  } else {
    height -= step;
  }
  step /= 2;
}

With just 15 trace calls you'd have the maximum height between 0 and 65535m 
to 1m resolution.

Ray


Post a reply to this message

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