POV-Ray : Newsgroups : povray.binaries.images : isosurface <> height_field : Re: isosurface <> height_field Server Time
7 Aug 2024 13:20:28 EDT (-0400)
  Re: isosurface <> height_field  
From: Thomas de Groot
Date: 2 Mar 2006 03:10:25
Message: <4406a871$1@news.povray.org>
"Bruno Cabasson" <bru### [at] alcatelaleniaspacefr> schreef in bericht
news:web.4405e8ec12c4035382fc96790@news.povray.org...
>
> Here is a general code to illustrate the principle of the conversion HF
<->
> ISO:
>
> #include "colors.inc"
> #include "functions.inc"
> global_settings {
>   assumed_gamma 1.0
> }
>
> // ----------------------------------------
>
> camera {
>   location  <0.0, 10, -30.0>
>   direction 1.5*z
>   right     x*image_width/image_height
>   look_at   <0.0, 0.0,  0.0>
> }
>
> background {Gray10}
>
> light_source {
>   <0, 0, 0>            // light's position (translated below)
>   color rgb <1, 1, 1>  // light's color
>   translate <-30, 30, -30>*100
> }
>
> // ----------------------------------------
>
>
> ##declare TERRAIN_SIZE = 10;
> #declare TERRAIN_HEIGHT = 2;
>
> #declare fn_Terrain = function (x, y, z) {f_agate (x, 0, z)} // Or
whatever
> in x-z plane. For functions in x-y plane (wood): f_wood(x, z, 0)
>
> #declare O_ISOTerrain = isosurface
> {
>     function {y - TERRAIN_HEIGHT*fn_Terrain(x/TERRAIN_SIZE, 0,
> z/TERRAIN_SIZE)}
>     max_gradient 4
>     contained_by {box {<-TERRAIN_SIZE, 0, -TERRAIN_SIZE>, <TERRAIN_SIZE,
> TERRAIN_HEIGHT,TERRAIN_SIZE>}}
> }
>
> #declare O_HFTerrain = height_field
> {
>     function 300, 300 {fn_Terrain ((x-0.5)*2, 0, -(y-0.5)*2)}
>     smooth
>     translate -x/2 -z/2
>     scale <2*TERRAIN_SIZE,TERRAIN_HEIGHT,2*TERRAIN_SIZE>
> }
>
> // Superimpose the 2 versions to check they are close one to another
> object {O_ISOTerrain pigment {Red}}
> object {O_HFTerrain pigment {Green}}
>
>

Excellent! Many thanks! This should do the job!

Thomas


Post a reply to this message

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