Re: [Algorithms] decompose onto non-orthogonal vectors
Brought to you by:
vexxed72
From: <ro...@do...> - 2000-07-16 06:00:18
|
Peter Dimov wrote: >> >> 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.) Agree that it works for any number of dimensions provided that p does indeed lie in the plane of a and b. My point was that it will not detect the case that p does not lie in that plane, that is, will not detect the case that no solution exisits. |