Skip to main content
43 votes
Accepted

How to perform Loop subdivision on a triangle mesh with Mathematica?

We need quite a bit of preparation. In the first place we need methods to compute cell adjacency matrices from here. I copied the code for completeness. ...
Henrik Schumacher's user avatar
42 votes
Accepted

Can Mathematica solve Plateau's problem (finding a minimal surface with specified boundary)?

Here is a method that utilizes $H^1$-gradient flows. This is far quicker than the $L^2$-gradient flow (a.k.a. mean curvature flow) or using FindMinimum and friends, ...
Henrik Schumacher's user avatar
40 votes
Accepted

How to exactly calculate the volume?

No numerics hacks here; this really computes the volume symbolically. It is a bit tedious and demands some tricks which may appear more obvious in this answer than they would really be on the first ...
kirma's user avatar
  • 19.1k
36 votes

How to estimate geodesics on discrete surfaces?

Geodesics in Heat Algorithm At the suggestion of @user21 I am splitting up my answers to help make the code(s) for calculating geodesics distances easier to find for other people interested in these ...
Dunlop's user avatar
  • 4,083
33 votes
Accepted

How to speed up estimation of Mean and Gaussian curvatures on triangular meshes?

Note added 1/29/2020: the routines here have a bug where the mean curvature is sometimes computed with the opposite sign. I still need to work on how to fix this. I guess I should not have been ...
J. M.'s missing motivation's user avatar
28 votes
Accepted

Project map to a particular shape

If the domain $\varOmega$ of the county is simply connect, one might use the Riemannian mapping theorem. For $z_0 \in \varOmega^\circ$, we make the following ansatz for the holomorphic map $f \colon \...
Henrik Schumacher's user avatar
27 votes
Accepted

Catmull-Clark and Doo-Sabin Subdivision Implementations

Catmull-Clark Subdivision Indeed, I have some code for Catmull-Clark subdivision and I planned to post it here for quite some time. This seems to be a good opportunity. The code is optimized for ...
Henrik Schumacher's user avatar
24 votes
Accepted

How to estimate geodesics on discrete surfaces?

Nothing really new from my side. But since I really like the heat method and because the authors of the Geodesics-in-Heat paper are good friends of mine (Max Wardetzky is even my doctor father), here ...
Henrik Schumacher's user avatar
24 votes
Accepted

Better way to calculate angle between lines?

This passed all test cases, I think: anglecalc[vec1_, vec2_] := Mod[(ArcTan @@ vec2) - (ArcTan @@ vec1), 2 π]
LLlAMnYP's user avatar
  • 11.5k
24 votes
Accepted

Reproducing Ómar Rayo's "Fresh Fog" Painting

Using a "dirty" gradient. ...
azerbajdzan's user avatar
23 votes
Accepted

Making a graph or network interactively over an image

There are many ways to do this, modifying, improving my method or doing a completely different thing. My goal here is to show a very basic idea that should give you a start. ...
Vitaliy Kaurov's user avatar
23 votes
Accepted

Divide a geometric region by (many) lines

You can find symbolic connected components (which are those regions you are asking about) in this case using CylindricalDecomposition. This can be a bit of an ...
kirma's user avatar
  • 19.1k
23 votes
Accepted

Paul Klee's Notebooks: Loops Around Control Points

...
azerbajdzan's user avatar
22 votes

How to extract parts from atomic expressions like DelaunayMesh and Graph?

Motivation Recently, I wanted to extract parts of an atomic expression, and my first thought was to use a ToExpression/ToString ...
Carl Woll's user avatar
  • 131k
22 votes

How to speed up estimation of Mean and Gaussian curvatures on triangular meshes?

It took me a while, but the suggestion of @Michael E2 was quite helpful, and especially the post (Optimize inner loops). For those of you (like me) who are new to this style of programming in ...
Dunlop's user avatar
  • 4,083
22 votes

How to generate approximately equally spaced points efficiently

