Does someone have Matlab or Maple and mind crunching some numbers

Started by
15 comments, last by mumpo 16 years, 1 month ago
Quote:Let me know if you want me to try something else, instead.

Okay try a taylor series using power of degree 9 for sine and degree 8 for cosine

cos(x) = 1 - x^2/2 + x^4/24 - x^6/720 + x^8/40320
sin(x) = x - x^3/6 + x^5/120 - x^7/5040 + x^9/362880

I'm not sure what the hangup is. If it's the sin or cosine the sqrt might be able to work with those substitutions.

daftasbrush, I'm looking for an approximation or anything that I can use to find the arclength of that moving vertex. A vertex will never rotate more than 180 degrees in a timestep so I picked those two equations above.

(I don't need to solve for t, not sure what I was thinking. Been writing up the algorithms for a unit test. Non-rotating seems to be fine.)
Advertisement
I guess it depends on how "approximate" you want your approximation to be,

The "Analytical" Integral (in my post above), will likely yield results accurate to the precision of whatever float type you are using.. even though it's "strictly" an approximation.

But providing you remain within your stated limits : d(Theta) < pi
Numerical Integration of the equation I gave
Quote:a = Vl^2 + Vr^2
b = 2.Vl.Vr
c = polygon1RotInit - ALV
f = polygon1RotRate
V(t) = sqrt(a + b*cos(c + f*t))

even using something as simple as Simpsons rule will likely give less than 0.5% error, in all but the most "extreme" cases.

Those "extreme" cases being.. Vr ~ Vl and d(theta) > pi/2

In those cases you could test whether (c + ft) spans pi.
If it does, then breaking the numerical integration into 2..
t=starttime to t(c+ft = pi) and t(c+ft= pi) to t = endtime
should improve things greatly.

As I said before, which method you choose depends how accurate you want it to be.
Well I want accuracy over speed with this physics simulation. The idea behind the arclength is that I'd be using it to determine a per vertex accuracy value. So basically it has to be fairly accurate in order for the simulation to run well.

I'm not sure if I understand what your saying 100%. When you say using simpson's rule are you suggesting that I iterate and calculate the distance at intervals? I'm looking for one equation that when given the values will give an approximation for t. I'd rather not do any numerical approximation to get this value. But if it comes down to it I'll have to.

It seems like these equations are very difficult to work with. I mean I tried last week to find out if it was possible to get an approximation of the time t when a rotating and moving vertex hit a line segment but the equations were unsolvable (even with approximations). I'm gonna talk to my math professor to see if he has any other ideas though.
Quote:I'm looking for one equation that when given the values will give an approximation for t.

That's what the Analytical Integral is!

If you calculate the following values... (per my previous post)
a = Vl^2 + Vr^2
b = 2.Vl.Vr
c = polygon1RotInit - ALV
f = polygon1RotRate

Then, like any normal integral, evaluate this function for t = starttime and t = endtime.
                                         c + f t   2 b(2 Sqrt[a + b Cos[c + f t]] *  EllipticE[-------, -----])                                             2     a + b /          a + b Cos[c + f t]  (f Sqrt[------------------])                a + b


Subtract the 2 results and you've got the arc length.

You'll just need to get hold of a function to calculate EllipticE.
Like I said there's a MatLab one available for download under GNU License, there are probably others out there.
Once you've got it, just treat it like any other "black box" function like sin, cos, sqrt etc.

That'll get you the most accurate answers, and shouldn't take much time to compute.
I seem to be having a problem finding this EllipticE matlab program online. Is it on their site? I thought maybe it was the symbolic math toolbox but that requires a license. Hmm.

//edit, yeah I can't seem to find the equation. And this is the second kind right?
I found this link talking about them, but not much else. http://reference.wolfram.com/mathematica/ref/EllipticE.html

[Edited by - Sirisian on March 22, 2008 11:05:01 PM]
The MatLab one i'd found turns out to be written in (for) MatLab, so probably won't be very useful to you. but here's the link anyway.
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8805&objectType=file
Quote:And this is the second kind right?
Yup, strictly the Incomplete Elliptic Integral of the Second Kind.

Your best bet is probably Stephen Moshier's Cephes Library.
http://www.moshier.net/
The whole package is available for download, cephes28.zip
but you pretty much just need the ellie.c file.

There's serveral versions of the file in the package, for different precisions
Single, double, Ldouble etc... take your pick.

His "license" statement is a bit wooly... (see the readme in the zip file)
but it includes the line...
Quote:What you see here may be used freely but it comes with no support or guarantee.


I've seen the library billed as "Free" .. somewhere..
And it's used by several other packages (Grace, Labplot) which are themselves under GPL.

I you feel you need futher clarification on useage / licensing..
shoot the guy an email.

[Edited by - daftasbrush on March 23, 2008 8:12:31 AM]
Quote:Original post by Sirisian
Quote:Let me know if you want me to try something else, instead.

Okay try a taylor series using power of degree 9 for sine and degree 8 for cosine

cos(x) = 1 - x^2/2 + x^4/24 - x^6/720 + x^8/40320
sin(x) = x - x^3/6 + x^5/120 - x^7/5040 + x^9/362880

I'm not sure what the hangup is. If it's the sin or cosine the sqrt might be able to work with those substitutions.

daftasbrush, I'm looking for an approximation or anything that I can use to find the arclength of that moving vertex. A vertex will never rotate more than 180 degrees in a timestep so I picked those two equations above.

(I don't need to solve for t, not sure what I was thinking. Been writing up the algorithms for a unit test. Non-rotating seems to be fine.)

I ran it with the taylor series approximations. Mathematica finished thinking after a while with those, but it was unable to actually solve the integral. I suggest you focus on the method daftasbrush was kind enough to work out for you. I'll keep an eye on this thread for a bit longer, though, if you have any more ideas.

This topic is closed to new replies.

Advertisement