I Made an Equation but I Cannot Solve It

Started by
23 comments, last by Fenrisulvur 13 years, 4 months ago
@johnstanp: I may still have been posting / editing, since I only realised afterwards.

@BrotherBob: Ah, yeah. :)
Advertisement
Well it is past midnight here and I have already had a few drinks so I am not in any state to analyse the math in detail now, but a few things I can see that I want to question or clarify.

#1:
Quote:Original post by johnstanp
The equation should actually be:
length²((Tp+Tvt+½×Tat²)-Bp) = (Bs*t)²

Is this the same as length²((Tp+Tvt+½×Tat²)-Bp)-(Bst*Bst) = 0, or did I miss a detail?
I originally started with your form (well almost) but my basic knowledge of math lead me to put all of the terms on the left side and 0 on the right, but I may be wrong in doing so. Or I missed something you changed.

#2:
Quote:Original post by sprite_hound
t^2(Ta / 2) + t(Tv-Bs) + Tp - Bp = 0

So this is the fully simplified version of the whole thing?
After confirmation, I was originally going to say that I wanted to wait until I had a clear head to try to visualize this model in my head and see if it models exactly what my original concept was (which I will explain in the article if you haven’t seen how it is meant to work yet (actually I will explain it in the article even if you have)) and see if I could solve for t on my own from there.
But two things:
- A: (Tv-Bs). How does that work? Tv is a 3D vector and Bs is a single scalar. I could do a component-wise subtraction, but I want to verify—is this really what you meant? “Target Velocity” Tv and “Bullet Speed” Bs may have been cause for confusion; if you treat these both as 3D vectors I can see how you would reach this conclusion, but since one of them is actually scalar I want to be sure this is not a conclusion reached in confusion.
- B: For the article, I want to explain what the purpose of each step is, just like in “Real-Time Collision Detection” by Christer Ericson. Can you include a comment that just says what each step is doing? Of course I am not going to try to sound like a bad-ass in the article who knows how to solve these kinds of equations; I will make it clear that I myself am not mathematically inclined enough to solve these kinds of equations and that I relied on a named 3rd party.


Thank you,
L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

I've solved something similar to this before, and yes, it is a 4th order polynomial. There are a number of ways to solve it, but all the ones I used involve some kind of iterative relaxation (like newtons method and other solutions).

However, a google search reveals the following:

http://en.wikipedia.org/wiki/Quartic_function#The_general_case.2C_along_Ferrari.27s_lines

So there's that. Good luck.
Quote:Original post by sprite_hound
Hmm. I get a second order polynomial, but I could well be going wrong somewhere:
Tp^2 - Bp^2 + t^2(Tv^2-Bs^2) + t^4(Ta^2 / 4) = 0t^2(Ta / 2) + t(Tv-Bs) + Tp - Bp = 0



I'm pretty sure this step is invalid. Unless I'm mistaken, there is no proof that the roots of (a^2 t^4+b^2 t^2+c^2) are the same as the roots of (a t^2 + b t + c)


Sorry to post so many times... One thing I wanted to mention: Guess and check is a pretty terrible "iterative solution." If you want to solve this, there's no reason an iterative solver has to be slow. Hell, most matrix decompositions are "iterative" and yet you can find a solution for a smallish matrix in very very short time because the algorithms are well understood and well optimized.

Now that you have the closed form, try implementing a real iterative root finder for a 4th order polynomial and I imagine the speed will be MUCH greater then whatever you are currently doing, despite the fact that its not a closed form solution.

Quote:
#2:
- A: (Tv-Bs). How does that work? Tv is a 3D vector and Bs is a single scalar. I could do a component-wise subtraction, but I want to verify—is this really what you meant? “Target Velocity” Tv and “Bullet Speed” Bs may have been cause for confusion; if you treat these both as 3D vectors I can see how you would reach this conclusion, but since one of them is actually scalar I want to be sure this is not a conclusion reached in confusion.


Yeah, I was assuming it was a 3d vector. I actually now think my whole working is very wrong due to forgetting how to multiply out brackets. [embarrass]

[Edited by - sprite_hound on November 15, 2010 1:35:51 PM]
Quote:Original post by YogurtEmperor
Is this the same as length²((Tp+Tvt+½×Tat²)-Bp)-(Bst*Bst) = 0, or did I miss a detail?


f²(x)-y²=0 is not equivalent to f²(x-y)=0
To prove it: simply take a counter example.

Let's f(x)=x;
x²-y²=0 is equivalent to (x-y)²=0?
The solutions of x²-y²=0 are x=y or x=-y
The unique solution of (x-y)²=0 is x=y.
So, the answer is "no".

It is not forbidden to do the following:
A := complex expression
B := another complex expression

A²-B²=0 <=> (A-B)(A+B)=0 <=> A=B OR A=-B
so lenth²(X) = Y² is equivalent to (length(X)-Y)(length(X)+Y)=0
But length(X) involves a square root. So it's easier working with length²(X)-Y²=0. But it introduces a solution that will have to be rejected when Y!=0 since length(X) cannot be negative.

As already said, you should have a 4th order polynomial at the left side (or whatever side you chose to put all the non zero terms) when developing your equation. There is an analytical solution to such a problem: actually there are analytical solutions up to the fourth order if I remember well.
A link:
Quartic_function

Good work! :-)

