Introduction

Motivation

One of the main challenges in computer-aided design is finding a suitable shape representation which is both performant and flexible, when implemented in a computer software. Especially with curves, a software engineer is usually presented with a plethora of possible shape representations to choose from. The wide range of candidates and their specific advantages and disadvantages motivate the application of this work. A brief overview of the main purpose of curves and splines as well as the necessity of a conversion method in engineering fields will prepare the reader for the subsequent theory and evaluation part within this paper.

Designers in the car industry often need to construct clay models or sketches of vehicles, where the mathematical representation needs to allow for interactive modifications to curve properties, such as curvature and continuity. Furthermore, one of the key properties of the available mathematical representations is the distinction between interpolating and approximating curves [10]. This property is related to whether a curve goes through its Control Points or not and can be observed as one of the main differences between the two shape representations discussed in this work. Indeed, the reason for conducting this research was the need to support two different curve representations in a common file format, and therefore, the remainder of this paper is focused on proposing a closed-form conversion equation.

Furthermore, according to the German Association of the Automotive Industry (VDA)Footnote 1, different manufacturers and their subcontractors have different geometric modeling systems for curve and surface representations. Thus, another motivating view on exchanging data between different geometric modeling systems to compensate differences in the types of polynomial bases, maximum polynomial degrees and mesh sizes of curve and surface representations is discussed more thoroughly in Ref. [14].

Engineering Purpose and Related Work

As the field of Computer Graphics (CG) develops, techniques for modeling complex curves and surfaces are being increasingly important. An example may be the rendering of highly detailed landscapes which need to be subdivided (tessellated) depending on the viewing distance to reduce the processing time for a geometry that is barely visible from the current camera viewpoint [12, 30]. One of the major techniques to realize such dynamic tessellation algorithms is the use of parametric splines in which a curve is defined by piecing together a succession of curve segments, and especially, surfaces defined by stitching together a mosaic of surface patches [1].

Splines are a mathematical means of representing a complex curve. For example, it is not possible to define a circle using only a single cubic Bézier curve. Therefore, a common approximation to model a circle is to use four Bézier curve segments [7]. Eventually, a complete path can be defined using a series of points at intervals along the curve segments and defining a function that allows to interpolate along the curve to retrieve additional points within each interval to be calculated. This is often the first step when creating procedural virtual worlds, i.e., generating smooth and infinite highways using Catmull–Rom splines in games [8]. The impressive power of splines is demonstrated when procedural landscapes and roads are combined to create entire virtual city models randomly, as can be seen, for instance in the SceneCity Blender addonFootnote 2. As seen with the CG examples, it is possible to generate paths and surfaces using splines. In addition, Splines can be used to animate objects or virtual cameras along predefined paths [27]. Recently, the research community involved in solving the inverse problem to CG, namely, Computer Vision (CV), increasingly discovers splines for recovering the real camera movement from image sequences. In robotics, related research is often concerned with solving the visual Simultaneous Localization And Mapping (SLAM) problem. However, since cameras usually take pictures at specific points in time, the resulting estimated trajectory is discrete. Imposing constraints on the camera path using splines has shown advantages in handling a common image sensor deficiency called rolling shutter, where the image exhibits a pixel warping deformation (informally often called a Jello Effect) due to a rowwise exposure [5]. Describing the camera trajectory using continuous B-splines offers the advantage that any exposure time along the path can be interpolated and thus allows for correcting the rolling shutter for both monocular [24] and stereo (RGB-D) [20] cameras. To predict and plan the future paths for Automated Driving Systems (ADS), while taking into account obstacles and driving comfort, it was shown that Bézier curves are a reliable solution for an optimal trajectory generation [11, 21].

This short review of interdisciplinary research contains many different types of spline representation, such as Bézier [7, 11, 21], Catmull–Rom [8], B-Splines [20, 24] and Non-uniform Rational B-Spline (NURBS) [12] surfaces. This shows the relevance of providing conversion methods between the various representations of which one is discussed in this paper.

Paper Structure and Contributions

In this paper, we do not go through the properties and details of Bézier and Catmull–Rom Splines, but rather the aim is to focus on the conversion equations. First, we give a brief explanation of Bézier curves in  "Bézier Curves" section as well as a brief explanation of Catmull–Rom Splines in  "Catmull–Rom Splines" section. Then, we go through the conversion equations in  "Conversion". Note that by conversion, we mean conversion of control points of a curve to the control points of another curve, which results in approximately the same curve as the curve before conversion representsFootnote 3. In  "Experiments and Results" section, we validate the equations with some numerical and graphical examples. We use bold-face notation for vector representation here.  "Discussion" section discusses the conversion equations with regard to the real-world applications and the limitations and proposes some potential future work. Finally, the conclusions are stated in  "Conclusion" section.

