toneburst

01-06-2010, 08:26 AM

Quick query.

in the following code;

float4 VertexInterp(isolevel, p1, p2, valp1, valp2)

double isolevel, valp1, valp2;

float4 p1, p2;

{

float mu;

float4 p = 0;

if (fabs(isolevel-valp1) < 0.00001) return(p1);

if (fabs(isolevel-valp2) < 0.00001) return(p2);

if (fabs(valp1-valp2) < 0.00001) return(p1);

mu = isolevel - valp1) / (valp2 - valp1;

p = mix(p1,p2,mu);

return(p);

}

}

is it good to explicitly convert the result of the calculation

isolevel - valp1) / (valp2 - valp1

(where valp1 and valp2 are doubles) into a float, or can it be left as it is?

I presume I'd cast the result as a float like so

mu = (float)(isolevel - valp1) / (valp2 - valp1);

but am wondering if it's necessary or desirable to do so.

a|x

http://machinesdontcare.wordpress.com

in the following code;

float4 VertexInterp(isolevel, p1, p2, valp1, valp2)

double isolevel, valp1, valp2;

float4 p1, p2;

{

float mu;

float4 p = 0;

if (fabs(isolevel-valp1) < 0.00001) return(p1);

if (fabs(isolevel-valp2) < 0.00001) return(p2);

if (fabs(valp1-valp2) < 0.00001) return(p1);

mu = isolevel - valp1) / (valp2 - valp1;

p = mix(p1,p2,mu);

return(p);

}

}

is it good to explicitly convert the result of the calculation

isolevel - valp1) / (valp2 - valp1

(where valp1 and valp2 are doubles) into a float, or can it be left as it is?

I presume I'd cast the result as a float like so

mu = (float)(isolevel - valp1) / (valp2 - valp1);

but am wondering if it's necessary or desirable to do so.

a|x

http://machinesdontcare.wordpress.com