Questions tagged [geometry]
This challenge is intended to be solved by using, manipulating, or creating shapes or other geometric structures.
385
questions
6
votes
2
answers
284
views
Snake a string through a simplex
An n-simplex is a generalization of 'triangleness' in any dimension (specifically, it is the simplest shape requiring n dimensions). Starting with 0 dimensions, the named simplexes are: point, line ...
14
votes
9
answers
1k
views
Draw a Regular Reuleaux Polygon
Related: Draw A Reuleaux Triangle!, Draw a regular polygon
A Reuleaux polygon is a curve of constant width made up of circular arcs of constant radius. The most well-known Reuleaux polygon is the ...
12
votes
1
answer
390
views
Plot the ground path of a satellite
If you model a satellite as a free point orbiting a body, you can pretty easily see it has 6 degrees of freedom: three for the X, Y, and Z position, and three for the X, Y, and Z velocity. However, ...
3
votes
7
answers
355
views
Find the most isolated point
Given two non-empty sets of points \$P,T = \{(x,y)\ |\ x,y \in \mathbb{Z} \}\$, find the point \$p \in P\$ such that it is the "most isolated" from all points in \$T\$. The "most ...
8
votes
4
answers
486
views
How far are you?
Write a program that gets coordinates of two objects on Earth, and calculates how far they are from each other directly in space (a straight line through Earth) and on the surface (through the ...
11
votes
4
answers
577
views
Construct the point with two segments
Given a rational point P, return four integral points A, B, C, and D, such that the line segments AB and CD intersect only at P. To make it a bit more interesting, segment AB doesn't include A and B.
...
13
votes
16
answers
3k
views
The primitive circle problem
Challenge
The primitive circle problem is the problem of determining how many coprime integer lattice points \$x,y\$ there are in a circle centered at the origin and with radius \$r \in \mathbb{Z}^+
\...
17
votes
19
answers
1k
views
Ellipse Lattice Point Counter
Challenge
Determine how many integer lattice points there are in an ellipse
$$\frac{x^2}{a^2} + \frac{y^2}{b^2} \leq 1$$
centered at the origin with width \$2a\$ and height \$2b\$ where integers \$a, ...
-6
votes
1
answer
187
views
Where to stand to throw circles over sticks
Consider a horizontal line with vertical lines centered on the x-axis and placed at gaps of \$\sqrt{2}/2\$. For a positive integer \$n \geq 3\$, the first half of the lines have lengths \$0, \sqrt{2},...
10
votes
12
answers
1k
views
Counting Collinear Points
Given two points \$(x_1, y_1)\$ and \$(x_2, y_2)\$ with integer coordinates, calculate the number of integer points (excluding the given points) that lie on the straight line segment joining these two ...
1
vote
1
answer
563
views
Where to put a circle?
Consider an \$n \times n\$ grid of integers which is part of an infinite grid. The top left coordinate of the \$n \times n\$ grid of integers is \$(0, 0)\$.
The task is to find a circle which when ...
16
votes
2
answers
607
views
Construct this point
Given a constructible point \$(x, y) \in \mathbb R^2\$, output the steps required to construct \$(x, y)\$
Constructing a point
Consider the following "construction" of a point \$(\alpha, \...
14
votes
1
answer
279
views
Construct the Constructability sequence
Consider compass-and-straightedge construction, where you can construct new points from existing ones by examining intersections of straight lines and circles constructed with one of the following two ...
10
votes
6
answers
983
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
...
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 ...
11
votes
4
answers
433
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 ...
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, ...
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 ...
22
votes
26
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 ...
23
votes
20
answers
3k
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 ...
12
votes
5
answers
634
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 ...
19
votes
7
answers
2k
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 ...
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, ...
10
votes
3
answers
634
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 ...
5
votes
2
answers
283
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 ...
4
votes
1
answer
211
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\$ ...
9
votes
5
answers
481
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}&...
5
votes
2
answers
882
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\...
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 ...
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, ...
18
votes
4
answers
909
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 ...
12
votes
6
answers
954
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:
...
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 ...
5
votes
2
answers
220
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 ...
20
votes
7
answers
3k
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 ...
15
votes
5
answers
954
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 ...
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 ...
7
votes
2
answers
307
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 ...
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 ...
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 <...
8
votes
6
answers
604
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 ...
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 <...
10
votes
3
answers
346
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 ...
17
votes
7
answers
490
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 ...
21
votes
4
answers
935
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 ...
15
votes
7
answers
577
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 ...
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 ...
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 ...
18
votes
4
answers
910
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 ...
14
votes
2
answers
573
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 ...