Questions tagged [computational-geometry]

Questions on constructing graphical objects using relatively complex computations relating to the mathematical structures defining those objects. Examples include convex hulls, Voronoi diagrams, Delaunay triangulations, mathematical constructions, symmetries, genuses of curves and graphs and programmatic constructions of polyhedra.

See the general reference on Computational Geometry and Geometric Computation.

Mathematica provides a lot of functionality related to computational geometry. It includes:

Note
As of Version 10, all the functionality of the ComputationalGeometry package is built into the Wolfram System.

739 questions
40
votes
5 answers

Site - Cell Correspondence in Voronoi Diagram obtained via VoronoiMesh

Consider the following: pts = RandomReal[4, {10, 2}]; vor = VoronoiMesh[pts, {{0, 4}, {0, 4}}]; Graphics[{GraphicsComplex[ MeshCoordinates[vor], {Thick, Blue, MeshCells[vor, 1], PointSize[0.02], Red, MeshCells[vor, 0], Opacity[0.2], Yellow,…
RunnyKine
  • 33,088
  • 3
  • 109
  • 176
28
votes
6 answers

Find the nearest locations for multiple points

Assume that there are many holes with their locations fixed, and the same number of balls distributed randomly. What is the smallest total distance for the balls fitting into the holes on the precondition that each hole can only fit one ball? For…
novice
  • 2,325
  • 1
  • 24
  • 30
21
votes
4 answers

How to find the incircle and circumcircle for an irregular polygon?

I was inspired by blog post where Gonzalo Ciruelos sorted all the countries by roundness, and looked at the Wikipedia page that gives a different definition of roundness to what Ciruelos used: The ISO definition of roundness is based on the ratio…
Jason B.
  • 68,381
  • 3
  • 139
  • 286
21
votes
3 answers

How to generate higher dimensional convex hull?

I like the function ConvexHullMesh very much, since I often need to take a look at the convex hull of points in 2D and 3D, which as an example can be generated and tested with the following code (*Dimension and number of points*) d = 2; np =…
Mauricio Fernández
  • 5,463
  • 21
  • 45
16
votes
3 answers

Finding the perimeter, area and number of sides of a Voronoi cell

Does anyone have any suggestions how to determine the perimeter, area and number of sides of each Voronoi cell in Voronoi diagram?
DeeDee
  • 807
  • 8
  • 13
16
votes
6 answers

Is there a simple strategy to determine whether a point is inside a boundary?

For a ellipse $E(\theta)$, which owns the parametric equation as follows: $\begin{cases} x = a \sin\theta + b \cos\theta + c \\ y = d \sin\theta + e \cos\theta + f \\ \end{cases}$ Now, I have a point $P=\{x_p,y_p\}$, to know the relationship…
xyz
  • 605
  • 4
  • 38
  • 117
15
votes
4 answers

Better way to calculate angle between lines?

I wrote anglecalc to calculate the clockwise angle from line a to b. Initially I thought VectorAngle would do it, but I had to add extra functionality. Is there a simpler way? rotationangle[{i_, j_}] := Which[ i >= 0 && j >= 0, VectorAngle[{1,…
Chris Degnen
  • 30,927
  • 2
  • 54
  • 108
13
votes
5 answers

Getting ordered coordinates out of ConvexHullRegion

I'm trying to get the ordered coordinates of a convex hull using MeshCoordnates[ConvexHullMesh[data]], but the coordinates are uselessly out of order: With[{d = RandomReal[{0, 1}, {20, 2}]}, ListPlot[ d, AspectRatio -> 1, Epilog ->…
ZachB
  • 1,200
  • 9
  • 19
12
votes
6 answers

How to check if a line segment intersects with a polygon?

The naive method is to bisect the line segment iteratively as asked here, and then check the bisection points using How to check if a 2D point is in a polygon?. Would there be an other way? I'm using v9. For example, list = {{4.4, 14}, {6.7, 15.25},…
novice
  • 2,325
  • 1
  • 24
  • 30
12
votes
2 answers

Smooth convex hull of a large data set of 3D points

I recently needed to deal with a large data set of 600,000 points in three dimensions. My task was to find a convex hull for this data. I have Mathematica 10, so I could use the function ConvexHullMesh; I obtained this: I was wondering if there is…
10
votes
1 answer

Voronoi grid on a sphere

If I have a set of points which lie on the unit sphere: data = Normalize /@ RandomReal[1, {100, 3}] How do I go about computing Voronoi cells on a sphere? I know that there are algorithms in other languages, but are they difficult to implement in…
Morgan
  • 525
  • 2
  • 10
9
votes
1 answer

Art Gallery Problem for the Castro's $24$-sided room

Art Gallery Theorem. If the walls of an art gallery are made up of $n$ straight line segments, then the entire gallery can always be supervised by $\lfloor{\frac{n}{3}}\rfloor$ watchmen placed in corners. How can I find…
vito
  • 8,958
  • 1
  • 25
  • 67
9
votes
3 answers

How to check if a 3D point is in a planar polygon?

Following up on ndroock1's question, I naively tried to apply the solutions to a 3D point and polygon and they didn't work. For example, functions involving ArcTan that are used in kguler's answer don't work with three arguments, Mac's answer…
Eli Lansey
  • 7,499
  • 3
  • 36
  • 73
8
votes
1 answer

How to draw Kobon triangles

I would like to know if Mathematica is capable of constructing Kobon triangles; that is, a figure consisting of the largest number of non-overlapping triangles that can be constructed using $n$ lines, $n\geq3$. It has been established that such a…
user35019
8
votes
1 answer

How to unite polygons of the same color into a single polygon?

Let a partition of a planar polygon into colored polygons be given, i.e. something similar to We know the coordinates of the vertices and the color of each part, e. g. in such a way Graphics[{EdgeForm[Black], Red, Polygon[{{0, 0}, {0, 2}, {2, 2},…
user64494
  • 26,149
  • 4
  • 27
  • 56
1
2 3 4 5 6