Many solutions similar to how to get $n$ equidistributed points on the unit sphere are possible, especially if one can accept that points are not on the edges of a region. For instance, one can use ...
kirma's user avatar
  • 19.1k
21 votes

Find duplicates in list of InfiniteLine

DeleteDuplicates[lines, RegionWithin] {InfiniteLine[{{0, 0}, {1, 0}}], InfiniteLine[{{0, 1}, {1, 0}}]} Also ...
kglr's user avatar
  • 399k
21 votes

Converting a Sierpinski tetrahedron to a Graph

A natural and simple way to approach this problem, assuming that your SiPyramid function has been defined, is as follows: ...
Mark McClure's user avatar
  • 32.5k
21 votes
Accepted

How to generate approximately equally spaced points efficiently

Annealing Found this to be an interesting question and immediately I thought it to be a good application for simulated annealing. Here's a little unoptimized annealing function I wrote. The idea is ...
Kelly Lowder's user avatar
20 votes
Accepted

How to get a specified number of points that are nearly equally spaced in a closed rectangle

There is a neat (and widely known) trick to produce n approximately evenly distributed points in a disk, or on any surface of revolution. Points are placed on a ...
Szabolcs's user avatar
  • 236k
20 votes

How to exactly calculate the volume?

Surprisingly, the volume of this complicated shape can be computed analytically. Some steps exceed MA capabilities, however, using arbitrary precision (I check up to 200 digits) arithmetics one can ...
yarchik's user avatar
  • 19.2k
20 votes
Accepted

Bridget Riley - Movement in Squares and Circles

Since I like the color image more than the black-and-white... ...
azerbajdzan's user avatar
20 votes
Accepted

How to draw a number of circles inscribed in a square so that the sum of the radii of the circle is greatest?

We only test n=5,n=6. We need three varaibles {x[i],y[i],r[i]} to determint a circle. Set ...
cvgmt's user avatar
  • 77.7k
19 votes

Determine whether points lie within a cow

One way is to compute the solid angle subtended by the cow viewed at the point by summing signed solid angles corresponding to the cow's polygonal faces. If the total is 4 pi, the point is inside the ...
Bob Werner's user avatar
19 votes
Accepted

How to construct a 3D 10-sided Die (Pentagonal trapezohedron) and Spin to a face?

Edit - forgot to add a necessary link Coincidentally I had a little personal project trying to make a good dice roller in Mathematica a while back. Here's some of my code (note: this was before I ...
lowriniak's user avatar
  • 2,412
19 votes

Voronoi tessellations on meshed surfaces

Using the Geodesics in Heat Algorithm implemented here, we can calculate the distances of all vertices on the surface to a given vertex. By repeating this algorithm on a selected subset of vertices on ...
Dunlop's user avatar
  • 4,083
19 votes

Catmull-Clark and Doo-Sabin Subdivision Implementations

Doo-Sabin Subdivision To my own surprise, Doo-Sabin subdivision is in many ways much easier to implement than Catmull-Clark subdivision. The only real problem I met was to compute the faces created at ...
Henrik Schumacher's user avatar
19 votes
Accepted

GeometricTest doesn't work in ellipse

Yep, it's a simple mistake by WRI, that is, a bug. ...
Michael E2's user avatar
  • 239k
19 votes
Accepted

Efficiently Mowing Grass with Mathematica

This is just starting ideas for arbitrary regions. Perhaps you can improve it. Version 1 Define concave region with holes, which can be generalizable to arbitrary complexity: ...
Vitaliy Kaurov's user avatar
18 votes

How to estimate geodesics on discrete surfaces?

Here is an exact algorithm but heavier to implement and to optimise. I chose to implement the "Line of Sight Algorithm" from Balasubramanian, Polimeni and Schwartz (REF). Exact Line of Sight ...
Dunlop's user avatar
  • 4,083

Only top scored, non community-wiki answers of a minimum length are eligible