Bézier Curves

There are two basic ways of defining a curve—in terms of the polygon vertices, and in terms of the polygon sides [10]. Even though, the latter is the form, which was originally used by Pierre Bézier [2,3,4], we consider the former throughout our paper. There are two reasons for developing a formulation of the Bézier curve in terms of polygon vertices rather than polygon sides. To begin with, the formulation becomes more elegant. Furthermore, as a general principle, it is better to program in terms of absolute vectors rather than a chain of relative vectors, irrespective of the particular user interface, when transformations such as rotation are to be applied to the vectors, because rounding errors do not have the cumulative effect which sometimes give rise to poor drawings. This can be particularly noticeable when transformations are performed, for reasons of speed, in a small satellite graphics computer [10].

A parametric Bézier curve is defined by its control points. The curve does not necessarily go through the control points. There may be 2, 3, 4 or more. For instance, Fig. 1 shows a linear, a quadratic, and cubic Bézier curve, respectively. The figures are drawn using a geometric approach called “de Casteljau’s algorithm”. It is the most common approach for drawing Bézier curves in CAGD. For more details on the algorithm, see Ref. [9].

Fig. 1
figure 1

Images taken from Ref. [19]

a Two-point Bézier curve. b Three-point (quadratic) Bézier curve. c Four-point (cubic) Bézier curve.

A cubic Bézier curve can be written in a matrix form by expanding the analytic definition of the curve into its Bernstein polynomial coefficients, and then writing these coefficients in a matrix form using the polynomial power basis [15]. The Bernstein polynomialsFootnote 4 of degree n are defined by Eq. 1 (for more details on Bézier curves, see Ref. [18]):

$$\begin{aligned} B_{i,n}(t)={n \atopwithdelims ()i}t^i(1-t)^{n-i} \end{aligned}$$
(1)

A Bézier curve uses Bernstein polynomials as basis. A cubic (degree 3 or order 4) is represented by the following:

$$\begin{aligned} {\text{Bezier}}(t) & = \sum\limits_{{i = 0}}^{3} {{\mathbf{P}}_{{\mathbf{i}}} {\mathbf{B}}_{{\mathbf{i}}} ({\mathbf{t}})} \\ & = (1 - t)^{3} {\mathbf{P}}_{{\mathbf{0}}} + 3t(1 - t)^{2} {\mathbf{P}}_{{\mathbf{1}}} + 3t^{2} (1 - t){\mathbf{P}}_{{\mathbf{2}}} + t^{3} {\mathbf{P}}_{{\mathbf{3}}} \\ \end{aligned}$$
(2)
$$\begin{aligned}&=\begin{bmatrix} 1&t&t^2&t^3 \end{bmatrix}\cdot \begin{bmatrix} 1&{}0&{}0&{}0 \\ -3&{}3&{}0&{}0 \\ 3&{}-6&{}3&{}0 \\ -1&{}3&{}-3&{}1 \end{bmatrix}\cdot \begin{bmatrix} \mathbf {P_0}\\ \mathbf {P_1}\\ \mathbf {P_2}\\ \mathbf {P_3 } \end{bmatrix}. \end{aligned}$$
(3)

Catmull–Rom Splines

Catmull–Rom splines are a family of cubic interpolating splines formulated such that the tangent at each point \({\mathbf {P}} _{i}\) is calculated using the previous and next point on the spline [29]. Unlike a Bézier curve, a (Centripetal) Catmull–Rom spline is defined for only 4 control points (see Fig. 2), i.e., a single Catmull–Rom segment is cubic. As it is an interpolating spline, the curve goes, through its control points, \({\mathbf {P}} _{0},{\mathbf {P}} _{1},{\mathbf {P}} _{2},{\mathbf {P}} _{3}\), and it is only drawn from \({\mathbf {P}} _{1}\) to \({\mathbf {P}} _{2}\) (Fig. 2). The curve is named after Edwin Catmull and Raphael Rom. The principal advantage of this technique is that the points along the original set of points also make up the control points for the spline curve [6].

Fig. 2
figure 2

Image taken from Ref. [13]

Catmull–Rom spline interpolation with four points.

Catmull–Rom splines are based on the concept of “tension”: the higher the tensions, the shorter the tangents at the departure and arrival points. It affects how sharply the curve bends at the (interpolated) control points [29]. When tension is set to 1 (as it often is), the resulting segments between control points will be straight lines. The basic Catmull–Rom curve arrives and departs with tangents equal to half the distance between the two adjacent points.

The matrix form of a Catmull–RomFootnote 5 spline is shown in Eq. 4:

