Search Results

Home / Snippets / Texts

Polyhedral Modeling with Curved Domain Patches

A reimplementation and extension of a somewhat unfinished project by Jázmin Szörfi - see also the companion paper. This time the main part (auxiliary cage generation) is written in Scheme, while patch evaluation uses the CD-GB(S) library by Márton Vaitkus. Multiple Schemes are supported (chibi, gambit, guile, s7).

There is also a GUI for testing, a fork of my geometry framework. Should work on all major platforms.

Clone the repository with Git:

git clone https://github.com/salvipeter/molihua.git
Originally submitted: 2026.06.05.

Adaptive Marching Cubes Library

A minimalistic, but adaptive marching cubes library, to be used (e.g.) in my CSG Testbed.

Clone the repository with Git:

git clone https://github.com/salvipeter/marching.git
Originally submitted: 2025.01.21.

Elastica

Turns out that sine-generated curves are very similar "elastica" curves defined by the differential equation θ'' + λ sin θ = 0, where θ(s) is the tangent angle and s is the arc length. So I modified my programs to examine these curves.

Here's a Postscript program showcasing this curve family for a variety of λ values (also in PDF). See also R.L. Levien's thesis. There is also an interactive Tcl applet where you can use sliders to adjust the shape parameter, arc length and scaling.

Originally submitted: 2024.10.02.

Sine-Generated Curves

Let us take log-aesthetic curves, and use cosine instead of exponentiation. In their "standard form" (borrowing the term from LA curves), where the initial tangent angle is 0 and the initial curvature is 1, the Cesàro equation is simply k(s) = cos(s/c), where c is a constant. Turns out that these curves are called sine-generated curves, and are used in geophysics. But they are also fun.

Here's a Postscript program showcasing this curve family for a variety of c values (also in PDF). There is also an interactive Tcl applet where you can use sliders to adjust the shape parameter, arc length and scaling.

Note that sine-generated curves also satisfy a differential equation: θ'' + θ/c^2 = 0, where θ(s) is the tangent angle and s is the arc length. Using this it is even easier to evaluate these curves, see the modified programs I've written for elastica.

Originally submitted: 2024.09.28.

Polyhedral Design with Quadratic GB Patches

Code for my paper on this topic.

Clone the repository with Git:

git clone https://github.com/salvipeter/manifold.git
Originally submitted: 2024.04.10.

Focal Curve

A Tcl implementation of Paul de Casteljau's focal spline (with a Bézier curve for comparison).

Originally submitted: 2023.11.24.

Interpolating Catmull-Clark Subdivision

A simple geometric progressive interpolation method for any surface defined by a control polyhedron, exemplified by Catmull-Clark surfaces, where this actually converges.

This implementation (using the OpenMesh library) actually computes the surface in each iteration, which is very expensive, but in this way we don't need to know the equation for the final position of the vertices (which is nice, because the CC matrix near the boundary is poorly documented in the literature).

Originally submitted: 2023.10.17.

Applying Constraints to Quadmeshes

Two possible solutions to the problem of modifying a quadmesh such that all quads become planar, but the mesh remains close to the original. One is a regularized Newton method based on a paper by Tang et al., the other is an ICP-like algorithm by Bouaziz et al.

The programs use the OpenMesh library. See a pair of images with flat shading before and after the optimization.

Originally submitted: 2023.10.17.

Geometry Framework

A reorganized version of my Sample 3D Framework".

Download the current version with Git:

git clone https://github.com/salvipeter/geo-framework.git
Originally submitted: 2023.09.01.

LEGO Sculpture Generator

An experiment with my LDNI library to generate a LEGO-block version of a mesh model. Uses only 2x2 blocks, with user-defined resolution. See an example; note that there may be blocks floating in the air etc. With a little more change in the library, it is easy to generate a slice-by-slice output, as well (this example needs roughly 25000 blocks).

Originally submitted: 2023.05.29.

Direct B-Spline Modification

A small applet for experimenting with a direct B-spline modification algorithm from The NURBS Book. Uses GLUT and my geometry library.

Originally submitted: 2023.02.24.

Nielson's patch

A C++ implementation of Nielson's triangular transfinite patch, with mesh interpolation and fullness settings.

Clone the repository with Git:

git clone https://github.com/salvipeter/nielson.git
Originally submitted: 2022.12.22.

