POV-Ray : Newsgroups : povray.advanced-users : isosurface and trace problem Server Time
23 Dec 2024 10:47:41 EST (-0500)
  isosurface and trace problem (Message 1 to 4 of 4)  
From: Doctor John
Subject: isosurface and trace problem
Date: 16 Jun 2009 13:30:04
Message: <4a37d69c@news.povray.org>
I'm having a problem with getting trace to accurately place objects on
an isosurface. I'm sure I'm making an elementary mistake but I've been
staring at the code so long that I think I've gone error-blind :-)

OK First the isosurface section:

#declare Sand = texture {
	pigment {
		color rgb <0.9, 0.7, 0.3>*2
	 }
	finish {
		specular 0.6
		diffuse 0.4
	}
	normal {
		granite 0.15
		scale 0.05
	}
}

#declare FPigment = function{
	pigment {
		bozo
		color_map {
			[0.0 color rgb 0.0]
			[0.3 color rgb 0.2]
			[0.7 color rgb 0.8]
			[1.0 color rgb 1.0]
		}
		warp {
			turbulence 0.01
		}
		scale <2, 3, 2>
		translate <1.8, -6.7, 0>
	}
}

#declare Terrain_Obj = isosurface {
	function { y-FPigment(x, 0, -z).gray*0.4 }
	max_gradient 1.024
	accuracy 0.01
	contained_by {
		box {
			<-10000, -0.1, -10000>, <10000, 0.41, 10000>
		}
	 }
}

object {
	Terrain_Obj
	texture { Sand scale 1.4}
	scale <3, 3.1, 1>
	translate <0, -0.65, 0>
	rotate y*45
}

...and now the trace bit:

#declare Grain = sphere {0, 0.01}
#declare Count = 0;
#declare Norm = <0, 0, 0>;
#declare Spacing = 0.1;
#declare Seed = seed(54321);
#declare PosX = -25;

#while (PosX < 25)
	#declare PosZ = -8;
	#while (PosZ < 10)
		#declare Norm = <0, 0, 0>;
		#declare Start = <PosX+(rand(Seed)-0.5)*Spacing, 3.0,
PosZ+(rand(Seed)-0.5)*Spacing>;
		#declare Pos = trace (Terrain_Obj, Start, -y, Norm );
		#if (vlength(Norm) != 0)
			object {
				Grain
				texture {Sand}
				translate Pos
			}
			#declare Count = Count+1; //used later in a #debug
		#end
		#declare PosZ = PosZ + Spacing;
	#end
	#declare PosX = PosX + Spacing;
#end

When I render the image the spheres are definitely not coincident with
the isosurface, in fact they seem to be following a completely different
shape. I'm also getting unexplained gaps in the pattern of the spheres
almost as if they're only being placed on a particular range of slopes.

Any ideas?

John (feeling particularly stupid)
-- 
"Eppur si muove" - Galileo Galilei


Post a reply to this message

From: Chris B
Subject: Re: isosurface and trace problem
Date: 16 Jun 2009 15:07:51
Message: <4a37ed87@news.povray.org>
"Doctor John" <joh### [at] homecom> wrote in message 
news:4a37d69c@news.povray.org...
> I'm having a problem with getting trace to accurately place objects on
> an isosurface.
> ... snip ...
> #declare Terrain_Obj = isosurface {
> function { y-FPigment(x, 0, -z).gray*0.4 }
> ... snip ...
> object {
> Terrain_Obj
> texture { Sand scale 1.4}
> scale <3, 3.1, 1>
> translate <0, -0.65, 0>
> rotate y*45
> }
> ... snip ...
> #declare Pos = trace (Terrain_Obj, Start, -y, Norm );
> #if (vlength(Norm) != 0)
> object {
> Grain
> texture {Sand}
> translate Pos
> }

> Any ideas?

You're placing the object into the scene then scaling, translating and 
rotating it.
You then use the non-scaled, non-translated and non-rotated object in the 
trace command and position spheres on that.

You should move the transformations out from where you add the object to the 
scene and  into the object declaration, then it should be ok (though I 
didn't run your code to check).

Regards,
Chris B.


Post a reply to this message

From: Doctor John
Subject: Re: isosurface and trace problem
Date: 17 Jun 2009 06:37:30
Message: <4a38c76a$1@news.povray.org>
Chris B wrote:
> You're placing the object into the scene then scaling, translating and
> rotating it.
> You then use the non-scaled, non-translated and non-rotated object in
> the trace command and position spheres on that.
> 

So what you're saying is that trace is looking at the
#declare Terrain_Obj statement, rather than the object{ Terrain_Obj}
statement.
Thinking about that I suppose that's logical since I could have multiple
object{} statements and trace wouldn't know which one to act on.

> You should move the transformations out from where you add the object to
> the scene and  into the object declaration, then it should be ok (though
> I didn't run your code to check).
> 
> Regards,
> Chris B.
> 

That suddenly occurred to me late last night, I'll try it when I get
home this evening.
Ah, debugging by talking about it :-)
Thanks for the help Chris

John
-- 
"Eppur si muove" - Galileo Galilei


Post a reply to this message

From: Chris B
Subject: Re: isosurface and trace problem
Date: 17 Jun 2009 07:34:10
Message: <4a38d4b2$1@news.povray.org>
"Doctor John" <joh### [at] homecom> wrote in message 
news:4a38c76a$1@news.povray.org...
> Chris B wrote:
>> You're placing the object into the scene then scaling, translating and
>> rotating it.
>> You then use the non-scaled, non-translated and non-rotated object in
>> the trace command and position spheres on that.
>>
>
> So what you're saying is that trace is looking at the
> #declare Terrain_Obj statement, rather than the object{ Terrain_Obj}
> statement.

Indeed it is. Indeed they both are.

The object {Terrain_Obj} statement is just **using** the object called 
'Terrain_Obj', much in the same way that the 'trace' function is taking it 
as input. It doesn't change it at all, it just adds an object to the scene 
that uses the previously declared object as the starting point, so any 
transformations within the object statement won't change the 'Terrain_Obj' 
object  (unless you explicitly assign the results back to it using another 
#declare statement).

Chris B.


Post a reply to this message

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