Logo Xingxin on Bug

Understanding Arc Length Parameterization with 🦏&πŸ¦—

December 31, 2023
10 min read

0. Introduction

In the fields of multivariable calculus and differential geometry, the concept of β€œarc length parameterization” is extremely important. However, for many people, it may seem obscure and difficult to understand at first.

For example, in do Carmo’s Differential Geometry of Curves and Surfaces (Section 1.5), the definition of curvature is closely related to arc length:

Let Ξ±:Iβ†’R3\alpha:I\to\mathbb{R}^3 be a curve parameterized by arc length s∈Is\in I. The number βˆ£Ξ±β€²β€²(s)∣=ΞΊ(s)\lvert \alpha''(s)\rvert=\kappa(s) is called the curvature of Ξ±\alpha at ss.

Similarly, in George Thomas’s Thomas Calculus (Section 13.3), arc length is used as a parameter to describe a curve:

r(s)=cos⁑(s/2)i+sin⁑(s/2)j+(s/2)k\mathbf{r}(s)=\cos(s/\sqrt{2})\mathbf{i}+\sin(s/\sqrt{2})\mathbf{j}+(s/\sqrt{2})\mathbf{k}
… each value of determines a point on CC, and this way of describing CC using ss is what we call an arc length parameter for the curve.

Although this concept may seem complex at first, it is crucial for designing and understanding complex curves and shapes. I will attempt to explain this fascinating concept in a more vivid way using Rhino & Grasshopper.

πŸ“‹1. Prerequisites

To better understand arc length parameterization, we need to review some basic mathematical knowledge:

1.1. Vector-Valued Functions

πŸ“Definition 1: A vector-valued function is simply a function whose domain is a set of real numbers and whose range is a set of vectors. This means that for every number tt in the domain of r\mathbf{r} there is a unique vector in V3V_3 denoted by r(t)\mathbf{r}(t). If f(t),g(t)f(t), g(t) and h(t)h(t) are the components of the vector r(t)\mathbf{r}(t), then f,gf, g, and hh are real-valued functions called the component functions of r\mathbf{r} and we can write r(t)=<f(t),g(t),h(t)>=f(t)i+g(t)j+h(t)k\mathbf{r}(t)=\left< f(t),g(t),h(t)\right>=f(t)\mathbf{i}+g(t)\mathbf{j}+h(t)\mathbf{k}

In simple terms, the distinctive feature of vector-valued functions is:

  • Input is a number
  • Output is a vector (three numbers)

πŸ—ƒExample 1: The simplest vector-valued function is:

