Re: [Algorithms] decompose onto non-orthogonal vectors
Brought to you by:
vexxed72
From: Peter D. <pd...@mm...> - 2000-07-15 23:14:52
|
> >> how to you get scalars (u,v) such that u*a + v*b = p? > >> Ie. decompose p onto a and b. > > > >Easy. dot the equation with a and b, correspondingly: > > > >u * (a dot a) + v * (b dot a) = p dot a; > >v * (a dot b) + v * (b dot b) = p dot b. > > > >Solve the system. > > In the 2D case this is more complicated than it need be, but will give > the correct solution (provided, of course that one knows dot product > and how to solve a 2x2 system). > > In the 3D case, this will give the correct solution only if p is > indeed in the plane of a and b. It will not detect that there is no > solution if p is not coplanar with a and b. This works for any number of dimensions. Whenever a solution exists, the (u, v) pair determined by this approach will have the property u * a + v * b = p. (Easy to prove.) -- Peter Dimov Multi Media Ltd. |