1
$\begingroup$

I have posted my initial question question "Arc-Length parameterization of a cubic bezier curve" here.

I was a bit confused with the mathematics but now i have understood most of it, only one question remains which i think is better to posted in the Mathematics forums.

The paper i use as a basic, describes the calculation of the Arc-Length of a curve segment as follows: $l_i = \int_{t_i}^{t_{i+1}}\sqrt{(x'(t))^2 + (y'(t))^2 + (z'(t))^2}dt$, where i is the i varies from $0$ to $n-1$ and $n$ is is the number of segments in the curve. Therefore the total Arc-Length of the curve would be $\sum_{i=0}^{n-1}l_1$

Now to calculate that integral and implement it, i found a website which tells me to use the Gauss Quadrature and shows:$\int_{0}^{z}\sqrt{(x'(t))^2 + (y'(t))^2 + (z'(t))^2}dt = \frac{z}{2} [C_1 f(\frac{z}{2} t_1+\frac{z}{2})+\cdots+C_n f(\frac{z}{2} t_n+\frac{z}{2})]$, where z is from $0$ to a value smaller or equal to $1$.

In order to implement it, the second solution seems what want to go for. The problem is it always calculates the Arc-length for $0$ to the time specified in $z$ of the original curve.

My question can i use the second formula or modify it so that i can use $\int_{t_i}^{t_{i+1}}$ where $t_i$ would be the time of a segment point and $t_{i+1}$ the time of the next segment point on the bezier curve.

  • 0
    Does nobody have a answer to that? I'm quite under pressure to solve this problem.2012-10-12

3 Answers 3

2

For a brief answer, put $l_i = \displaystyle \int_{t_i}^{t_{i+1}} \| M'(t)\| \ \mathrm dt$, $L_i = \displaystyle \sum_{k \mathop = 0}^i l_k$. Then you want $l_i$ from the given $L_i$.

One way to do this is via $l_i = L_{i+1} - L_i$.

Maybe the other answer is what you are looking for, but I suspect that you may not want to reparametrise your integral as this does not actually help you calculating the desired quantities from your given primitive.

You could have a look at the Fundamental Theorem of Calculus.

  • 0
    Let me see if I understand your answer. The integral for $l_0$ is already in the needed form. Then, taking $l_1 = \int_0^{t_1} - l_0$, where the integral is in the needed form, etc?2012-10-12
  • 0
    Yes, precisely. The critical fact you use is that $\int_a^b + \int_b^c = \int_a^c$ for any integral (and then subtract $\int_a^b$). I hope it's clear now.2012-10-12
  • 0
    Very nice and simple. +12012-10-12
  • 0
    All I have is the Integral which gives me the Arc-Length from $0$ to some time in the curve $\leq 1$. When i use 1 i get the length of the whole Curve, and that is $L_i$.Now for further calculation i need the especialy the lenght of each segment so i need to be able to calculate the integral from lets say: $0 to 0.2; 0.2 to 0.5, 0.5 to 0.52f ...$ i now that i could calculate the integral $0 to 0.2$ and then $0 to 0.5$ and suptract the first result from it. But since this needs to be calculated in real time is this really the fastest way to solve it.2012-10-12
  • 0
    Alright, is it probably that easy: This website (http://processingjs.nihongoresources.com/bezierinfo/legendre-gauss-values.php) gives me the solution in the second formula and i have completely overlooked it.2012-10-12
  • 0
    If I read correctly the referenced web site, the idea is to approximate the curve by line segments. The other answer seems to be more in line with what you are looking for. I suggest that you read the page and the one it links to thoroughly again.2012-10-12
1

If I understand correctly, you need to send the interval $(t_i,t_{i+1})$ to $(0,z)$ where $0 < z \le 1$. So, basically you need to send the interval to the origin and then rescale it (or viceversa).

Traslating the intervals. The left side of the intervals is $t_i\,$ (assuming $t_i < t_{i+1}$). Taking the change of variables $s = t - t_i$, $$ \int_{t_i}^{t_{i+1}} \|M'(t)\| dt = \int_{0}^{t_{i+1}-t_i} \|M'(s + t_i) \| ds, $$ where $M(t) = \big(x(t),y(t),z(t)\big)$ is your parametrized curve.

Rescaling the intervals. The length of the intervals is $t_{i+1} - t_i$, and you need to rescale it to be $z$. Taking the change of variables $x = \frac{z}{t_{i+1} - t_i}s$, $$ \int_{t_i}^{t_{i+1}} \|M'(t)\| dt = \int_{0}^{t_{i+1}-t_i} \|M'(s + t_i) \| ds = \frac{t_{i+1} - t_i}{z} \int_0^z \big\|M'\big(\tfrac{t_{i+1} - t_i}{z} x + t_i\big) \big\|dx, $$ and you are done.

Note that the last step might not be necessary if $0 < t_1 < \ldots < t_n \le 1$.

1

The Gaussian Quadrature is in the interval [-1,1] and to map any interval [a,b] to that simply use:

$\int_a^bf(x)dx = \frac{b-a}2 \simeq \frac{b-a}{2}[C_1 * f(\frac{b-a}2 * t_1 + \frac{b+a}2) + ... + C_n * f(\frac{b-a}2 * t_n + \frac{b+a}2)]$

Where $C_1 ... C_n$ are the weights and $t_1 ... t_n$ are the abscissae from the those Tables