$$\begin{aligned} {\text{Catmull-Rom}}(t) = & \frac{1}{2} \cdot \left[ {\begin{array}{*{20}c} 1 & t & {t^{2} } & {t^{3} } \\ \end{array} } \right] \\ & \cdot \left[ {\begin{array}{*{20}c} 0 & 2 & 0 & 0 \\ { - \tau } & 0 & \tau & 0 \\ {2\tau } & {\tau - 6} & { - 2(\tau - 3)} & { - \tau } \\ { - \tau } & {4 - \tau } & {\tau - 4} & \tau \\ \end{array} } \right].\left[ {\begin{array}{*{20}c} {{\mathbf{P^{\prime}}}_{{\mathbf{0}}} } \\ {{\mathbf{P^{\prime}}}_{{\mathbf{1}}} } \\ {{\mathbf{P^{\prime}}}_{{\mathbf{2}}} } \\ {{\mathbf{P^{\prime}}}_{{\mathbf{3}}} } \\ \end{array} } \right] \\ \end{aligned}$$
(4)

where \(\tau\) is the tension factorFootnote 6. See Ref. [17] for the proof of Eq. 4 with \(\tau = 1\).

Conversion

We will use only cubic splines for both Catmull–Rom and Bézier throughout this paper, as the Catmull–Rom splines are only defined with four control points. It is always possible to concatenate multiple splines to create the desired curve. A series of unique cubic polynomials are fitted between each of the data points, with the stipulation that the curve obtained be continuous and appear smooth [22]. As a matter of fact, in industrial applications, it is often found that a particular curve segment is not sufficiently powerful or flexible (i.e., it does not have sufficient degrees of freedom) to adopt a desired shape [10].

Comparing Eqs. 3 and 4, we wish to find the transformation matrix A to convert from Catmull–Rom to Bézier:

$$\begin{aligned} \begin{aligned} \begin{bmatrix} 1&t&t^2&t^3 \end{bmatrix}\cdot \frac{1}{2}\cdot \begin{bmatrix} 0&{}2&{}0&{}0 \\ -\tau &{}0&{}\tau &{}0 \\ 2\tau &{}\tau -6&{}-2(\tau -3)&{}-\tau \\ -\tau &{}4-\tau &{}\tau -4&{}\tau \end{bmatrix}. \begin{bmatrix} \mathbf {P'_0}\\ \mathbf {P'_1}\\ \mathbf {P'_2}\\ \mathbf {P'_3} \end{bmatrix}\\ = \begin{bmatrix} 1&t&t^2&t^3 \end{bmatrix}\cdot \begin{bmatrix} 1&{}0&{}0&{}0 \\ -3&{}3&{}0&{}0 \\ 3&{}-6&{}3&{}0 \\ -1&{}3&{}-3&{}1 \end{bmatrix}\cdot A\cdot \begin{bmatrix} \mathbf {P_0}\\ \mathbf {P_1}\\ \mathbf {P_2}\\ \mathbf {P_3} \end{bmatrix}. \end{aligned} \end{aligned}$$
(6)

Consequently, we have,

