Questions tagged [geometry]

This challenge is intended to be solved by using, manipulating, or creating shapes or other geometric structures.

Filter by
Sorted by
Tagged with
9 votes
6 answers
938 views

Calculate the Distance to a Line Segment

The Challenge Given two vertexes and a point calculate the distance to the line segment defined by those points. This can be calculated with the following psudocode ...
ATaco's user avatar
  • 10.2k
20 votes
9 answers
2k views

Cutting a Circular Pizza Vertically

Most people would cut circular pizzas into circular sectors to divide them up evenly, but it's also possible to divide them evenly by cutting them vertically like so, where each piece has the same ...
Yousername's user avatar
  • 3,430
11 votes
4 answers
350 views

Generate the vertices of a geodesic sphere

As in this challenge, the task is to generate the vertices of a polyhedron. The polyhedron here is the one obtained by dividing a regular icosahedron's triangular faces into smaller triangles so that ...
Karl's user avatar
  • 621
25 votes
15 answers
2k views

Vertices of a regular dodecahedron

A regular dodecahedron is one of the five Platonic solids. It has 12 pentagonal faces, 20 vertices, and 30 edges. Your task is to output the vertex coordinates of a regular dodecahedron. The size, ...
alephalpha's user avatar
  • 45.6k
14 votes
8 answers
1k views

Euclidean distance on projective plane

Motivated by this challenge Background Let we have a square sheet of flexible material. Roughly speaking, we may close it on itself four ways: Here the color marks the edges that connect and the ...
lesobrod's user avatar
  • 3,231
22 votes
25 answers
4k views

Given 4 fence lengths, what's the largest rectangular yard you can make?

Here's a very simple little problem that I don't believe has been asked before. Challenge Write a program or a function that takes in four positive integers that represents the lengths of movable but ...
blaketyro's user avatar
  • 769
22 votes
20 answers
2k views

Calculate Euclidean distance on a torus

Euclidean distance between two lattice points \$(x_1, y_1)\$ and \$(x_2, y_2)\$ on a plane is: \$\sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2}\$. Imagine now a lattice ...
anatolyg's user avatar
  • 13.1k
12 votes
5 answers
417 views

Enumeration of free polyominoes