r(t)={f(t)=tg(t)=th(t)=t\mathbf{r}(t)= \begin{cases} f(t) &= t \\ g(t) &= t \\ h(t) &= t \\ \end{cases}

In Grasshopper, we can use the β€œπŸ”‹Construct Point” component to represent this. Therefore, when t=13t=13, we have r(13)=[131313]\displaystyle \mathbf{r}(13)=\begin{bmatrix}13\\13\\13\end{bmatrix}.

construct-point-gh-vector-valued-function.png

Note

In mathematics, vectors and points are different concepts. For simplicity, I will not strictly distinguish between them.

πŸ—ƒExample 2: Let’s look at a slightly more complex example: a helix can be expressed using a vector-valued function.

helix-thomas-calculus.png (©️Thomas’ Calculus)

Similarly, it can be expressed in the system of linear equations:

x=cos⁑ty=sin⁑tz=t\begin{align} x &= \cos t \\ y &= \sin t \\ z &= t \\ \end{align}

We can use the β€œπŸ”‹Construct Point” component to represent this curve. Here, we can appreciate that when the output is a 3-vector, it is given a geometric meaning. I just need to give a single value tt to this function, and it will give me a point in space!😍When we give a sufficiently dense set of values, these points form a smooth curve.

dense-points-to-curve.png

1.2. Arc Length

The arc length not only represents the length of an β€œarc” but also the total length of a curve.

πŸ“Definition 2: The arc length of a plane curve with parametric equationsx=f(t),y=g(t),a≀t≀b\displaystyle x=f(t),y=g(t),a\leq t\leq b, as the limit of lengths of approximating polygonal paths and, for the case where fβ€²f' and gβ€²g' are continuous, we arrived at the formula L=∫ab(dxdt)2+(dydt)2dt.L=\int_a^b\sqrt{(\frac{dx}{dt})^2+(\frac{dy}{dt})^2}dt.

If you have forgotten calculus and partial derivatives, don’t worry. The essence of this formula is that the total length of a curve can be obtained by dividing the curve into small segments and summing the lengths of each segment. When our division is infinitely fine, the result of this summation is the total length of the curve.

As shown in the figure, the blue curve is the curve we want to measure, and the red curve is the polygonal path used to approximate the blue curve.

(©️Thomas’ Calculus)

We can use a Grasshopper example to understand this. When our division is finer, the two curves’ lengths are closer.

gh-simple-segment-arc-length.png gh-many-segments-arc-length.png

At this point, we can use trigonometric function to calculate the distance between two very close points:

(dxdt)2+(dydt)2.\sqrt{(\frac{dx}{dt})^2+(\frac{dy}{dt})^2}.

2. What is Arc Length Parameterization?

After the above preparation, we finally need to discuss the essence of arc length parameterizationπŸ™Œ. From do Carmo’s Differential Geometry of Curves and Surfaces (Section 1.5), we know that:

Let Ξ±:Iβ†’R3\alpha:I\to\mathbb{R}^3 be a curve parameterized by arc length s∈Is\in I. The number βˆ£Ξ±β€²β€²(s)∣=ΞΊ(s)\lvert \alpha''(s)\rvert=\kappa(s) is called the curvature of Ξ±\alpha at ss.

So, what is β€œarc length parameterization”, and what is β€œparameterized by arc length”?

Let’s review the helix example. The points on the helix are expressed as:

dense-points-to-curve.png

r(t)=(cos⁑t)i+(sin⁑t)k+tk.\mathbf{r}(t) = (\cos t)\mathbf{i} + (\sin t)\mathbf{k} + t\mathbf{k}.

Or:

x=f(t)=cos⁑ty=g(t)=sin⁑tz=h(t)=t.\begin{align} x &= f(t) = \cos t \\ y &= g(t) = \sin t \\ z &= h(t) = t. \\ \end{align}

Notice that? All these expressions are with input tt. The tt is given, which belongs to the interval II, i.e., t∈It\in I.

Remark

This II is also the β€œπŸ”‹Domain” in Grasshopper.

Let’s try to use r\mathbf{r} to express the points on the curve. Suppose the input is tt, we then write: r(t)\mathbf{r}(t). In rigorous mathematical language, this is

A smooth curve r\mathbf{r} parametrized by tt.

Therefore, when we talk about β€œarc length parameterization” and β€œparameterized by arc length”, we are actually talking about ==replacing the input tt from to ss!==

That is, as long as we can find the relationship between tt and ss, we can re-interpret the curve using ss! So, what can be used to establish the relationship between ss and tt? The answer is arc length!πŸ’‘

The arc length of r(t)\mathbf{r}(t) is:

s(t)=∫at(dfdu)2+(dgdu)2+(dhdu)2du=∫0t(βˆ’sin⁑t)2+(cos⁑t)2+12du=∫0t2du=2t.\begin{align} s(t) &= \int_a^t \sqrt{\left(\frac{df}{du}\right)^2 + \left(\frac{dg}{du}\right)^2 + \left(\frac{dh}{du}\right)^2} du \\ &= \int_0^t \sqrt{ (-\sin t)^2 + (\cos t)^2 + 1^2} du = \int_0^t \sqrt{2} du = \sqrt{2} t. \end{align}

Therefore, we can swap ss and tt:

s=2tt=s/2\begin{align} s &= \sqrt{2} t \\ t &= s/\sqrt{2} \\ \end{align}

Then, substituting t=s/2t = s/\sqrt{2} into r(t)\mathbf{r}(t), we get the equation of the curve expressed using ss. This process is so-called β€œarc length parameterization”, and this curve is β€œparameterized by arc length”.

r(t)=cos⁑ti+sin⁑tk+tkr(s(t))=cos⁑(s/2)i+sin⁑(s/2)j+(s/2)k\begin{align} \mathbf{r}(t) &= \cos t\mathbf{i} + \sin t\mathbf{k} + t\mathbf{k} \\ \mathbf{r}(s(t)) &= \cos(s/\sqrt{2})\mathbf{i} + \sin(s/\sqrt{2})\mathbf{j} + (s/\sqrt{2})\mathbf{k} \end{align}

3. Verify in Grasshopper

Now, let’s apply these theories to Grasshopper for practical operation. I drew a helix in Rhino, as shown below.

3.1. Curve Domain

First, we need to define the domain of the curve: gh-domain-helix.png

Here, we need to think about whether the interval 0≀t≀100\leq t \leq 10 is we need. This interval is the definition domain of a Rhino.Geometry.Curve, but it may not be what we expect.

Let’s review the helix formula:

r(t)=(cos⁑t)i+(sin⁑t)j+tk.\mathbf{r}(t) = (\cos t)\mathbf{i} + (\sin t)\mathbf{j} + t\mathbf{k}.

Actually, its more general form is:

r(t)=(acos⁑t)i+(asin⁑t)j+btk.\mathbf{r}(t) = (a\cos t)\mathbf{i} + (a\sin t)\mathbf{j} + bt\mathbf{k}.

Here,

  • aa controls the rotation radius of the helix, and
  • bb controls the β€œhow compressed” in the zz direction. At the same time, we see that tt is the parameter of the trigonometric function, therefore using radian as tt may be a good choiceβœ”οΈ. By observing how many turns this curve makes, we find that it has 10 turns! So, the interval of is:
0≀t≀10Γ—2Ο€.0\leq t\leq 10 \times 2\pi.

We can use the β€œπŸ”‹Remap” component to map the tt from mathematical space to the domain of Rhino.Geometry.Curve.

gh-remap-helix-from-math-to-rhino.png

3.2. Curve Formula

Our objective🎯 is to figure out the values of aa and bb.

r(t)=(acos⁑t)i+(asin⁑t)j+btk.\mathbf{r}(t) = (a\cos t)\mathbf{i} + (a\sin t)\mathbf{j} + bt\mathbf{k}.

3.2.1. Calculate b

The value of bb is easy to calculate. The simplest method is to take t=10Γ—2Ο€t=10\times2\pi. When t=20Ο€t=20\pi, the point has rotated 10 times and has reached the end of the interval. So, zz is:

z=10Γ—2Ο€b,z = 10 \times 2\pi b,

i.e., the end of the interval, also the end of the curve. We can simply get the value of zz: gh-helix-end-point-z-value.png

Thus, we can get:

10=10Γ—2Ο€bb=12Ο€.\begin{align} 10 &= 10\times 2 \pi b \\ b &= \frac{1}{2\pi}. \end{align}

3.2.2. Calculate a

We can take any value tt, for example t=3.3t=3.3:

gh-calculate-value-a-helix.png

At this time, xx and yy are:

βˆ’0.987468=acos⁑(3.3)βˆ’0.157744=asin⁑(3.3)\begin{align} -0.987468 &= a \cos(3.3) \\ -0.157744 &= a \sin(3.3) \\ \end{align}

Squaring both sides, we get:

(βˆ’0.987468)2+(βˆ’0.157744)2=a2cos⁑2(3.3)+a2sin⁑2(3.3)(βˆ’0.987468)2+(βˆ’0.157744)2=a2(cos⁑2(3.3)+sin⁑2(3.3))a2=1\begin{align} (-0.987468)^2 + (-0.157744)^2 &= a^2 \cos^2(3.3) + a^2 \sin^2(3.3)\\ (-0.987468)^2 + (-0.157744)^2 &= a^2 (\cos^2(3.3) + \sin^2(3.3))\\ a^2 &= 1 \end{align}

Because aβ‰₯1a\geq1, we know that a=1a=1.

Rearranging, we get the formula for the helix. Now, let’s plug in the values of aa and bb:

r(t)=(1cos⁑t)i+(1sin⁑t)j+12Ο€tkx=cos⁑ty=sin⁑tz=12Ο€t.\begin{align} \mathbf{r}(t) &= (1\cos t)\mathbf{i} + (1\sin t)\mathbf{j} + \frac{1}{2\pi}t\mathbf{k}\\ x&=\cos t \\ y&=\sin t \\ z&=\frac{1}{2\pi} t. \\ \end{align}

The results show that the distance between the points obtained through mathematical reasoning and those calculated by Rhino is within an acceptable tolerance.

gh-error-math-very-small.png

3.3. Reparameterization from t to Arc Length s

Next, let’s reparameterize the curve:

r(t)=(1cos⁑t)i+(1sin⁑t)j+12Ο€tk.\mathbf{r}(t) = (1\cos t)\mathbf{i} + (1\sin t)\mathbf{j} + \frac{1}{2\pi}t\mathbf{k}.

First, we use the following formula to calculate the arc length and establish the relationship between ss and tt:

s(t)=∫at(dfdu)2+(dgdu)2+(dhdu)2du.s(t) = \int_a^t \sqrt{\left(\frac{df}{du}\right)^2 + \left(\frac{dg}{du}\right)^2 + \left(\frac{dh}{du}\right)^2} du.

Substituting the formula, we get:

s(t)=∫at(dfdu)2+(dgdu)2+(dhdu)2du=∫at(βˆ’sin⁑t)2+(cos⁑t)2+(12Ο€)2du=∫0t14Ο€2+1du=14Ο€2+1t\begin{align} s(t) &= \int_a^t \sqrt{\left(\frac{df}{du}\right)^2 + \left(\frac{dg}{du}\right)^2 + \left(\frac{dh}{du}\right)^2} du \\ &= \int_a^t \sqrt{\left(-\sin t\right)^2 + \left(\cos t\right)^2 + \left(\frac{1}{2\pi}\right)^2} du = \int_0^t\sqrt{\frac{1}{4\pi^2}+1}du = \sqrt{\frac{1}{4\pi^2}+1}t \\ \end{align}

That is, the relationship between ss and tt is:

s=14Ο€2+1tt=114Ο€2+1s\begin{align} s &= \sqrt{\frac{1}{4\pi^2}+1}t \\ t &= \frac{1}{\sqrt{\frac{1}{4\pi^2}+1}}s \end{align}

So, if we express the helix curve using ss, it will be:

r(s)=cos⁑(114Ο€2+1s)i+sin⁑(114Ο€2+1s)j+12Ο€114Ο€2+1sk.x=cos⁑(114Ο€2+1s)y=sin⁑(114Ο€2+1s)z=12Ο€114Ο€2+1s.\begin{align} \mathbf{r}(s) &= \cos \left(\frac{1}{\sqrt{\frac{1}{4\pi^{2}} + 1}}s\right) \mathbf{i} + \sin\left( \frac{1}{\sqrt{\frac{1}{4\pi^{2}} + 1}}s \right)\mathbf{j} + \frac{1}{2\pi}\frac{1}{\sqrt{\frac{1}{4\pi^{2}} + 1}}s\mathbf{k}. \\ x &= \cos \left(\frac{1}{\sqrt{\frac{1}{4\pi^{2}} + 1}}s\right) \\ y &= \sin\left( \frac{1}{\sqrt{\frac{1}{4\pi^{2}} + 1}}s \right) \\ z &= \frac{1}{2\pi}\frac{1}{\sqrt{\frac{1}{4\pi^{2}} + 1}}s. \end{align}

We can also verify this using Grasshopper. The difference between the curve constructed using mathematical expressions and the curve calculated using β€œπŸ”‹Evaluate Length” is very small.

gh-verify-arc-length-parameterization-curve.png

Remark

Here, the error is larger than before because it involves a lot of root calculations. For whom is interested can further research numerical analysis.

4.Conclusion

The example below is parameterized by tt:

r(t)=cos⁑ti+sin⁑tj+tk.\mathbf{r}(t) = \cos t\mathbf{i} + \sin t\mathbf{j} + t\mathbf{k}.

While the example below is parameterized by arc length ss:

r(s)=cos⁑(s/2)i+sin⁑(s/2)j+(s/2)k.\mathbf{r}(s) = \cos (s/\sqrt{2})\mathbf{i} + \sin (s/\sqrt{2})\mathbf{j} + (s/\sqrt{2})\mathbf{k}.

Through this detailed discussion and practice, we not only deepened our understanding of arc length parameterization but also implemented this concept in Grasshopper. This understanding and application provide us with powerful tools and perspectives for complex geometric modeling and problem-solving. I hope this article can help you apply these concepts in your own projects!