Quad fitting

A library & test program for fitting B-spline surfaces on genuine multi-sided patches. Does not work as well as hoped.

Clone the repository with Git:

git clone https://github.com/salvipeter/quadfit.git
Originally submitted: 2022.12.09.

Zheng-Ball patch

A C++ implementation of the Zheng-Ball transfinite patch, with a utility to convert from my .gbp (Generalized Bézier patch) format. See also my writeup on the tessellation.

Clone the repository with Git:

git clone https://github.com/salvipeter/zheng-ball.git
Originally submitted: 2022.11.23.

Quad Viewer

A fork of my 3D framework for viewing a collection of B-spline surfaces with exact normals & curvatures, isolines etc.

Clone the repository with Git:

git clone https://github.com/salvipeter/qds-viewer.git
Originally submitted: 2022.11.10.

Tetrapod

A tetrapod model created as the combination of implicit surfaces, suitable for 3D printing (see photo). Originally designed in Scheme, the final model is generated by a C++ program using my dual contouring library.

Originally submitted: 2022.09.05.

Fortune's Algorithm

A Tcl implementation of Fortune's algorithm for generating the Voronoi cell structure and Delaunay triangulation of a set of points in the plane. This is for demonstration purposes, with a movable beachline, showing also the circles. See a screenshot.

Originally submitted: 2022.02.20.

Bézier Matrices

Two libraries for computing Bézier-related matrices: (i) Bézier extraction matrices, for getting the control points of a given segment of a B-spline curves, and (ii) reduction matrices, for computing the optimal degree reduction (in an L2-norm sense) while retaining derivatives at the endpoints.

The extraction matrix library is written in C++, using Eigen and my geometry library; there is also a short memo on how to use it.

The reduction matrix library has an implementation in Julia and another one in C. In both cases the computations are exact, using rational bignums (with libGMP in the C version), so it should work even with high degrees.

There is also a library for approximating a high-degree Bézier curve with a lower-degree B-spline, with the given number of segments and continuity. This is just a showcase for the above two libraries.

Clone the repositories (extractions, reduction, approximation) with Git:

git clone https://github.com/salvipeter/bezier-extractions.git git clone https://github.com/salvipeter/bezier-reduction.git git clone https://github.com/salvipeter/bezier-bspapprox.git
Originally submitted: 2022.02.05.

Isoptic Surfaces

Isoptic surface generation for meshes, based on the PhD dissertation of Ferenc Nagy. Only a simple brute force approach is implemented, using my dual contouring library.

Clone the repository with Git:

git clone https://github.com/salvipeter/isoptic.git
Originally submitted: 2021.05.26.

Jet Fitting Wrapper

A wrapper over CGAL for convenient jet fitting based normal / curvature computation using my geometry library.

Clone the repository with Git:

git clone https://github.com/salvipeter/jet-wrapper.git
Originally submitted: 2021.05.25.

εκ-curves

A Julia implementation of εκ-curves, an extension of κ-curves, where the proximity can be controlled with an extra parameter. The video branch also allows the weight modification for individual points, and it contains the supplementary video available on the Springer website.

Clone the repository with Git:

git clone https://github.com/salvipeter/ekcurves.git
Originally submitted: 2021.05.19.

Curve Fitting and Proximity Curves

Originally started for trying out various cubic and quartic interpolation schemes, this little program also serves as a testbed for proximity curves (see the corresponding paper).

Clone the repository with Git:

git clone https://github.com/salvipeter/quartic.git
Originally submitted: 2021.04.29.

Interior Editing with Displacement Blends

A fork of my 3D framework for testing some ideas on editing the interior of transfinite interpolation surfaces using displacements multiplied by C-infinity blending functions. See also the related paper.

Clone the repository with Git:

git clone https://github.com/salvipeter/displacement.git
Originally submitted: 2021.02.01.

IPIA Implicit Fit

An implementation of the implicit progressive-iterative approximation algorithm of Hamza et al., using my geometry library.

Clone the repository with Git:

git clone https://github.com/salvipeter/ipia.git
Originally submitted: 2021.01.08.

Parabola Curvature Monotonicity

A small Racket applet that demonstrates the criterion for a parabolic arc to have monotonic curvature.

Originally submitted: 2020.10.05.

Vertebra Fit

