Skip to main content
GameDev.net gamedev.net
🔒 Locked

solving equations problem

Started by u_r_b_a_n Sep 29, 2008 at 3:32 AM 8 replies 1.4k views
Original Post
u_r_b_a_n
u_r_b_a_n
Hello! I have a math problem in my program that i'm writing. I want to get new position of a point by inputing angles. I need to get x, y and z coordinates of a point sEP from three equations... I'll write them: .............K1 * (sEP.X - K2) + K3 * (sEP.X - K2) aCosVF = ----------------------------------------------------------------- , .............Math.Sqrt(number) * Math.Sqrt( (sEP.X - K2)^2 + (sEP.Y - K4)^2 ) .............K5 * (sEP.Y - K4) + K6 * (sEP.Z - K7) aCosVS = ----------------------------------------------------------------- , .............Math.Sqrt(number2) * Math.Sqrt( (sEP.Y - K4)^2 + (sEP.Z - K7)^2 ) .............K1 * (sEP.X - K2) + K8 * (sEP.Z - K7) aCosH = ----------------------------------------------------------------- , .............Math.Sqrt(number3) * Math.Sqrt( (sEP.X - K2)^2 + (sEP.Z - K7)^2 ) where K1,...,K7 and aCosVF, aCosVS and aCosH are given numbers. I need to get the coordinates from sEP, that means sEP.X, sEP.Y and sEP.Z. I'm not much of a mathematician so if anyone has the knowledge and time i would be most grateful!! PS: please ignore the dots in front of K1, K5 and Math.Sqrt because they are for aligning ... :) Thanks!!
metalman666
metalman666

I didn't quite understood your question. Weather you are asking how you derive these equations or how you are going to get the values of x,y and z from sEP structure.
u_r_b_a_n
u_r_b_a_n
Sorry, im asking how to derive these equations (i need the equatins for sEP.X, sEP.Y and sEP.Z so i can calculate the coordinates)...

I tried to solve them (i only got sEP.Y from the first equation) but the equations get pretty long and i'm sure i'm not calculating right ...

So again, any help from mathematicians would be apretiated.
Zipster
Zipster
I think it would be more helpful if we knew the problem you're trying to solve -- the source of these equations -- rather than the equations themselves.
Drew_Benton
Drew_Benton
You are just solving a system of 3 equations. It should just be tedious work. If you start with aCosVF and are solving for sEP.X,
1..............K1 * (sEP.X - K2) + K3 * (sEP.X - K2)aCosVF = ----------------------------------------------------------------- ,.............Math.Sqrt(number) * Math.Sqrt( (sEP.X - K2)^2 + (sEP.Y - K4)^2 ) 2.Math.Sqrt(number) * Math.Sqrt( (sEP.X - K2)^2 + (sEP.Y - K4)^2 ) * aCosVF = K1 * (sEP.X - K2) + K3 * (sEP.X - K2)3.(Math.Sqrt(number) * Math.Sqrt( (sEP.X - K2)^2 + (sEP.Y - K4)^2 ) * aCosVF) - (K1 * (sEP.X - K2)) = K3 * (sEP.X - K2)4.((Math.Sqrt(number) * Math.Sqrt( (sEP.X - K2)^2 + (sEP.Y - K4)^2 ) * aCosVF) - (K1 * (sEP.X - K2))) / K3 = (sEP.X - K2)5.(((Math.Sqrt(number) * Math.Sqrt( (sEP.X - K2)^2 + (sEP.Y - K4)^2 ) * aCosVF) - (K1 * (sEP.X - K2))) / K3) + K2 = sEP.X


Now you have an equation for sEP.X, so you throw that nonsense into either the aCosVS or aCosH and solve for sEP.Y or sEP.Z. Once you have that done, you have to do it again for the last value and you will be left with a physical value for the sEP value. Then, you plug in that solved value and solve for another sEP value, and finally solve for the last sEP value.

Your problem is a complicated form of: x + y + z = c and you are given the 3 systems that bound the solution, i.e. just a random system x + y + 5 = z, y * y = z + x + 2, z = x ^ y

Like I said, it'll be long and tedious, but you just churn through it. Look for simplifications where you can to make it more easier to manage.

Just my take on this post [wink]
u_r_b_a_n
u_r_b_a_n
drew_benton i know what i must do ... but you didn't simplify the first equation as it could be... :)

I've done some calculating and from the first equation i exposed sEP.Y (i'll write only Y) and got the following:

Y = K2 + (X - K2)* Math.Sqrt( ( (K1+K3)^2 / acosVF^2*const ) - 1)

where Y = sEP.Y and X = sEP.X.

I'm pretty sure that's right...


...now i must do the same for third equation and then but it all together in second one, but im having problems with third equation, so i'll write it again for some mathematician out there to solve it :)

Here it is:

acosH = K1 * (X - K2) + K8 * (Z - K7) / Math.Sqrt(number) * Math.Sqrt( (X - K2)^2 + (Z - K7)^2 )

I must expose Z so i can calculate the sistem! All other numbers (except X) are given... Any help would be apretiated. Thanks.
Lord Crc
Lord Crc
Unless I did something wrong, you end up with a system on the form of

Au^2 + Buw + Cu^2 = 0

where u = sEP.X - K2 and w = sEP.Z - K7, and A, B and C are constants derived from your constants. That formula describes an ellipse, so afaik you have any number of solutions, each one lying on the ellipse described by the formula above.

Then again, I might have screwed up along the way :)
u_r_b_a_n
u_r_b_a_n
Quote:
Original post by Lord Crc
Unless I did something wrong, you end up with a system on the form of

Au^2 + Buw + Cu^2 = 0

where u = sEP.X - K2 and w = sEP.Z - K7, and A, B and C are constants derived from your constants. That formula describes an ellipse, so afaik you have any number of solutions, each one lying on the ellipse described by the formula above.

Then again, I might have screwed up along the way :)


Hmm, it would be nice if you wrote what constants A,B and C represent, because i really don't know how u came up with this formula ... :)
Lord Crc
Lord Crc
I'll write it down, however are you sure the numerator of the first equation shouldn't read "K1 * (sEP.X - K2) + K3 * (sEP.Y - K4)"? The other equations are on this form.

edit: I've put up a pdf with the steps here, since it would be too much of a pain to write it down in ascii.

edit2: I did this in a hurry so it's quite possible I made some mistakes along the way :)

[Edited by - Lord Crc on September 30, 2008 1:49:31 PM]
u_r_b_a_n
u_r_b_a_n
Hey! The first equation is right as it is...

Thanks a loot for your help!!

I'll go through your formulas and see if i can make anything out of them :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.