$$\begin{aligned} \begin{bmatrix} 1&t&t^2&t^3 \end{bmatrix}\cdot M' \cdot \begin{bmatrix} \mathbf {P'_0}\\ \mathbf {P'_1}\\ \mathbf {P'_2}\\ \mathbf {P'_3} \end{bmatrix} = \begin{bmatrix} 1&t&t^2&t^3 \end{bmatrix}\cdot M \cdot \begin{bmatrix} \mathbf {P_0}\\ \mathbf {P_1}\\ \mathbf {P_2}\\ \mathbf {P_3} \end{bmatrix} \end{aligned}$$
(7)

with M and \(M'\) being the following matrices:

$$\begin{aligned} M'&=\frac{1}{2}\cdot \begin{bmatrix} 0&{}2&{}0&{}0 \\ -\tau &{}0&{}\tau &{}0 \\ 2\tau &{}\tau -6&{}-2(\tau -3)&{}-\tau \\ -\tau &{}4-\tau &{}\tau -4&{}\tau \end{bmatrix}, \end{aligned}$$
(8)
$$\begin{aligned} M&= \begin{bmatrix} 1&{}0&{}0&{}0 \\ -3&{}3&{}0&{}0 \\ 3&{}-6&{}3&{}0 \\ -1&{}3&{}-3&{}1 \end{bmatrix}\cdot A \end{aligned}$$
(9)

The difference is somewhere in the M and \(M'\) matrices, since t and the coordinate values are identical. Therefore, we should solve the matrix equation in Eq. 10:

$$\begin{aligned} \frac{1}{2}\cdot \begin{bmatrix} 0&{}2&{}0&{}0 \\ -\tau &{}0&{}\tau &{}0 \\ 2\tau &{}\tau -6&{}-2(\tau -3)&{}-\tau \\ -\tau &{}4-\tau &{}\tau -4&{}\tau \end{bmatrix}= \begin{bmatrix} 1&{}0&{}0&{}0 \\ -3&{}3&{}0&{}0 \\ 3&{}-6&{}3&{}0 \\ -1&{}3&{}-3&{}1 \end{bmatrix}\cdot A \end{aligned}$$
(10)

We left-multiply both sides by the inverse of the Bézier matrix, to get rid of the Bézier matrix on the right side of the equals sign:

$$\begin{aligned} & \left[ {\begin{array}{*{20}c} 1 & 0 & 0 & 0 \\ { - 3} & 3 & 0 & 0 \\ 3 & { - 6} & 3 & 0 \\ { - 1} & 3 & { - 3} & 1 \\ \end{array} } \right]^{{ - 1}} \cdot \frac{1}{2} \cdot \left[ {\begin{array}{*{20}c} 0 & 2 & 0 & 0 \\ { - \tau } & 0 & \tau & 0 \\ {2\tau } & {\tau - 6} & { - 2(\tau - 3)} & { - \tau } \\ { - \tau } & {4 - \tau } & {\tau - 4} & \tau \\ \end{array} } \right] \\ & = \left[ {\begin{array}{*{20}c} 1 & 0 & 0 & 0 \\ { - 3} & 3 & 0 & 0 \\ 3 & { - 6} & 3 & 0 \\ { - 1} & 3 & { - 3} & 1 \\ \end{array} } \right]^{{ - 1}} \cdot \left[ {\begin{array}{*{20}c} 1 & 0 & 0 & 0 \\ { - 3} & 3 & 0 & 0 \\ 3 & { - 6} & 3 & 0 \\ { - 1} & 3 & { - 3} & 1 \\ \end{array} } \right] \cdot A = I \cdot A = A, \\ \end{aligned}$$
(11)

which brings us to Eq. 12.

$$\begin{aligned} \frac{1}{6}\cdot \begin{bmatrix} 0&{}6&{}0&{}0\\ -\tau &{}6&{}\tau &{}0\\ 0&{}\tau &{}0&{}-\tau \\ 0&{}0&{}6&{}0 \end{bmatrix}=A. \end{aligned}$$
(12)

Multiplying this A with our coordinates will give us a proper Bézier matrix expression again, as in Eqs. 13 and 14:

$$\begin{aligned}&\begin{bmatrix} 1&t&t^2&t^3 \end{bmatrix} \begin{bmatrix} 1&{}0&{}0&{}0 \\ -3&{}3&{}0&{}0 \\ 3&{}-6&{}3&{}0 \\ -1&{}3&{}-3&{}1 \end{bmatrix}\cdot \frac{1}{6}\cdot \begin{bmatrix} 0&{}6&{}0&{}0\\ -\tau &{}6&{}\tau &{}0\\ 0&{}\tau &{}0&{}-\tau \\ 0&{}0&{}6&{}0 \end{bmatrix}\cdot \begin{bmatrix} \mathbf {P_0}\\ \mathbf {P_1}\\ \mathbf {P_2}\\ \mathbf {P_3} \end{bmatrix} \end{aligned}$$
(13)
$$\begin{aligned}&=\begin{bmatrix} 1&t&t^2&t^3 \end{bmatrix} \begin{bmatrix} 1&{}0&{}0&{}0 \\ -3&{}3&{}0&{}0 \\ 3&{}-6&{}3&{}0 \\ -1&{}3&{}-3&{}1 \end{bmatrix}\cdot \begin{bmatrix} \mathbf {P_1}\\ \mathbf {P_1}+\displaystyle {\frac{\mathbf {P_2}-\mathbf {P_0}}{6\cdot \tau }}\\ \mathbf {P_2}-\displaystyle {\frac{\mathbf {P_3}-\mathbf {P_1}}{6\cdot \tau }}\\ \mathbf {P_2} \end{bmatrix}. \end{aligned}$$
(14)

Thus, a Catmull–Rom to Bézier conversion, based on coordinates, requires turning the Catmull–Rom coordinates on the left into the Bézier coordinates on the right (with \(\tau\) being our tension factor), according to Eq. 15:

$$\begin{aligned} \begin{bmatrix} \mathbf {P'_0}\\ \mathbf {P'_1}\\ \mathbf {P'_2}\\ \mathbf {P'_3} \end{bmatrix}_{Catmull-Rom}\Rightarrow \begin{bmatrix} \mathbf {P_1}\\ \mathbf {P_1}+\displaystyle {\frac{\mathbf {P_2}-\mathbf {P_0}}{6\cdot \tau }}\\ \mathbf {P_2}-\displaystyle {\frac{\mathbf {P_3}-\mathbf {P_1}}{6\cdot \tau }}\\ \mathbf {P_2} \end{bmatrix}_{Bezier} \end{aligned}$$
(15)

In addition, in the same way, a Bézier to Catmull–Rom conversion instead requires turning the Bézier coordinates on the left into the Catmull–Rom coordinates on the right. Note that, there is no tension factor this time, because Bézier curves do not have any. Converting from Bézier to Catmull–Rom is simply a default-tension Catmull–Rom curve, based on Eq. 16:

$$\begin{aligned} \begin{bmatrix} \mathbf {P_0}\\ \mathbf {P_1}\\ \mathbf {P_2}\\ \mathbf {P_3 } \end{bmatrix}_{Bezier}\Rightarrow \begin{bmatrix} \mathbf {P'_3}+6\cdot (\mathbf {P'_0}-\mathbf {P'_1})\\ \mathbf {P'_0}\\ \mathbf {P'_3}\\ \mathbf {P'_0}+6\cdot (\mathbf {P'_3}-\mathbf {P'_2}) \end{bmatrix}_{Catmull-Rom} \end{aligned}$$
(16)

Experiments and Results

In this section, we use sets of exemplary control points to validate the transformation equations.

Numerical Analysis

Having the fact that we only consider some random values here, this part cannot be considered as a mathematical proof. However, it gives a sound overview of how the conversion equations (Eqs. 15 and 16) work.

Looking at the equations, it is trivial that the conversion equations are valid for any number of dimensions. In this part, we explain our examples with 3-dimensional (3D) control points.

In the following, first, we validate the conversion from cubic Bézier curves to cubic Catmull–Rom splines by experimenting two random timepoints. In addition, in the second part, we do the reverse and validate the conversion from cubic Catmull–Rom splines to cubic Bézier curves by experimenting two other random timepoints.

Conversion from Bézier to Catmull–Rom

Let us have a cubice Bézier curve with the following 3D control points:

$$\begin{gathered} {\mathbf{P}}_{{\mathbf{0}}} = (1.0,1.0,1.0), \hfill \\ {\mathbf{P}}_{{\mathbf{1}}} = (2.0,2.0,2.0), \hfill \\ {\mathbf{P}}_{{\mathbf{2}}} = (3.0,3.0,3.0), \hfill \\ {\mathbf{P}}_{{\mathbf{3}}} = (4.0,4.0,4.0). \hfill \\ \end{gathered}$$

Using Eq. 16, we get the following control points for the Catmull–Rom spline with the tension factor \(\tau =1\):

$$\begin{gathered} {\mathbf{P^{\prime}}}_{{\mathbf{0}}} = ( - 2.0, - 2.0, - 2.0), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{1}}} = (1.0,1.0,1.0), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{2}}} = (4.0,4.0,4.0), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{3}}} = (7.0,7.0,7.0). \hfill \\ \end{gathered}$$