A small C++ library to fit closed B-spline curves over a set of sampled points, some more important than the others (originally used for fitting vertebra contours).

Clone the repository with Git:

git clone https://github.com/salvipeter/vertebra-fit.git
Originally submitted: 2020.10.05.

Approximate G1/G2 Connections

A lightweight library for connecting B-spline patches with approximate G1/G2 continuity. Uses my geometry library.

Clone the repository with Git:

git clone https://github.com/salvipeter/bspline-connect.git
Originally submitted: 2020.07.01.

MidPoint Patch

An implementation of the MidPoint patch using my geometry library.

Clone the repository with Git:

git clone https://github.com/salvipeter/midpoint.git
Originally submitted: 2020.06.22.

Tensor-Product Conversion of Multi-Sided Patches

Test on converting Kato, Charrot-Gregory and S-patches into tensor-product rational Bézier surfaces. See also the related paper.

Clone the repository with Git:

git clone https://github.com/salvipeter/tensor-conversion.git
Originally submitted: 2020.05.22.

Implicit fitting

A test program in Julia for experimenting with fitting implicit surfaces on a boundary loop of (rational) polynomial curves, and maybe additional constraints. Uses my dual contouring library for generating meshes.

Clone the repository with Git:

git clone https://github.com/salvipeter/implicit-fit.git
Originally submitted: 2020.02.19.

Transfinite library

A C++ library for testing different transfinite interpolation surfaces.

Clone the repository with Git:

git clone https://github.com/salvipeter/transfinite.git
Originally submitted: 2020.02.19.

CSG Testbed

A testbed for playing with implicit surfaces, using my 3D framework and dual contouring library.

Models are built with scripts written in Scheme (Guile), which can be reloaded on-the-fly. See a screenshot of the elliptic blend of two cylinders, and the corresponding script.

Clone the repository with Git:

git clone https://github.com/salvipeter/csg-script.git
Originally submitted: 2020.02.04.

C0 Coons Patch

An implementation of the multi-sided C0 Coons patch, using my geometry library.

Clone the repository with Git:

git clone https://github.com/salvipeter/c0coons.git
Originally submitted: 2020.01.30.

Best Ellipse

A rational quadratic Bézier curve can represent ellipses, when the weight of the central control point is set to a value in (0,1). We like circles, so when the two control edges are the same length, we can set the weight such that the curve will be a circular arc. But what should we do when the edges have different lengths? It should behave continuosly, i.e., if we move a control point a little bit, the curve should remain almost the same.

Here is a JavaScript applet that shows two possible solutions. The circle weight is computed by an angle, and it can be extended to the general case in a straightforward manner (green curve). But one thing we like about circles, is that the ratio of its axes is 1 - so it is a natural idea to minimize the deviation of the major and minor axes, or the (1 - minor/major) function (blue curve).

The second method uses golden section minimization, and the computation involves solving a linear equation system, for which I have used a slightly modified version of the linear-solve library.

Originally submitted: 2020.01.15.

Isophote Texture Generation

A small program generating textures for isophote visualization, as used in my sample framework.

Clone the repository with Git:

git clone https://github.com/salvipeter/isophotes.git
Originally submitted: 2020.01.08.

Geometry Library

A minimal library containing the essential tools for geometry processing, such as 2D and 3D points/vectors, triangular meshes, B-spline curves, etc.

Clone the repository with Git:

git clone https://github.com/salvipeter/libgeom.git
Originally submitted: 2019.11.26.

Layered Depth-Normal Image Library

A library for creating a quasi-implicit representation from triangular meshes, with a compact file format. The mesh can be regenerated by cell-based contouring methods (dual contouring is implemented). The LDNI representation can be useful for Boolean operations or as a decimation tool.

Clone the repository with Git:

git clone https://github.com/salvipeter/ldni.git
Originally submitted: 2019.11.26.

Dual Contouring

A minimal C++ library to convert implicit surfaces (isosurfaces of real-valued functions in 3D space) into quadrilateral meshes. It is very basic, because (i) it is not adaptive, (ii) does not use derivatives, and (iii) creates only one point in each cell. Still, the resulting meshes are better quality than those created by marching cubes, and it is quite fast.

Clone the repository with Git:

git clone https://github.com/salvipeter/dual-contouring.git
Originally submitted: 2019.11.18.

Profile fitting

