View Full Version : Reverse engineering a point constraint
10 October 2006, 01:24 AM
Hiya, I'm having a serious dilemma, and my brain is threatening to leave me if I continue to hammer it with this problem:
We have object "N" which is point constrained between three objects, A, B and C, with (normalised) weight values of i, j and k.
Object N's position is found by:
N = Ai + Bj + Ck
Given N, A, B and C... how do we find i, j and k?
I attempted to solve using this equation and I share what follows purely for amusement and out of a masochistic desire to be told my maths is horribly, horribly wrong, SO, anyone seeking to answer my question, please ignore what follows because I don't think this is the road to the solution.
We know that:
i + j + k = 1
Taking the long and arduous road of trying-to-remember-highschool-maths, I substituted i = 1 - j - k into the equation to get:
N = A(1 - j - k) + Bj + Ck
= A - Aj - Ak + Bj + Ck
Not sure if this was helping me or not, I ran some tests substituting values for k until I came up with the further equation:
j = ( N - ( A(1-k) + Ck) ) / (B - A)
I can't remember how to prove an 'estimated' equation so I just kept throwing numbers at it and it kept working, so with the glimmer of scientific discovery (manic psychotic disassociation) I went through a small forest in paper to end up with.... nothing usable.
I have before me pages and pages of mathematical substitution and minimisation and...all
this...number...stuff. The end result?
N = A ( 1 - ( ( N - ( A ( 1 - k ) + Ck ) ) / ( B - A ) ) ) + B ( ( N - ( A ( 1 - k ) + Ck ) ) / ( B - A ) ) + Ck
Just thought I'd share. For those real mathematicians out there, please excuse my heavy handling of your art.
EDIT: I should add that the first couple of pages of my attempt to minimise this equation resulted in the accidental discovery of the groundbreaking mathematical formula:
N = N
10 October 2006, 06:48 AM
U set my mind tickin too.. ;) I suggest u check out this website... http://math2.org/ it has some neat stuff abt all math basics n a lot of links to advanced math.... more of a Math Bible.. Hope tht helps...
10 October 2006, 07:28 AM
I may well be wrong here, but my gut tells me you can't solve that without knowing at least one of i, j and k. If you do know one of these, and know A, B C and N (as I assume you do from your post), it is easy, but otherwise...
10 October 2006, 02:18 PM
i think you'll need 2 of ijk. just imagine ABC would be in a line - you won't be able to find results if you only had N and 1 of ijk. and as i remember from my math lessons for every variable you want to solve you need one equation - so in your case at least three...
10 October 2006, 02:49 PM
Yeah Starrider.. I gues u r totally right... its like back in school we used to solve equations with 3 variables.. Eg:
These r jus random equations which I fabricated jus now.. but jus for an example.. we would then add all 3 in two seperate combinations..and try and eliminate either x or y or z... then with the remaining two pairs of equatons having the same 2 variables, we solve and find the value of either one.. (if z is eliminated then the 2 eqns with x & y will be evaluated to eliminate x or y and that way we find one which leads to the other) then with having both x & y now we can finally find z.
I guess that clears the basic doubts we all had.... ;)
10 October 2006, 08:09 PM
If I'm understanding your proposition correctly, I think Barycentric Coordinates are your answer.
And paraphrasing from the wikiPedia article:
Given three points of a triangle: A, B, and C, any point N can be written as a weighted sum of the vertices:
N = iA + jB + kC
And after lots of math you can look at on the wikiPedia article, you can find parameters i, j, and k with:
i = ---------------------------------------------------------------
j = ---------------------------------------------------------------
k = 1 - i - j
This is a special case though with triangles. If you have more than three pointConstraints, it becomes a little trickier. But if you think about it as a linear combination of vectors, it should still be solveable. It might not necessarily have a unique solution though.
10 October 2006, 05:51 AM
Thanks..!! I guess u pretty much nailed it for us...!
10 October 2006, 11:38 AM
I've been away for the weekend and have to confess I didn't really expect any replies at all, let alone a solution!
I was convinced a solution WAS possible given only A,B,C and N, because there would always be only one (normalised) solution for i,j and k.
Trying to solve based upon the equation N = Ai + Bj + Ck was something I shared purely for amusement :) Seeing as how we had only two equations but three unknowns, we knew we weren't going to find an easy solution down this road, but we did correctly identify a third equation through substitution and a bit of guess work.
But we also knew there had to be a relatively simple solution that was in all likelihood not derived from the N = Ai + Bj + Ck equation, as there were many other factors (such as vector magnitudes and angles within the triangular space) that could 'possibly' be utilised for a solution.
Either way, thankyou VERY MUCH for finding the solution. It was driving me to lack of sleep!
10 October 2006, 11:38 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.