POV-Ray : Newsgroups : povray.general : Density file drift based upon interpolation Server Time
18 Nov 2024 07:17:11 EST (-0500)
  Density file drift based upon interpolation (Message 1 to 2 of 2)  
From: William F  Pokorny
Subject: Density file drift based upon interpolation
Date: 28 Sep 2002 12:33:36
Message: <3D95D9DF.591FBAE4@attglobal.net>
Perhaps the wrong group, but I want to document something I
found.

I discovered while playing with R. Suzuki's density file
patch that when we use any interpolation type but 'no
interpolation' the density becomes vertex centered instead
of voxel centered.  In other words the density specified by
the density file changes position.

With typical density files perhaps this has gone unnoticed,
but if using the density file with isosurfaces  for example,
the density files can be quite small and the shift in
position is very noticeable.

If we want to stay voxel centered for all interpolation
types, we can accomplish it with some code like the
following.  In the density_pattern function, in pattern.cpp,
just ahead of the interpolation switch block we would add:

interpolationType =
(TPat->Vals.Density_File->Interpolation % 10);

if ((interpolationType != NO_INTERPOLATION)
  { Ex -= (0.5 / (DBL)Data->Sx); // Result to voxel center
    Ey -= (0.5 / (DBL)Data->Sx);
    Ez -= (0.5 / (DBL)Data->Sx);
  }

And the switch control statement would be changed to use the
already calculated interpolationType value.

Regards, Bill P.


Post a reply to this message

From: William Pokorny
Subject: Re: Density file drift based upon interpolation
Date: 29 Sep 2002 16:09:57
Message: <3D9760FE.9297F762@attglobal.net>
Privately someone pointed out a couple of mistakes in my
suggested fix. The corrected lines read: 

if (interpolationType != NO_INTERPOLATION)
  { Ex -= (0.5 / (DBL)Data->Sx); // Result to voxel center
    Ey -= (0.5 / (DBL)Data->Sy);
    Ez -= (0.5 / (DBL)Data->Sz);
  }

Bill P.


Post a reply to this message

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