Now, we replace the set of control data points in Eq. 3 and with a random choice of \(t= 0.2\), we get the following:

$$\begin{aligned} \text {Bezier}(0.2)= \begin{bmatrix} 1&0.2&0.04&0.008 \end{bmatrix}\cdot \begin{bmatrix} 1&{}0&{}0&{}0 \\ -3&{}3&{}0&{}0 \\ 3&{}-6&{}3&{}0 \\ -1&{}3&{}-3&{}1 \end{bmatrix}\cdot \begin{bmatrix} 1.0\\ 2.0\\ 3.0\\ 4.0\end{bmatrix} = 1.600. \end{aligned}$$
(17)

The obtained value should be the same when using Eq. 4 with \(t= 0.2\):

$$\begin{aligned} 1.600 = {\text{Catmull-Rom}}(0.2) = & \frac{1}{2} \cdot \left[ {\begin{array}{*{20}c} 1 & {0.2} & {0.04} & {0.008} \\ \end{array} } \right] \\ & \cdot \left[ {\begin{array}{*{20}c} 0 & 2 & 0 & 0 \\ { - 1} & 0 & 1 & 0 \\ 2 & { - 5} & 4 & { - 1} \\ { - 1} & 3 & { - 3} & 1 \\ \end{array} } \right].\quad \left[ {\begin{array}{*{20}c} {{\mathbf{P^{\prime}}}_{{\mathbf{0}}} } \\ {{\mathbf{P^{\prime}}}_{{\mathbf{1}}} } \\ {{\mathbf{P^{\prime}}}_{{\mathbf{2}}} } \\ {{\mathbf{P^{\prime}}}_{{\mathbf{3}}} } \\ \end{array} } \right]. \\ \end{aligned}$$
(18)