[Edited by - johnstanp on November 15, 2010 1:13:45 PM]
I found this link:

http://mathworld.wolfram.com/QuarticEquation.html

but currently I have no time to solve it, maybe tonight, if no one else has by then.
Quote:Original post by johnstanp
f²(x)-y²=0 is not equivalent to f²(x-y)=0

I’m not rearranging the terms that way.
length²((Tp+Tvt+½×Tat²)-Bp) = Bst² // If these two terms are equal (this is the form you said the equation should be), thenlength²((Tp+Tvt+½×Tat²)-Bp)-Bst² = 0 // Subtracting them results in 0.

I do not know enough about Algebra II to know why you put x and y together when you moved the y term to the left. From my primitive understanding, I am not doing this.




I do understand the Newton–Raphson method; I have used it before.
If I could rewrite this so that the Newton–Raphson method could be used here, yes, that would be a much faster iterative method. And even acceptable in terms of performance I think.
But I don’t know how to get the equation there, and frankly I am not sure I could solve it even in the form of a Quartic function; as for that, I will see once it gets into that form. I want to give it a shot for the challenge, but I will not hold a grudge if someone shows the solution all the way down to “t = blah blah blah”.
If multiple solutions are posted (Newton–Raphson method and the Quartic function) I will post both methods in the article and give credits to both people.


Regards,
L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Length ^ 2 ( Tp + (Tv * t) + ((1 / 2) * Ta * (t ^ 2)) - Bp) - (Bs^2 * (t ^ 2)) = 0
-------------------------------
(Tpx + (Tvx * t) + ((1/2) * Tax * t^2) - Bpx) ^ 2 + (Tpy + (Tvy * t) + ((1/2) * Tay * t^2) - Bpy) ^ 2 + (Tpz + (Tvz * t) + ((1/2) * Taz * t^2) - Bpz) ^ 2 - (Bs^2 * t^2) = 0
-------------------------------
Tpx^2 + (Tvx^2 * t^2) + ((1/4) * Tax^2 * t^4) - Bpx^2 + (2 * Tpx * Tvx * t) + (Tpx * Tax * t^2) - (2 * Tpx * Bpx) + (Tvx * Tax * t^3) - (2 * Tvx * Bpx * t) - (Tax * Bpx * t^2) +
Tpy^2 + (Tvy^2 * t^2) + ((1/4) * Tay^2 * t^4) - Bpy^2 + (2 * Tpy * Tvy * t) + (Tpy * Tay * t^2) - (2 * Tpy * Bpy) + (Tvy * Tay * t^3) - (2 * Tvy * Bpy * t) - (Tay * Bpy * t^2) +
Tpz^2 + (Tvz^2 * t^2) + ((1/4) * Taz^2 * t^4) - Bpz^2 + (2 * Tpz * Tvz * t) + (Tpz * Taz * t^2) - (2 * Tpz * Bpz) + (Tvz * Taz * t^3) - (2 * Tvz * Bpz * t) - (Taz * Bpz * t^2)
- (Bs^2 * t^2) = 0

-------------------------------

((1/4) * (Tax^2 + Tay^2 + Taz^2) * t^4) +
(((Tvx * Tax) + (Tvy * Tay) + (Tvz * Taz)) * t^3) +
((Tvx^2 + Tvy^2 + Tvz^2 + (Tpx * Tax) + (Tpy * Tay) + (Tpz * Taz) - (Tax * Bpx) - (Tay * Bpy) - (Taz * Bpz) - Bs^2) * t^2) +
(2 * ((Tpx * Tvx) + (Tpy * Tvy) + (Tpz * Tvz) - (Tvx * Bpx) - (Tvy * Bpy) - (Tvz * Bpz)) * t) +
Tpx^2 + Tpy^2 + Tpz^2 - Bpx^2 - Bpy^2 - Bpz^2 - (2 * ((Tpx * Bpx) + (Tpy * Bpy) + (Tpz * Bpz)))
= 0
-------------------------------

Wich is of the form

A * t^4 + B * t^3 + C * t^2 + D * t + F = 0 (1)
(using F instead of E on porpuese just to avoid getting it confused with Euler's number)

Having:
A = (1/4) * (Tax^2 + Tay^2 + Taz^2)
B = (Tvx * Tax) + (Tvy * tay) + (Tvz * Taz)
C = Tvx^2 + Tvy^2 + Tvz^2 + (Tpx * Tax) + (Tpy * Tay) + (Tpz * Taz) - (Tax * Bpx) - (Tay * Bpy) - (Taz * Bpz) - Bs^2
D = 2 * ((Tpx * Tvx) + (Tpy * Tvy) + (Tpz * Tvz) - (Tvx * Bpx) - (Tvy * Bpy) - (Tvz * Bpz))
F = Tpx^2 + Tpy^2 + Tpz^2 - Bpx^2 - Bpy^2 - Bpz^2 - (2 * ((Tpx * Bpx) + (Tpy * Bpy) + (Tpz * Bpz)))

Now I put the equation (1) on an oline solver in:
http://www.quickmath.com/webMathematica3/quickmath/page.jsp?s1=equations&s2=solve&s3=basic

and solved it for t, but the results are just obscene. You'll have to replace and maybe simplify if possible. I have no time to that now. You'll have to take wathever result is real and positive, if none is then the bullet can't reach the target.

This topic is closed to new replies.

Advertisement