A Julia program for fitting a polyline on an unordered set of noisy points. It also provides methods for fitting segments and circular arcs (still in an early phase).

Clone the repository with Git:

git clone https://github.com/salvipeter/profile-fitter.git
Originally submitted: 2019.11.11.

Two Optimizations

Two (otherwise unrelated) optimizations using C++/Eigen.

The first fits a sphere with fixed radius on a set of 3D points. Download the source code, or see the htmlized version.

The second one takes a 2D B-spline curve embedded in 3D, and a direction for each control point. Then it computes a translation of the control points in the given directions in such a way that the integral of curvature (actually, the second derivative at discrete points) is minimal. Download the source code, or see the htmlized version.

Originally submitted: 2019.10.29.

Biharmonic S-patch

Two experiments with S-patches: (i) hole filling (C0 or G1 boundary constraints, and a special "biharmonic" mask on the interior control points), and (ii) CAD-compatible conversion. See also the related papers.

Clone the repository with Git:

git clone https://github.com/salvipeter/biharmonic-spatch.git
Originally submitted: 2019.01.21.

Circle Approximation with Cubic and Quartic Curves

An HTML5 applet to test two polynomial approximations of the circle as curves with fullness determined by 3 points. The red curve is a cubic approximation (approximating the circle at 68%), and the green one is a quartic (circle approximation at 50%).

Originally submitted: 2019.01.03.

Rotation Matrix Computation

Given 3 planes containing the origin, and 3 lines going through the origin, find the rotation matrix that rotates each line to the corresponding plane. The planes are represented by their (unit) normal vectors, while the lines by their (unit) direction vectors.

Download the source code, or see the Juno notebook version.

Originally submitted: 2018.12.03.

I-patch

A short implementation of I-patches in Julia, based on an old paper of my colleagues. The patch is exported as raw voxel data, visualizable in Paraview (here is a screenshot of an example used in the original article).

Download the source code, or see the htmlized version.

Originally submitted: 2018.09.01.

Maximum Entropy Library

A C library for evaluating the maximum entropy barycentric coordinates. Uses the the GSL library for optimization. I have also summarized the maximum entropy principle.

Clone the repository with Git:

git clone https://github.com/salvipeter/libmec.git
Originally submitted: 2018.06.16.

Bézier Triangle

This is a minimal C++ library for evaluating Bézier triangles.

Clone the repository with Git:

git clone https://github.com/salvipeter/bezier-triangle.git
Originally submitted: 2018.04.21.

Concave GB Patch Library

A C++ library for evaluating concave GB patches. Uses the harmonic library, as well as Shewchuk's Triangle.

Clone the repository with Git:

git clone https://github.com/salvipeter/concave-gb.git
Originally submitted: 2018.03.08.

[Bi]Harmonic Coordinates

A C library for computing (discretized) harmonic and biharmonic coordinates.

Clone the repository with Git:

git clone https://github.com/salvipeter/harmonic.git
Originally submitted: 2018.02.09.

2D Class A Curves

Actually there are two projects. One is about interpolating one curve segment, which can be a Class A Bézier curve or a logarithmic aesthetic curve (or LAC), the other is about interpolating points with a discrete clothoid spline. The former is written in Racket, like before, but the latter is written in Julia, in an attempt to try to create something non-trivial in it.

Clone the repository with Git (Bézier & LAC):

git clone https://github.com/salvipeter/class-a-curves.git

Clone the repository with Git (discrete clothoid):

git clone https://github.com/salvipeter/discrete-clothoids.git
Originally submitted: 2015.11.10.

Visualization of the "vision" transformation

A somewhat minimalistic 3D demo showing several aspects of the mathematics of how we see (projections). Uses Qt / QGLViewer for the GUI (see a screenshot).

Download the current version with Git:

git clone https://github.com/salvipeter/3dviz.git
Originally submitted: 2014.03.23.

Testbed for Pseudo-G2 Curves

This is a feasibility test for a research idea - basically how curves using curved ribbons give better curvature than those using linear ribbons. Two days before the abstract deadline I did not have time for elaborate programming, but I needed a GUI, graphics and some math. Once again, Racket came to the rescue. Using an earlier snippet as a base, I managed to implement this program in a few hours, with all its "bells & whistles" (see screenshot).

Download the source code, or see the htmlized version.

