Arxiv:2011.08232V2 [Cs.GR] 28 Jun 2021
Total Page:16
File Type:pdf, Size:1020Kb
Conversion Between Cubic Bezier Curves and Catmull–Rom Splines Soroosh Tayebi Arasteh1,2 · Adam Kalisz1 Abstract Splines are one of the main methods of mathe- and flexible, when implemented in a computer software. Es- matically representing complicated shapes, which have be- pecially with curves, a software engineer is usually presented come the primary technique in the fields of Computer Graph- with a plethora of possible shape representations to choose ics (CG) and Computer-Aided Geometric Design (CAGD) from. The wide range of candidates and their specific advan- for modeling complex surfaces. Among all, Bezier´ and Cat- tages and disadvantages motivate the application of this work. mull–Rom splines are the most common in the sub-fields of A brief overview of the main purpose of curves and splines as engineering. In this paper, we focus on conversion between well as the necessity of a conversion method in engineering cubic Bezier´ and Catmull–Rom curve segments, rather than fields will prepare the reader for the subsequent theory and going through their properties. By deriving the conversion evaluation part within this paper. equations, we aim at converting the original set of the con- Designers in the car industry often need to construct clay trol points of either of the Catmull–Rom or Bezier´ cubic models or sketches of vehicles, where the mathematical rep- curves to a new set of control points, which corresponds to resentation needs to allow for interactive modifications to approximately the same shape as the original curve, when curve properties, such as curvature and continuity. Further- considered as the set of the control points of the other curve. more, one of the key properties of the available mathemati- Due to providing simple linear transformations of control cal representations is the distinction between interpolating points, the method is very simple, efficient, and easy to im- and approximating curves [10]. This property is related to plement, which is further validated in this paper using some whether a curve goes through its Control Points or not and numerical and visual examples. can be observed as one of the main differences between the two shape representations discussed in this work. Indeed, Keywords Bezier´ curves · Catmull–Rom splines · Computer the reason for conducting this research was the need to sup- aided design · Computer graphics port two different curve representations in a common file format, and therefore, the remainder of this paper is focused 1 Introduction on proposing a closed-form conversion equation. Furthermore, according to the German Association of 1.1 Motivation the Automotive Industry (VDA)1, different manufacturers and their subcontractors have different geometric modeling One of the main challenges in computer-aided design is find- systems for curve and surface representations. Thus, another ing a suitable shape representation which is both performant motivating view on exchanging data between different geo- metric modeling systems to compensate differences in the This is the pre-print version. The main article is published in SN Computer Science: https://link. types of polynomial bases, maximum polynomial degrees springer.com/article/10.1007/s42979-021-00770-x and mesh sizes of curve and surface representations is dis- DOI: https://doi.org/10.1007/s42979-021-00770-x cussed more thoroughly in [14]. Soroosh Tayebi Arasteh and Adam Kalisz have contributed equally to arXiv:2011.08232v3 [cs.GR] 31 Jul 2021 this study. Soroosh Tayebi Arasteh is the corresponding author. 1.2 Engineering Purpose and Related Work 1Department of Electrical, Electronic, and Communication Engineering, As the field of Computer Graphics (CG) develops, techniques Information Technology (LIKE), Friedrich-Alexander-Universitat¨ for modeling complex curves and surfaces are being increas- Erlangen-Nurnberg,¨ Am Wolfsmantel 33, 90158 Erlangen, Germany ingly important. An example may be the rendering of highly 2Harvard Medical School, 25 Shattuck St, Boston, MA 02115, detailed landscapes which need to be subdivided (tessellated) USA depending on the viewing distance to reduce the process- ing time for a geometry that is barely visible from the cur- E-mail: rent camera viewpoint [12, 30]. One of the major techniques [email protected] [email protected] 1 In German: Verband der Automobilindustrie. 2 S.T. Arasteh, et al. to realize such dynamic tessellation algorithms is the use 1.3 Paper Structure and Contributions of parametric splines in which a curve is defined by piec- ing together a succession of curve segments, and especially, In this paper, we do not go through the properties and details surfaces defined by stitching together a mosaic of surface of Bezier´ and Catmull–Rom Splines, but rather the aim is patches [1]. to focus on the conversion equations. First, we give a brief explanation of Bezier´ curves in Sec.2 as well as a brief Splines are a mathematical means of representing a com- explanation of Catmull–Rom Splines in Sec.3. Then, we plex curve. For example, it is not possible to define a circle go through the conversion equations in Sec.4. Note that using only a single cubic Bezier´ curve. Therefore, a com- by conversion, we mean conversion of control points of a mon approximation to model a circle is to use four Bezier´ curve to the control points of another curve, which results curve segments [7]. Eventually, a complete path can be de- in approximately the same curve as the curve before conver- fined using a series of points at intervals along the curve sion represents3. In Sec.5, we validate the equations with segments and defining a function that allows to interpolate some numerical and graphical examples. We use bold-face along the curve to retrieve additional points within each inter- notation for vector representation here. Sec.6 discusses the val to be calculated. This is often the first step when creating conversion equations with regard to the real-world applica- procedural virtual worlds, i.e., generating smooth and infi- tions and the limitations and proposes some potential future nite highways using Catmull–Rom splines in games [8]. The work. Finally, the conclusions are stated in Sec.7. impressive power of splines is demonstrated when proce- dural landscapes and roads are combined to create entire virtual city models randomly, as can be seen, for instance 2 Bezier´ Curves in the SceneCity Blender addon2. As seen with the CG ex- amples, it is possible to generate paths and surfaces using There are two basic ways of defining a curve—in terms of splines. In addition, Splines can be used to animate objects or the polygon vertices, and in terms of the polygon sides [10]. virtual cameras along predefined paths [27]. Recently, the re- Even though, the latter is the form, which was originally used search community involved in solving the inverse problem to by Pierre Bezier´ [2–4], we consider the former throughout CG, namely, Computer Vision (CV), increasingly discovers our paper. There are two reasons for developing a formula- splines for recovering the real camera movement from image tion of the Bezier´ curve in terms of polygon vertices rather sequences. In robotics, related research is often concerned than polygon sides. To begin with, the formulation becomes with solving the visual Simultaneous Localization And Map- more elegant. Furthermore, as a general principle, it is better ping (SLAM) problem. However, since cameras usually take to program in terms of absolute vectors rather than a chain of pictures at specific points in time, the resulting estimated relative vectors, irrespective of the particular user interface, trajectory is discrete. Imposing constraints on the camera when transformations such as rotation are to be applied to path using splines has shown advantages in handling a com- the vectors, because rounding errors do not have the cumu- mon image sensor deficiency called rolling shutter, where lative effect which sometimes give rise to poor drawings. the image exhibits a pixel warping deformation (informally This can be particularly noticeable when transformations are often called a Jello Effect) due to a rowwise exposure [5]. performed, for reasons of speed, in a small satellite graphics Describing the camera trajectory using continuous B-splines computer [10]. offers the advantage that any exposure time along the path A parametric Bezier´ curve is defined by its control points. can be interpolated and thus allows for correcting the rolling The curve does not necessarily go through the control points. shutter for both monocular [24] and stereo (RGB-D) [20] There may be 2, 3, 4 or more. For instance, Fig.1 shows cameras. To predict and plan the future paths for Automated a linear, a quadratic, and cubic Bezier´ curve, respectively. Driving Systems (ADS), while taking into account obstacles The figures are drawn using a geometric approach called ”de and driving comfort, it was shown that Bezier´ curves are a Casteljau’s algorithm”. It is the most common approach for reliable solution for an optimal trajectory generation [11, 21]. drawing Bezier´ curves in CAGD. For more details on the This short review of interdisciplinary research contains algorithm, see [9]. many different types of spline representation, such as Bezier´ [7, A cubic Bezier´ curve can be written in a matrix form 11,21], Catmull–Rom [8], B-Splines [20,24] and Non-uniform by expanding the analytic definition of the curve into its Rational B-Spline (NURBS) [12] surfaces. This shows the Bernstein polynomial coefficients, and then writing these relevance of providing conversion methods between the vari- coefficients in a matrix form using the polynomial power ba- 4 ous representations of which one is discussed in this paper. sis [15]. The Bernstein polynomials of degree n are defined by Eq.1. For more details on B ezier´ curves, see [18]. 3 To encourage reproducibility, the source code of the project is pub- 2 SceneCity is a procedural city generation addon for Blender avail- licly accessible here: https://github.com/starasteh/bezier catmullrom/ able at: https://www.cgchan.com/ 4 For more information on the Bernstein polynomials, see [9, 16, 28].