Interpolating 10 vectors ?

Started by
2 comments, last by SirTwist 20 years ago
Hello there. I got something here that I don´t know to handle, even being the math genius that I am (<- deep sarcasm). So this is the thing. I´ve got a tetrahedron which has a field vector (v0-v3) assigned to each of its nodes. Furthermore it has another field vector (v4-v9) assigned to each of its edges (the middle of it). So that makes 10 field vectors. Now if I wanted to determine the corresponding field vector at a a certain position (x,y,z) in the tetrahedron, well, how would that go ? As fast as possible . Thanks in advance ! Twist
Advertisement
That's not trivial!

Actually, what you can do is to fit some polynomial function to your tetrahedron. I guess, for your case, it's a polynomial of second degree

p(x,y,z) = ax^2 + by^2 + cz^2 + dxy + exz + fyz + gx + hy + iz + j

That's 10 unknowns: a,b,...,i,j.
You got 10 nodes and 10 field vectors (v0,...,v9) at these nodes.
This means, you have 10 unknowns, but you can make 10 equations out of it (that fortunately fits!):

p(x,y,z-component of the l-th node) = l-th field vector vl.

where l=0,...,9. If the field vectors are really vectors, then your a,b,...,j's are also vectors, but you can solve the equations component-wise.

The equations you have to solve are a 10x10 linear system of equations which can be done e.g. by Gaussian elimination or any method you want.

Once you have the coefficients a,...,j, you have an interpolation formula. Plug in any x,y,z, then p(x,y,z) will interpolate your field vectors.

Hope that helps.

Lutz

[edited by - Lutz on April 5, 2004 6:33:50 AM]
Hm, thanks, but honestly, I have to say I never before solved that kind of equation.
I guess it would let this thread explode if I asked to write that down in code or pseudo-code format, huh ?!

Anyway, if that is possible and anybody is willing to take the time to do it I would be grateful. Otherwise I just have to dig into a math book I guess *arrghhhh*.

Thanks again.

Twist
Gaussian elimination is rather easy in principle, but a nice and stable implementation has some hidden difficulties. However, there should be ready-to-use C libraries for that task. Just google for "gaussian elimination C" or something like that, I bet you find something. Such a routine should just take a matrix A and a right-hand-side u. The return value is the vector s solving As=u.

In your case, A is a 10x10 matrix and is obtained directly from the equations

p(x,y,z-component of the l-th node) = l-th field vector vl.

Say, you call the x,y and z-component of the l-th node xl, yl and zl and the A-matrix is given by the entries Anm, n,m=0,...,9. Then by

p(x,y,z) = ax^2 + by^2 + cz^2 + dxy + exz + fyz + gx + hy + iz + j

you have
A00=x0^2, A01=y0^2, A02=z0^2, A03=x0y0, ..., A08=z0, A09=1,
A10=x1^2, A11=y1^2, A12=z1^2, A13=x1y1, ..., A18=z1, A19=1,
.
.
.
A90=x9^2, A91=y9^2, A92=z9^2, A93=x9y9, ..., A98=z1, A99=1.

That''s your matrix. The vector u you get from the right hand side "l-th field vector vl". Say, vl is not a vector but just a number, then the 10-dim-vector u=(u0,...,u9) is given by

ul = vl, l=0,...,9.

If vl is a vector, you do this procedure (number-of-dimensions-of-vl) times with just different u''s. The u''s are just obtained from vl(current dimension).

Finally, just plug your A and u into the linear system solver and you are ready. The vector s you get is your polynomial coefficients: s(0)=a, s(1)=b, ..., s(9)=j.

I hope this helped. If you have no idea what I am talking about, you should read something about basic linear algebra, but to explain it all in this forum would definitely let it explode.

Lutz

This topic is closed to new replies.

Advertisement