2012.10.09.: This little project got a lot bigger since its first version, and now it has earned its own repository - you can download the latest version with Git:

git clone https://github.com/salvipeter/pseudo-g2.git
Originally submitted: 2012.09.29.

Sample 3D Framework

A minimal 3D framework for creating simple applications (intended for class use). Uses Qt / QGLViewer for the GUI and OpenMesh for the mesh data structure (see a screenshot).

Download the current version with Git:

git clone https://github.com/salvipeter/sample-framework.git
Originally submitted: 2012.04.28.

Marching Squares

Another applet written in Racket - this time a demonstration of the basic marching squares algorithm (without any heuristics), applied for displaying 3rd-degree implicit functions (see a screenshot).

Download the source code, or see the htmlized version.

Originally submitted: 2011.11.11.

Pythagorean Hodograph Curves

A simple demo for quintic PH curve interpolation, implemented in Racket. Its features include exact arc-length computation and displaying the curve's (explicit rational Bézier) offset curves (see a screenshot).

Download the source code, or see the htmlized version.

Originally submitted: 2011.10.24.

Polygon subdivision

A JavaScript demonstration of three trivial subdivision algorithms (Chaikin with two weight sets, and 4-point interpolation). The program was a feasibility test of JS programming using CL-WHO and ParenScript that makes use of advanced widgets, events and macros.

Try the JavaScript code, download the source code, or see the htmlized version.

There is also a (manually) modified version used as a test of the parabola's parametric equation.

Originally submitted: 2011.04.03.

2022.09.28.: Correct end conditions for the Chaikin subdivisions are now implemented.

Delaunay Triangulation

This is a demonstration of the (easiest) incremental approach to Delaunay triangulation, written entirely in PostScript. It uses user-given or random points, generating a sequence of "slides" that explain how this method works. The code may need some polishing, since it was a (relatively) fast hack.

Download the EPS file, a PDF conversion for random data, or see the htmlized source.

Originally submitted: 2011.02.16.

SFView

SFView (Surface Viewer) is a utility that I needed very much - it loads NxM grids of 3d points or NURBS surfaces and displays them in a common OpenGL window. There are several display modes, including slicing map, isophote map and mean curvature map, and it can also take PNG screenshots with transparent background. See a screenshot.

It handles RBN (see CL-NURBS for its specification) and PTS files. The latter one is of the format:

M N Point1-x Point1-y Point1-z Point2-x Point2-y Point2-z ...

I tried to follow the GNU standards while making this, so it has all the standard command line arguments and also a manual page.

Download the source code for version 0.35 or get the latest with Git:

git clone https://github.com/salvipeter/sfview.git
Originally submitted: 2009.07.27.

Linear Least Squares Example

An example program I wrote for a friend of mine to demonstrate multi-parameter linear least squares approximation using the GSL library. The package also contains HTMLized source code and a documentation that states the problem and explains some simple mathematics behind the solution. Extension of its features is left as an exercise to the reader.

Originally submitted: 2008.05.19.

CL-NURBS

A NURBS library in Common Lisp. It handles both curves and surfaces; it can generate PostScript output for curves and VTK files for surfaces. It also has an own file format (RBN) for storing NURBS (as opposed to mesh) data (see here for its specification).

Features include point / vector operations, curve and surface evaluation, derivation, curvature calculation, algorithms for creating continuity between surfaces and fairing with downhill simplex method, knot removal/reinsertion and fitting. See a screenshot.

Download the source code for the stable release or get the development version with Git:

git clone https://github.com/salvipeter/cl-nurbs.git

Note that these packages don't include the fitting library, which is the property of Geomagic, Inc., and because of this, some functions of CL-NURBS cannot be used.

Originally submitted: 2008.02.28.

GLUT Demos

C++ / GLUT implementation of Bézier curves, Aitken-Lagrange interpolation, B-spline curves and global B-spline curve interpolation.

Download the c++ source code. You can also download a Lisp version of the Bézier curve demo (with only the deCasteljau algorithm, and no popup menu), or see its htmlized version.

Originally submitted: 2007.11.15.

Triangle Strip

Tried my hand at Vtk programming. Just a GUI for viewing a triangle strip, that can be lengthened or shortened using a slider.

Download the source code or see the htmlized version.

Originally submitted: 2007.10.10.

Copyright (C) 2007-2026 Peter Salvi