Solving the matrix equation, we get the following control points:

$$\begin{gathered} {\mathbf{P^{\prime}}}_{{\mathbf{0}}} = ( - 2.0, - 2.0, - 2.0), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{1}}} = (1.0,1.0,1.0), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{2}}} = (4.0,4.0,4.0), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{3}}} = (7.0,7.0,7.0). \hfill \\ \end{gathered}$$

which are equal to the results of using Eq. 16. \(\square\)


Another timepoint Now, to show the equation is valid for any timepoint, we choose another random time \(t= 0.64\) and follow the same procedure as above for the same control points:

$$\begin{aligned} {\text{Bezier}}(0.64) & = \left[ {\begin{array}{*{20}c} 1 & {0.64} & {0.4096} & {0.262144} \\ \end{array} } \right] \\ & \cdot \left[ {\begin{array}{*{20}c} 1 & 0 & 0 & 0 \\ { - 3} & 3 & 0 & 0 \\ 3 & { - 6} & 3 & 0 \\ { - 1} & 3 & { - 3} & 1 \\ \end{array} } \right] \cdot \left[ {\begin{array}{*{20}c} {1.0} \\ {2.0} \\ {3.0} \\ {4.0} \\ \end{array} } \right] \\ & = 2.920 \\ \end{aligned}$$
(19)
$$\begin{aligned} 2.920 & = {\text{Catmull-Rom}}(0.64) \\ & = \frac{1}{2} \cdot \left[ {\begin{array}{*{20}c} 1 & {0.64} & {0.4096} & {0.262144} \\ \end{array} } \right] \\ & \cdot \left[ {\begin{array}{*{20}c} 0 & 2 & 0 & 0 \\ { - 1} & 0 & 1 & 0 \\ 2 & { - 5} & 4 & { - 1} \\ { - 1} & 3 & { - 3} & 1 \\ \end{array} } \right].\left[ {\begin{array}{*{20}c} {{\mathbf{P^{\prime}}}_{{\mathbf{0}}} } \\ {{\mathbf{P^{\prime}}}_{{\mathbf{1}}} } \\ {{\mathbf{P^{\prime}}}_{{\mathbf{2}}} } \\ {{\mathbf{P^{\prime}}}_{{\mathbf{3}}} } \\ \end{array} } \right]. \\ \end{aligned}$$
(20)

Solving the matrix equation, we again get the following values:

$$\begin{gathered} {\mathbf{P^{\prime}}}_{{\mathbf{0}}} = ( - 2.0, - 2.0, - 2.0), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{1}}} = (1.0,1.0,1.0), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{2}}} = (4.0,4.0,4.0), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{3}}} = (7.0,7.0,7.0). \hfill \\ \end{gathered}$$

which are again equal to the results of using Eq. 16. \(\square\)

Conversion from Catmull–Rom to Bézier

In this part, we do the reverse and start with a cubic Catmull–Rom spline with the following 3D control points:

$$\begin{gathered} {\mathbf{P^{\prime}}}_{{\mathbf{0}}} = (1.0,1.0,1.0), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{1}}} = (2.0,2.0,2.0), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{2}}} = (3.0,3.0,3.0), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{3}}} = (4.0,4.0,4.0). \hfill \\ \end{gathered}$$

Using Eq. 15, we get the following control points for the Bézier curve with the tension factor \(\tau =1\):

$$\begin{gathered} {\mathbf{P}}_{{\mathbf{0}}} = (2.0,2.0,2.0), \hfill \\ {\mathbf{P}}_{{\mathbf{1}}} = (1.0,1.0,1.0), \hfill \\ {\mathbf{P}}_{{\mathbf{2}}} = (2.0,2.0,2.0), \hfill \\ {\mathbf{P}}_{{\mathbf{3}}} = (3.0,3.0,3.0). \hfill \\ \end{gathered}$$

Replacing the set of control data points in Eq. 4 and with a random choice of \(t= 0.45\), we get the following:

$$\begin{aligned} {\text {CatmullRom}(0.45)}&= \frac{1}{2} \cdot \begin{bmatrix} 1&0.45&0.2025&0.0911 \end{bmatrix}\nonumber \\&\quad \cdot \begin{bmatrix} 0&{}2&{}0&{}0 \\ -1&{}0&{}1&{}0 \\ 2&{}-5&{}4&{}-1 \\ -1&{}3&{}-3&{}1 \end{bmatrix}. \begin{bmatrix} 1.0\\ 2.0\\ 3.0\\ 4.0 \end{bmatrix} = 2.5411. \end{aligned}$$
(21)

The obtained value should be the same, when using Eq. 3 with \(t= 0.45\):

$$\begin{aligned} 2.5411&=\text {Bezier}(0.45)= \begin{bmatrix} 1&0.45&0.2025&0.0911 \end{bmatrix}\nonumber \\&\quad \cdot \begin{bmatrix} 1&{}0&{}0&{}0 \\ -3&{}3&{}0&{}0 \\ 3&{}-6&{}3&{}0 \\ -1&{}3&{}-3&{}1 \end{bmatrix}\cdot \begin{bmatrix} \mathbf {P_0}\\ \mathbf {P_1}\\ \mathbf {P_2}\\ \mathbf {P_3} \end{bmatrix}. \end{aligned}$$
(22)

Solving the matrix equation, we again get the following values:

$$\begin{gathered} {\mathbf{P}}_{{\mathbf{0}}} = (2.0,2.0,2.0), \hfill \\ {\mathbf{P}}_{{\mathbf{1}}} = (1.0,1.0,1.0), \hfill \\ {\mathbf{P}}_{{\mathbf{2}}} = (2.0,2.0,2.0), \hfill \\ {\mathbf{P}}_{{\mathbf{3}}} = (3.0,3.0,3.0), \hfill \\ \end{gathered}$$

which are equal to the results of using Eq. 15. \(\square\)

Another timepoint Now, to show the equation is valid for any timepoint, we choose another random time \(t= 0.32\) and follow the same procedure as above for the same control points:

$$\begin{aligned} {\text {CatmullRom}(0.32)}&= \frac{1}{2} \cdot \begin{bmatrix} 1&0.32&0.1024&0.0327 \end{bmatrix}\nonumber \\&\quad \cdot \begin{bmatrix} 0&{}2&{}0&{}0 \\ -1&{}0&{}1&{}0 \\ 2&{}-5&{}4&{}-1 \\ -1&{}3&{}-3&{}1 \end{bmatrix}. \begin{bmatrix} 1.0\\ 2.0\\ 3.0\\ 4.0 \end{bmatrix} = 2.3527. \end{aligned}$$
(23)
$$\begin{aligned} 2.3527&=\text {Bezier}(32)= \begin{bmatrix} 1&0.32&0.1024&0.0327 \end{bmatrix}\nonumber \\&\quad \cdot \begin{bmatrix} 1&{}0&{}0&{}0 \\ -3&{}3&{}0&{}0 \\ 3&{}-6&{}3&{}0 \\ -1&{}3&{}-3&{}1 \end{bmatrix}\cdot \begin{bmatrix} \mathbf {P_0}\\ \mathbf {P_1}\\ \mathbf {P_2}\\ \mathbf {P_3} \end{bmatrix}. \end{aligned}$$
(24)

Solving the matrix equation, we again get the following values:

$$\begin{gathered} {\mathbf{P}}_{{\mathbf{0}}} = (2.0,2.0,2.0), \hfill \\ {\mathbf{P}}_{{\mathbf{1}}} = (1.0,1.0,1.0), \hfill \\ {\mathbf{P}}_{{\mathbf{2}}} = (2.0,2.0,2.0), \hfill \\ {\mathbf{P}}_{{\mathbf{3}}} = (3.0,3.0,3.0), \hfill \\ \end{gathered}$$

which are again equal to the results of using Eq. 15. \(\square\)

Graphical Fitting

Fig. 3
figure 3

2D curves converted from Bézier to Catmull–Rom, drawn for 1000 time steps. a The original Bézier curve, which is drawn using the following randomly generated 2D control points: \(\mathbf {P_0} = (70.650, 40.045),\, \mathbf {P_1} = (65.354, 15.054),\, \mathbf {P_2} = (60.253, 100.754),\, \mathbf {P_3} = (100.234, 95.287)\). b The calculated Catmull–Rom curve with \(\tau =1\), which is drawn using the following control points, which are the converted control point of the original Bézier curve using Eq. 16: \(\mathbf {P'_0} = (130.010, 245.233),\, \mathbf {P'_1} = (70.650, 40.045),\, \mathbf {P'_2} = (100.234, 95.287),\, \mathbf {P'_3} = (310.536, 7.243)\)

Fig. 4
figure 4

2D curves converted from Catmull–Rom to Bézier, drawn for 1000 time steps. a The original Catmull–Rom curve with \(\tau =1\), which is drawn using the following randomly generated 2D control points: \(\mathbf {P'_0} = (72.022, 219.863),\, \mathbf {P'_1} = (0.257, 40.527),\, \mathbf {P'_2} = (85.204, 1.025),\, \mathbf {P'_3} = (307.331, 15.189)\). b The calculated Bézier curve, which is drawn using the following control points, which are the converted control point of the original Catmull–Rom curve using Eq. 15: \(\mathbf {P_0} = (0.257, 40.527),\, \mathbf {P_1} = (2.454, 4.054),\, \mathbf {P_2} = (34.025, 5.248),\, \mathbf {P_3} = (85.204, 1.025)\)

In this part, we aim at showing the validity of the conversion equations (Eqs. 15 and 16) by illustrating graphical examples. For the ease of illustration, we assume 2-dimensional (2D) curves in this part.

Figure 3a shows a cubic Bézier curve which is drawn for 1000 timepoints (\(t \in [0,1]\) with a step size of 0.001). Furthermore, the aforementioned figure is drawn using the following randomly generated 2D control points:

$$\begin{gathered} {\mathbf{P}}_{{\mathbf{0}}} = (70.650, 40.045), \hfill \\ {\mathbf{P}}_{{\mathbf{1}}} = (65.354, 15.054), \hfill \\ {\mathbf{P}}_{{\mathbf{2}}} = (60.253, 100.754), \hfill \\ {\mathbf{P}}_{{\mathbf{3}}} = (100.234, 95.287). \hfill \\ \end{gathered}$$

Using Eq. 16, we convert the above Bézier control points to the respective control points of a Catmull–Rom cubic spline with the tension factor \(\tau =1\):

$$\begin{gathered} {\mathbf{P^{\prime}}}_{{\mathbf{0}}} = (130.010,245.233), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{1}}} = (70.650,40.045), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{2}}} = (100.234,95.287), \hfill \\ {\mathbf{P^{\prime}}}_{{\mathbf{3}}} = (310.536,7.243), \hfill \\ \end{gathered}$$

and sketch the corresponding cubic Catmull–Rom spline of these new control points for the same 1000 timepoints (\(t \in [0,1]\) with a step size of 0.001). Figure 3b illustrates the resulting curve, which is almost the same as in Fig. 3a.

In a similar way, Fig. 4 shows the reverse conversion from Catmull–Rom to Bézier using Eq. 15 and the following randomly generated 2D control points and the resulting converted control points:

$$\begin{aligned} \mathbf {P'_0}=\, & {} (72.022, 219.863),\\ \mathbf {P'_1}=\, & {} (0.257, 40.527),\\ \mathbf {P'_2}=\, & {} (85.204, 1.025),\\ \mathbf {P'_3}=\, & {} (307.331, 15.189),\\ \mathbf {P_0}= \,& {} (0.257, 40.527),\\ \mathbf {P_1}=\, & {} (2.454, 4.054),\\ \mathbf {P_2}=\, & {} (34.025, 5.248),\\ \mathbf {P_3}= \,& {} (85.204, 1.025). \end{aligned}$$

Discussion

The method proposed in this work allows for converting control points between Bézier and Catmull–Rom definitions. This conversion can be applied in situations, where one of these mathematical representations is not supported in specific software implementations and thus allows to use data, such as 2D drawings, 3D camera trajectories or surfaces across individual software pipelines. For instance, the open source 3D creation suite Blender does not support Catmull–Rom curve primitivesFootnote 7 but it does support Bézier curves. Therefore, one of the many applications of the proposed method in this paper would be to convert the control points of a Catmull–Rom curve to the Bézier representation to be able to draw the curve in Blender.

This work has also some limitations. The proposed method is solely valid for cubic curve segments, i.e., curves which are defined by four control points. However, Bézier curves may be defined with an arbitrary number of control points and consequently, contain a higher degree polynomial. The advantage of lower degree polynomials is less computations during both the evaluation of the curve and the calculation of derivatives (comparing the definitions in Eqs. 1 and  2, the number of summations/loops depends on the degree of the curve). Therefore, the higher the degree, the higher the number of evaluations. To use our proposed method with higher degree curves, additional techniques such as Degree Reduction [26] or Curve Subdivision using De Casteljau’s algorithm [23] need to be applied to the curve prior to type conversion. Moreover, B-Splines might be utilized in many applications instead of Bézier splines, due to the fact that they could provide finer local shape control by introducing a knot vector. Even though there is a conversion method between B-Splines and Bézier splines [25], the authors are not aware of a method to directly convert between B-Splines and Catmull–Rom splines. Such generalizations to other spline representations are expected to be formulated in future research.

Conclusion

In this paper, we focused on conversion of control points of a cubic Bézier curve to those of a Catmull–Rom curve and vice versa. It was shown that, to do so, according to Eqs. 15 and 16, we merely need basic linear transformations of the positions of the control points. Moreover, we illustrated that the equations are valid for any timepoint and for control points with arbitrary number of dimensions.