A polyomino with \$n\$ cells is a shape consisting of \$n\$ equal squares connected edge to edge. No free polyomino is the rotation, translation or reflection (or a combination of these ...
math scat's user avatar
  • 7,939
17 votes
7 answers
1k views

Draw the GKMS aperiodic tile

Chaim Goodman-Strauss, Craig Kaplan, Joseph Myers and David Smith found the following simple (both objectively and subjectively) polygon that tiles the plane, but only aperiodically: Indeed they ...
Parcly Taxel's user avatar
  • 3,707
16 votes
6 answers
1k views

Detect round trips on a hyperbolic grid

You're driving a car in an infinite city whose blocks are pentagons arranged in the order-4 pentagonal tiling. At each step, you proceed to the next intersection and choose whether to continue left, ...
Karl's user avatar
  • 621
10 votes
3 answers
601 views

Voronoi-Lloyd ASCII art [closed]

Voronoi diagram is a partition of a plane (or part of plane) into regions close to each of a given set of objects ("seeds"). Here we’ll be dealing with discrete arrays or even rather with ...
lesobrod's user avatar
  • 3,231
5 votes
2 answers
241 views

Canonical form of a cubic Bézier curve

On Pomax's Primer on Bézier Curves this "fairly funky image" appears: This is related to the fact that every cubic Bézier curve can be put in a "canonical form" by an affine ...
Parcly Taxel's user avatar
  • 3,707
4 votes
1 answer
187 views

4D rotation matrix to quaternions

It is well-known that a 3D rotation can always be represented by a quaternion. It is less well-known that a 4D rotation can always be represented by two quaternions, sending a point \$p=(a,b,c,d)^T\$ ...
Parcly Taxel's user avatar
  • 3,707
9 votes
5 answers
452 views

3D rotation matrix to quaternion

There are multiple ways to represent a 3D rotation. The most intuitive way is the rotation matrix – $$A=\begin{bmatrix}A_{11}&A_{12}&A_{13}\\A_{21}&A_{22}&A_{23}\\A_{31}&A_{32}&...
Parcly Taxel's user avatar
  • 3,707
5 votes
2 answers
868 views

How spherical is my ellipsoid?

Define the (unnormalised) Willmore energy of a surface as the integral of squared mean curvature over it: $$W=\int_SH^2\,dA$$ For surfaces topologically equivalent to a sphere \$W\ge4\pi\$, and \$W=4\...
Parcly Taxel's user avatar
  • 3,707
16 votes
4 answers
1k views

Create a triangle whose colors are determined by the bitsums of coordinates

Write a program that, for any \$n\$, generates a triangle made of hexagons as shown, \$2^n\$ to a side. The colors are to be determined as follows. We may give the triangle barycentric coordinates so ...
Akiva Weinberger's user avatar
18 votes
8 answers
2k views

Roll a painted cube

There is a 1x1x1 cube placed on a infinite grid of 1x1 squares. The cube is painted on every side, so it leaves a mark on the grid when it moves. The sides of the cube are colored 6 distinct colors, ...
mousetail's user avatar
  • 11.4k
18 votes
4 answers
657 views

Intersection area of two rotated rectangles

Given two rectangles, which are possibly not in the orthogonal direction, find the area of their intersection. Input You may take the rectangles as input in one of the following ways: The ...
alephalpha's user avatar
  • 45.6k
12 votes
6 answers
898 views

ASCII-art polygons to GeoJSON coordinates

We're going to turn ascii art versions of polygons into their equivalent GeoJSON. The ASCII shape language The input ASCII language only has 3 possible characters: ...
Hannesh's user avatar
  • 1,225
23 votes
8 answers
1k views

Rolling a 1x1x2 block

Rolling a 1x1x2 block This challenge is inspired by the game Bloxorz. Like that game, there is a 1x1x2 block, which may be moved on a square grid in any of the four cardinal directions. It moves by ...
AlephSquirrel's user avatar
5 votes
2 answers
209 views

Transform a lattice polygon to minimum diameter by shearing

Given is a grid polygon by the list of its integer vertex coordinates arranged along the perimeter, in the form \$(x_1,y_1), (x_2,y_2), \cdots , (x_n,y_n)\$ with \$n \ge 3\$. The polygon is completed ...
Hugo Pfoertner's user avatar
20 votes
7 answers
2k views

The smallest area of a convex grid polygon

I got an email from Hugo Pfoertner, an Editor-in-Chief at the On-Line Encyclopedia of Integer Sequences, with a terrific idea for a fastest-code challenge, which will also help verify or expand the ...
Peter Kagey's user avatar
  • 8,649
15 votes
5 answers
939 views

Detect round trips on a dodecahedron

An ant starts on an edge of a dodecahedron, facing parallel to it. At each step, it walks forward to the next vertex and turns either left or right to continue onto one of the other two edges that ...
Karl's user avatar
  • 621
24 votes
34 answers
2k views

Triangle area from side lengths

Output the area \$A\$ of a triangle given its side lengths \$a, b, c\$ as inputs. This can be computed using Heron's formula: $$ A=\sqrt{s(s-a)(s-b)(s-c)}\textrm{, where } s=\frac{a+b+c}{2}.$$ This ...
xnor's user avatar
  • 144k
7 votes
2 answers
283 views

Find the Circle-Tangent Polynomials

Introduction A circle-tangent polynomial is a polynomial of degree \$N\ge3\$ or above that is tangent to the unit circle from inside at all of its N-1 intersection points. The two tails that exits the ...
Shieru Asakoto's user avatar
19 votes
7 answers
2k views

Matrix Meets ASCII Art

A binary matrix represents a shape in the plane. 1 means a unit square at that position. 0 means nothing. The background is 0. For example, the array ...
Number Basher's user avatar
14 votes
7 answers
1k views

Euler characteristic of a binary matrix

A binary matrix represents a shape in the plane. 1 means a unit square at that position. 0 means nothing. The background is <...
alephalpha's user avatar
  • 45.6k
8 votes
6 answers
495 views

Calculate the overlapping line

(l, r) defines a line whose left end is at l and the right end is at r, on a 1-dimensional ...
xiver77's user avatar
  • 2,325
17 votes
12 answers
2k views

Random Point from a 2D Donut Distribution

A donut distribution (for lack of a better term) is a random distribution of points in a 2-dimensional plane, forming a donut-like shape. The distribution is defined by two parameters: the radius <...
Jitse's user avatar
  • 6,866
10 votes
3 answers
331 views

Coordinates for a Heronian tetrahedron

Did you know that Heronian Tetrahedra Are Lattice Tetrahedra? A Heronian tetrahedron is a tetrahedron where the length of each edge is an integer, the area of each face is an integer, and the volume ...
Peter Kagey's user avatar
  • 8,649
17 votes
7 answers
482 views

Score a curling end

Curling is a sport where two teams aim to place stones as close to the centre of a target as possible. The winner of a curling end is the team whose stone is closest to the centre – they score as many ...
Parcly Taxel's user avatar
  • 3,707
21 votes
4 answers
912 views

Is this hexagon symmetric?

TLDR: This is the hexagonal version of Is this square symmetrical? Given a hexagonal grid, decide if it is symmetric. The shape of the grid is a regular hexagon. Each cell in the grid has two possible ...
alephalpha's user avatar
  • 45.6k
13 votes
6 answers
547 views

AoCG2021 Day 22: Hyperbolic rescue

Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2017 Day 11. Crossing the bridge, you've barely reached the other side of the stream when you ...
Wheat Wizard's user avatar
  • 95.5k
14 votes
9 answers
2k views

All distances different on a chessboard

Inspired by this Puzzling SE question: All distances different on a chess board. Introduction Lets define a sequence \$a(n), n\geqslant 1\$ as how many pawns can you put on a \$n \times n\$ chessboard ...
pajonk's user avatar
  • 14.9k
19 votes
14 answers
2k views

The Area of Rectangles

Getting the area covered by a rectangle is really easy; just multiply its height by its width. However in this challenge we will be getting the area covered by multiple rectangles. This is equally ...
Wheat Wizard's user avatar
  • 95.5k
18 votes
4 answers
909 views

Find the sliced sheet of paper

Context : Suppose you have a sheet of paper measuring 8 x 10. You want to cut it exactly in half while maintaining its rectangular shape. You can do this in two ...
Eternal Student's user avatar
14 votes
2 answers
526 views

Draw me a shape

The game shapez.io has a lot of shapes. In my previous challenge, the object was to generate a random code for a shape. Now, your challenge is to render a shape. Specs Shapes Each shape has a unique ...
emanresu A's user avatar
  • 34.5k
28 votes
10 answers
6k views

Distances between keys on a QWERTY keyboard

Inspired by this video by Matt Parker The distances between the letter keys of a QWERTY keyboard are somewhat standardised. The keys are square and both the horizontal and vertical spacing are 19.05mm ...
pxeger's user avatar
  • 23.2k
16 votes
1 answer
363 views

Build the widest unsupported bridge with nothing but frictionless blocks

In this challenge you must write a computer program that creates a stack of a thousand identical \$1 \times 1\$ frictionless homogeneous blocks such that each block is supported and the stack is ...
orlp's user avatar
  • 39k
11 votes
4 answers
377 views

Minkowski sum of two convex polygons

Background Minkowski addition is a binary operation on two sets of points (usually geometric objects) in the Euclidean space. The Minkowski sum of two sets \$A\$ and \$B\$ is formally defined as ...
Bubbler's user avatar
  • 73.2k
3 votes
8 answers
928 views

Are vertices in a clockwise order?

Your program must accept as input six numbers, which describe a triangle - for example, the inputs 80, 23, 45, 1, 76, -2 describe a triangle with vertices (80, 23), (45, 1), and (76, -2). The input ...
Adam Abahot's user avatar
21 votes
18 answers
5k views

Convince me Gabriel's Horn is possible

From Wikipedia, Gabriel's Horn is a particular geometric figure that has infinite surface area but finite volume. I discovered this definition in this Vsauce's video (starting at 0:22) where I took ...
ihavenoidea's user avatar
  • 1,219
19 votes
2 answers
533 views

Determine Circles

Giving n(any amount) of points (x,y). What's the minimum amount of circles required to cross every point given? Task Your ...
okie's user avatar
  • 1,797
15 votes
2 answers
416 views

Connecting the Dots: Counting n²-gons in the n×n Grid

The recent volume of MAA's Mathematics Magazine had an article "Connecting the Dots: Maximal Polygons on a Square Grid" by Sam Chow, Ayla Gafni, and Paul Gafni about making (very convex) \$n^...
Peter Kagey's user avatar
  • 8,649
34 votes
3 answers
2k views

Placing circles along a square spiral

In this code golf challenge, you'll be computing the placement of (open) circles of areas \$\pi, 2\pi, 3\pi, \dots\$ when greedily placed along integer points in a square spiral in such a way that no ...
Peter Kagey's user avatar
  • 8,649
13 votes
8 answers
1k views

Count the number of possible squares [duplicate]

In a 9 by 9 grid some points have been marked. The task is it to make a program that counts all distinct squares that can be made using four marked points. Note that squares can also be placed ...
Donat's user avatar
  • 1,429
8 votes
8 answers
578 views

Coordinate Connecting

Input: Ten unique integer coordinates, between (0,0) and (100,100). Output: The coordinates arranged in the order/an order such ...
qazwsx's user avatar
  • 1,184
14 votes
8 answers
2k views

Is my triangle on the lattice?

Write a program or function which takes three positive integers \$a, b, c\$ and returns/outputs one value if there is, and a different value if there isn't, a triangle on the square lattice, whose ...
Rosie F's user avatar
  • 417
20 votes
5 answers
795 views

The Caged Circles

This problem will have you analyzing circles drawn on the grid, with the gridlines drawn at integer values of \$x\$ and \$y\$. Let \$\varepsilon\$ be a very small number (think, \$\varepsilon = 0.0001\...
Peter Kagey's user avatar
  • 8,649
13 votes
6 answers
702 views

Ellipsoid surface area

Related: Ellipse circumference Introduction An ellipsoid (Wikipedia / MathWorld) is a 3D object analogous to an ellipse on 2D. Its shape is defined by three principal semi-axes \$a,b,c\$: $$ \frac{x^2}...
Bubbler's user avatar
  • 73.2k

1
2 3 4 5
8