Interpolation in 3d

Started by
1 comment, last by P2 20 years ago
Hi, I have a vessel with a position on an x-y grid and want to calculate the vessel''s position in the z direction, the height. There are only a few points scattered around the grid where the z is given so on the rest of the points I have to interpolate the height from these points. Could I just use the three closest points and make some kind of weighted average between them or should I calculate some kind of height curves for the grid? A problem is that this should all happen in real-time so it can’t be too computationally expensive. I’m thankful for all the help I can get. Does anyone know of a good page for interpolating and calculating averages and so on? I often seem to end up with these kind of problems. Regards, P2
Advertisement
If there really are just a few control points, this might be the easiest:

z_final = 0.0;z_weight = 0.0;for (i = 0; i < NumPoints; ++i){  dx = pt.x - my_x;  dy = pt.y = my_y;<br>  this_weight = 1.0 / (1.0 + dx*dx + dy*dy); // add 1 so no "if 0"<br>  z_final += pt.z * this_weight;<br>  z_weight += this_weight;<br>}<br>z_final /= z_weight; // "normalize"<br>  </pre>     </i>   <br><br>note that cycle saving measures like finding the 3 closest points are expensive too.  I say try it and see.<br><br>numerical recipies (sp?) is a great resource for algo's:<br>www.nr.com<br><br>lonesock<br><br>Piranha are people too.   <br><br><SPAN CLASS=editedby>[edited by - lonesock on March 30, 2004 4:09:11 AM]</SPAN>
Thanks,
I''ll try that idea, It''s not always the same amount of control points but when there are just a few I believe this will be quite good, since as you pointed out, finding the 3 closest points can be expensive.

Guess I have to go for some triangulation when there are too many points.

/P2

This topic is closed to new replies.

Advertisement