1
ie. [ sqrt( (X't)^2 + (Y't)^2 ) ]
0
I started doing so but for some reason ended up with X't squared being a bitch to write down (got 25 or so terms).
The question is: how long will this curve be?
EDIT: "line" changed to "curve"
[edited by - Kurioes on May 16, 2003 8:33:26 AM]
Length of bezier-like line
In my game, I want to create fragmentation bombs which divide in 8-16 parts. Those "particles" should, on separation, pick a target and home in on it. For this, I want to use some kind of interpolation, namely:
vector A is the start location of the particle
vector B is another point (straight "ahead")
vector C is the target
I want to interpolate them like so:
Pt = A*t*t + 2*B*t*(1-t) + C*(1-t)*(1-t)
*note that with vectors I actually mean poins, which are not the same but could be abused to serve the same purpose...
For determining the speed of the particle I need to know how long the resulting curve is (I adjust the rate in which t is increased to change the speed). I don't want the particles to all reacht the target in the same time regardless of how long their path is.
Now I *could* use some approximation but I'm curious as to how to calculate it exactly. I figured as much as:
- Calculate dx/dt and dy/dt for both axes
- square them both
- take square root of sum
- integrate that
x''(t) should only be nine terms, if you''re using a cubic spline. There might not be a closed form solution for the arclength of a cubic parametric curve. There should be... I will check it out in mathematica, and I''ll get back to you later.
You know what I never noticed before?
Thank you!
What I did was
x(t) = att + 2bt(1-t) + c(1-t)(1-t)
= at^2 + 2bt - 2bt^2 + ct^2 - 2ct + 1
and thus x''(t) = 2at + 2b - 4bt + 2ct - 2c
This means x''(t) squared will be 25 terms (at most i.e. things like 3c + 5c = 8c should cut that down to 15? or something)
After that I need to add two of those (a = vector A.x, b = Vector B.x and so on), being one for each axis (2D space), and integrate the square root of that. I think.
I should probably try to do so but my math''s not good enough for this.
What I did was
x(t) = att + 2bt(1-t) + c(1-t)(1-t)
= at^2 + 2bt - 2bt^2 + ct^2 - 2ct + 1
and thus x''(t) = 2at + 2b - 4bt + 2ct - 2c
This means x''(t) squared will be 25 terms (at most i.e. things like 3c + 5c = 8c should cut that down to 15? or something)
After that I need to add two of those (a = vector A.x, b = Vector B.x and so on), being one for each axis (2D space), and integrate the square root of that. I think.
I should probably try to do so but my math''s not good enough for this.
Since the calulus is with respect to t, and the equation in t is second order, there are only three terms, so its really like this:
x(t) = att + 2bt(1-t) + c(1-t)(1-t)
= at^2 + 2bt - 2bt^2 + ct^2 - 2ct + 1
= (a-2b+c)*t^2 + (2b-2c)*t + 1
like you suspected. That is technically the same as what you had, but grouping in terms of t simplifies the calculus. The derivative is linear, so x''^2 is quadratic in t, and I think that there is always a solution to the integral of a square root of a quadratic expression. What you should do is rewrite all the stuff under the radical as a quadratic expression in t, which should be easy, and then it will be integrable.
int( sqrt(att+bt+c) , t)=
((4ac-bb)*ln(2*sqrt(aatt+abt+ac)+2at+b))/(8a^(3/2))+
((2at+b)*sqrt(at^2+bt+c))/(4a)
It''s not pretty, but it''s closed form.
x(t) = att + 2bt(1-t) + c(1-t)(1-t)
= at^2 + 2bt - 2bt^2 + ct^2 - 2ct + 1
= (a-2b+c)*t^2 + (2b-2c)*t + 1
like you suspected. That is technically the same as what you had, but grouping in terms of t simplifies the calculus. The derivative is linear, so x''^2 is quadratic in t, and I think that there is always a solution to the integral of a square root of a quadratic expression. What you should do is rewrite all the stuff under the radical as a quadratic expression in t, which should be easy, and then it will be integrable.
int( sqrt(att+bt+c) , t)=
((4ac-bb)*ln(2*sqrt(aatt+abt+ac)+2at+b))/(8a^(3/2))+
((2at+b)*sqrt(at^2+bt+c))/(4a)
It''s not pretty, but it''s closed form.
You know what I never noticed before?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement