Does someone have Matlab or Maple and mind crunching some numbers
(sorry if this is in the wrong place, not sure if the math forum allows this. I'm desperate)
Okay I have a parametric equation.
X = Cos(polygon1RotRate * t + polygon1RotInit) * vertexX - Sin(polygon1RotRate * t + polygon1RotInit) * vertexY + (polygon1VelX - polygon2VelX) * t + polygon1X
Y = Sin(polygon1RotRate * t + polygon1RotInit) * vertexX + Cos(polygon1RotRate * t + polygon1RotInit) * vertexY + (polygon1VelY - polygon2VelY) * t + polygon1Y
integrate(sqrt(derivate(X,t)^2 + derivate(Y,t)^2),t);
That is the arc length that I need. Only problem and anyone trying to do this will realize it. It will take a lot of time (a few hours or a day) to do and a lot of file paging (so increase file paging to the max if attempting). I would do it myself but when trying to use my companies matlab discs I realized they were scratched by whoever used them last.
If someone that has a beefy computer and doesn't mind letting it run for a long time processing this I'd be very grateful. (it's for a small physics demo I'm coding and this is a key equation I need).
I'm taking a crack at it in Mathematica 5.2 right now. I have 4 GB of RAM and am running 64-bit Vista, so hopefully my system won't have any memory problems. My processor is a relatively tame 2.13 GHz Core 2 Duo, so who knows how long it will take. . . I'll let you know if it ever finishes (no guarantees).
I may be missing something but this looks like it can be done analytically, at least part of the way.
I'm going to restate variables to make me able to see what's going on so
polygonnVelX/Y => vX/Yn
polygon1X/Y => sX/Y
polygon1RotRate => r
polygon1RotInit => r0
vertexX => x
vertexY => y
So
X = x cos(rt+r0) - y sin(rt+r0) + t(vX1-vX2) + sX
Y = x sin(rt+r0) + y cos(rt+r0) + t(vY1-vY2) + sY
Assuming all the terms are not variant in t
dX/dt = xr sin (rt+r0) + yr cos(rt+r0) + (vX1-vX2)
dY/dt = xr cos (rt+r0) + yr sin(rt+r0) + (vY1-vY2)
Just setting R = rt+r0
and ∆vX/Y = (vX/Y1-vX/Y2) for ease of typing:
(dX/dt)² = x²r²sin²R + y²r²cos²R + ∆vX² + 2[xyr²cos R sin R+yr∆vX cos R+xr∆vXsin R]
and similarly for Y
(dY/dt)² = x²r²cos²R + y²r²sin²R + ∆vY² + 2[xyr²cos R sin R+yr∆vY sin R+xr∆vYcos R]
=> (dX/dt)²+(dY/dt)² =
x²r²(sin²R+cos²R) + y²r²(sin²R+cos²R) + ∆vY² + ∆vX² + 2[xyr²cos R sin R+yr∆vX cos R+xr∆vXsin R+xyr²cos R sin R+yr∆vY sin R+cos R]
= r²(x²+y²) + ∆vY² + ∆vX² + 2r cos R[y∆vX + x∆vY] + 2r sin R[x∆vX + y∆vY] + 2xyr²cos R sin R
As R there is the only thing that depends on t, you can park [r²(x²+y²) + ∆vY² + ∆vX²] in a constant (A) and you get
= A + 2r(cos R[y∆vX + x∆vY] + sin R[x∆vX + y∆vY] + xyr cos R sin R)
Hmm, okay, it looks like that as far as you go analytically, unless I'm missing things. However it shouldn't take that long to integrate that numerically?
Of course if other parts depend on T then I just wasted 10 minutes <.<
I'm going to restate variables to make me able to see what's going on so
polygonnVelX/Y => vX/Yn
polygon1X/Y => sX/Y
polygon1RotRate => r
polygon1RotInit => r0
vertexX => x
vertexY => y
So
X = x cos(rt+r0) - y sin(rt+r0) + t(vX1-vX2) + sX
Y = x sin(rt+r0) + y cos(rt+r0) + t(vY1-vY2) + sY
Assuming all the terms are not variant in t
dX/dt = xr sin (rt+r0) + yr cos(rt+r0) + (vX1-vX2)
dY/dt = xr cos (rt+r0) + yr sin(rt+r0) + (vY1-vY2)
Just setting R = rt+r0
and ∆vX/Y = (vX/Y1-vX/Y2) for ease of typing:
(dX/dt)² = x²r²sin²R + y²r²cos²R + ∆vX² + 2[xyr²cos R sin R+yr∆vX cos R+xr∆vXsin R]
and similarly for Y
(dY/dt)² = x²r²cos²R + y²r²sin²R + ∆vY² + 2[xyr²cos R sin R+yr∆vY sin R+xr∆vYcos R]
=> (dX/dt)²+(dY/dt)² =
x²r²(sin²R+cos²R) + y²r²(sin²R+cos²R) + ∆vY² + ∆vX² + 2[xyr²cos R sin R+yr∆vX cos R+xr∆vXsin R+xyr²cos R sin R+yr∆vY sin R+cos R]
= r²(x²+y²) + ∆vY² + ∆vX² + 2r cos R[y∆vX + x∆vY] + 2r sin R[x∆vX + y∆vY] + 2xyr²cos R sin R
As R there is the only thing that depends on t, you can park [r²(x²+y²) + ∆vY² + ∆vX²] in a constant (A) and you get
= A + 2r(cos R[y∆vX + x∆vY] + sin R[x∆vX + y∆vY] + xyr cos R sin R)
Hmm, okay, it looks like that as far as you go analytically, unless I'm missing things. However it shouldn't take that long to integrate that numerically?
Of course if other parts depend on T then I just wasted 10 minutes <.<
Thanks for trying it mumpo. I had someone else that started doing it yesterday but had to stop it after 50 minutes because he had something to do. That's the only reason I know that it will take a long time.
And yes, Bob Janova, I too thought I could do it by hand but a computer has a much higher chance of telling if it is possible.
And yes, Bob Janova, I too thought I could do it by hand but a computer has a much higher chance of telling if it is possible.
I entered (-Sin[w x+p]*w*p1-Cos[w x+p]*w*p2+v1)^2+(Cos[w x+p]*w*p1-Sin[w x+p]*w*p2+v2)^2 into http://integrals.wolfram.com/index.jsp and out came a formula. You should be able to use that.
EDIT: Ooops! Nevermind. I forgot the Sqrt[]. It doesn't work once you add it.
EDIT: Ooops! Nevermind. I forgot the Sqrt[]. It doesn't work once you add it.
Just a quick update -- my computer is still at it. Mathematica is using about 800 MB now. I wonder if the computer can actually solve it, or if it is just going ever deeper into some infinitely recursive algorithm? Either way, I'll try to give it at least a couple more days before I give up on it.
Quote:Original post by mumpo
Just a quick update -- my computer is still at it. Mathematica is using about 800 MB now. I wonder if the computer can actually solve it, or if it is just going ever deeper into some infinitely recursive algorithm? Either way, I'll try to give it at least a couple more days before I give up on it.
Thanks :) I can't tell you how much this is going to help me if this works. If not then substituting sine and cosine with a taylor series or something will be my next guess and just solve on a range. If it's the sin and cos that actually cause the problem.
I'm gonna find out next Tuesday where my university's cluster server is. I heard they use it for astronomy, maybe I can get someone to plug in equations.
I might not have made this clear. After finding the arc length (if it exists) I need to solve it for t. So that given an arc length it returns the t value associated with that length.
From My Understanding...I don't think there's definitive Analytical solution.
MatLab (or whatever) may kick out a formula which will initially appear to be "analytical" but I reckon it's going to contain a "numerical approximation" component....
Here's how I arrived at this conclusion...
Assuming the same as Bob ... that most everything is constant wrt t
Your problem boils down to a point rotating about a centre, and that centre is moving.
Ultimately you are trying to compute s = integral(V(t) dt)
It seems to me that you can find V(t) much more simply if you don't "decompose" everything into 2 independant cartesian axes, but consider the problem "as a whole".
Consider the 2 motion components (Rotational and Linear) as vectors, and simply add them and determine the length of the result.
The point is rotating at a constant (angular) rate...
it's distance from the "centre" r = sqrt(VertexX^2 + VertexY^2)
so it's rotational speed Vr = r * polygon1RotRate
(assuming polygon1RotRate in radians per "Unit Time")
It's Linear Velocity Vl = sqrt((polygon1VelX - polygon2VelX)^2 + (polygon1VelY - polygon2VelY)^2))
Now all you need is "Cosine rule" to determine the actual speed.
Theta = Angle between rotational and linear velocity
= polygon1RotRate * t + polygon1RotInit - "Angle of Linear Velocity" (ALV)
Simplifying for clarity :
a = Vl^2 + Vr^2
b = 2.Vl.Vr
c = polygon1RotInit - ALV
f = polygon1RotRate
we get V(t) = sqrt(a + b*cos(c + f*t))
Now if you drop that into the Wolfram Web Integrator you get.... a result.
I imagine Matlab will give a similar result (eventually...)
But the (one?) problem is.... The Elliptic Integral
Not (I think) a coincidence it's come up for this problem...
As I understand them (admittedly in limited fashion, so I'm not 100% on this bit), there is no exact analytical way to evaluate an elliptic integral, it has to be done numerically or by approximation (there are a few different methods)....
But either way... it doesn't look like you can get an exact answer.
So the question is....
How accurate vs complex do you want it to be....
As I see it, you could...
i) Do the original integration numerically. (using whatever method)
or
ii)Use the "analytical" integral above.. that includes a numerical integration or an approximation.
I can't say which would be more accurate....
On a happy Note:
MatLab has a function for 2nd form elliptic integrals under GNU license... might make things a bit easier!?
HTH
[Edited by - daftasbrush on March 21, 2008 1:05:49 PM]
MatLab (or whatever) may kick out a formula which will initially appear to be "analytical" but I reckon it's going to contain a "numerical approximation" component....
Here's how I arrived at this conclusion...
Assuming the same as Bob ... that most everything is constant wrt t
Your problem boils down to a point rotating about a centre, and that centre is moving.
Ultimately you are trying to compute s = integral(V(t) dt)
It seems to me that you can find V(t) much more simply if you don't "decompose" everything into 2 independant cartesian axes, but consider the problem "as a whole".
Consider the 2 motion components (Rotational and Linear) as vectors, and simply add them and determine the length of the result.
The point is rotating at a constant (angular) rate...
it's distance from the "centre" r = sqrt(VertexX^2 + VertexY^2)
so it's rotational speed Vr = r * polygon1RotRate
(assuming polygon1RotRate in radians per "Unit Time")
It's Linear Velocity Vl = sqrt((polygon1VelX - polygon2VelX)^2 + (polygon1VelY - polygon2VelY)^2))
Now all you need is "Cosine rule" to determine the actual speed.
V(Theta)^2 = Vl^2 + Vr^2 + 2.Vl.Vr.cos(Theta) so V(Theta) = sqrt(Vl^2 + Vr^2 + 2.Vl.Vr.cos(Theta))
Theta = Angle between rotational and linear velocity
= polygon1RotRate * t + polygon1RotInit - "Angle of Linear Velocity" (ALV)
Simplifying for clarity :
a = Vl^2 + Vr^2
b = 2.Vl.Vr
c = polygon1RotInit - ALV
f = polygon1RotRate
we get V(t) = sqrt(a + b*cos(c + f*t))
Now if you drop that into the Wolfram Web Integrator you get.... a result.
I imagine Matlab will give a similar result (eventually...)
(2 Sqrt[a + b Cos[c + f t]] * c + f t 2 b EllipticE[-------, -----]) / 2 a + b a + b Cos[c + f t] (f Sqrt[------------------]) a + b
But the (one?) problem is.... The Elliptic Integral
Quote:From Wiki - "elliptic integrals originally arose in connection with the problem of giving the arc length of an ellipse."
Not (I think) a coincidence it's come up for this problem...
As I understand them (admittedly in limited fashion, so I'm not 100% on this bit), there is no exact analytical way to evaluate an elliptic integral, it has to be done numerically or by approximation (there are a few different methods)....
But either way... it doesn't look like you can get an exact answer.
So the question is....
How accurate vs complex do you want it to be....
As I see it, you could...
i) Do the original integration numerically. (using whatever method)
or
ii)Use the "analytical" integral above.. that includes a numerical integration or an approximation.
I can't say which would be more accurate....
On a happy Note:
MatLab has a function for 2nd form elliptic integrals under GNU license... might make things a bit easier!?
HTH
[Edited by - daftasbrush on March 21, 2008 1:05:49 PM]
Quote:Original post by SirisianQuote:Original post by mumpo
Just a quick update -- my computer is still at it. Mathematica is using about 800 MB now. I wonder if the computer can actually solve it, or if it is just going ever deeper into some infinitely recursive algorithm? Either way, I'll try to give it at least a couple more days before I give up on it.
Thanks :) I can't tell you how much this is going to help me if this works. If not then substituting sine and cosine with a taylor series or something will be my next guess and just solve on a range. If it's the sin and cos that actually cause the problem.
You're welcome :) . I'm not very optimistic about the current calculation ever finishing, though; I can't imagine why it would need so much memory to solve a relatively concise symbolic problem unless the answer has an infinite number of terms or it just can't do it, but won't admit it. Let me know if you want me to try something else, instead.
Quote:I'm gonna find out next Tuesday where my university's cluster server is. I heard they use it for astronomy, maybe I can get someone to plug in equations.
I might not have made this clear. After finding the arc length (if it exists) I need to solve it for t. So that given an arc length it returns the t value associated with that length.
My calculus is quite rusty, and I never took all that much of it to begin with, but it seems to me that if my computer ever comes up with a sensible result for that integral, solving it for t shouldn't take too long.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement