A spiral is a two- or three-dimensional shape composed of lines which continuously wrap around a center point. The spiral model is an iterative software development methodology, in which each iteration builds upon previous work.
Questions tagged [spiral]
202 questions
178
votes
34 answers
Looping in a spiral
A friend was in need of an algorithm that would let him loop through the elements of an NxM matrix (N and M are odd). I came up with a solution, but I wanted to see if my fellow SO'ers could come up with a better solution.
I'm posting my solution as…

Can Berk Güder
- 109,922
- 25
- 130
- 137
28
votes
7 answers
Iterate over 2d array in an expanding circular spiral
Given an n by n matrix M, at row i and column j, I'd like to iterate over all the neighboring values in a circular spiral.
The point of doing this is to test some function, f, which depends on M, to find the radius away from (i, j) in which f…

Jason Sundram
- 12,225
- 19
- 71
- 86
27
votes
4 answers
Draw equidistant points on a spiral
I need an algorithm to calculate the distribution of points on a spiral path.
The input parameters of this algorithm should be:
Width of the loop (distance from the innermost loop)
Fixed distance between the points
The number of points to draw
The…

Giulio Pierucci
- 281
- 1
- 3
- 5
22
votes
10 answers
Code Golf: Easter Spiral
What's more appropriate than a Spiral for Easter Code Golf sessions? Well, I guess almost anything.
The Challenge
The shortest code by character count to display a nice ASCII Spiral made of asterisks ('*').
Input is a single number, R, that will be…

friol
- 6,996
- 4
- 44
- 81
15
votes
2 answers
Coordinate (x,y) list to be sort with a spiral algorithm
I have a list of coordinate to be sorted with a spiral algorithm. My need is to start on the middle of the area and "touch" any coordinate.
To simplify this is the representation of the (unsorted) list of coordinates (x,y marked with a "dot" on…

Stefano Radaelli
- 1,088
- 2
- 15
- 35
12
votes
1 answer
Spiral barplot using ggplot & coord_polar (Condegram)
I'd like to create a bar plot on an Archimedean spiral, like discussed here.
With an end goal of something like this, but less overwhelming.
Here's a sample dataframe:
test <- structure(list(month = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
…

jesstme
- 604
- 2
- 10
- 25
10
votes
2 answers
Algorithm to solve the points of a evenly-distributed / even-gaps spiral?
First, just to give a visual idea of what I'm after, here's the closest result (yet not exactly what I'm after) image that I've found:
Here's the entire site-reference: http://www.mathematische-basteleien.de/spiral.htm
BUT, it doesn't exactly solve…

chamberlainpi
- 4,854
- 8
- 32
- 63
9
votes
6 answers
Find the position nth element of a rectangular tiled spiral?
What is an algorithm to get the nth element of a rectangular tiled spiral?
Here is n:
[ 20 ][ 21 ][ 22 ][ 23 ][ 24 ]
[ 19 ][ 6 ][ 7 ][ 8 ][ 9 ]
[ 18 ][ 5 ][ 0 ][ 1 ][ 10 ]
[ 17 ][ 4 ][ 3 ][ 2 ][ 11 ]
[ 16 ][ 15 ][ 14 …

MaiaVictor
- 51,090
- 44
- 144
- 286
8
votes
4 answers
Matrix and algorithm "spiral"
i wanted ask if there some algorithm ready, that allowed me to do this: i have a matrix m (col) x n (row) with m x n elements. I want give position to this element starting from center and rotating as a spiral, for example, for a matrix 3x3 i have…

Marcello Impastato
- 2,263
- 5
- 30
- 52
8
votes
4 answers
How do I make make spiral of natural numbers in python?
I want to make a function that I give it a number and the function returns a spiral from 1 to that number(in 2 dimensional array). For example if I give the number 25 to the function it will return something like this:
I tried different ways but…

Skizo
- 521
- 2
- 8
- 14
8
votes
3 answers
Using a Bezier Curve to draw a spiral
This is for an iPad application, but it is essentially a math question.
I need to draw a circular arc of varying (monotonically increasing) line width. At the beginning of the curve, it would have a starting thickness (let's say 2pts) and then the…

Jon Hull
- 679
- 6
- 15
7
votes
1 answer
Implementing a Paper.js spiral raster example on server-side
I am trying to draw a spiral raster example (link) on a server (running Node.js). However, I am facing an issue where my path is not displayed on the exported frame and I can only see the downloaded image. Probably a silly mistake on my side,…

dmee3
- 304
- 2
- 11
6
votes
2 answers
Python - OpenDrive Map - Spiral / Clothoid / Euler Spiral / Cornu Spiral Interpolation using Fresnel Integrals
The map format OpenDrive, provides (among others) the geometry of a road. Each segment of the road can have a different geometry (e.g. line, arc, spiral, polynomial). The provided information for a road geometry "spiral", is the following:
- s …

Trenera
- 1,435
- 7
- 29
- 44
6
votes
1 answer
Making a logarithmic spiral in Java
import java.io.*;
import java.awt.*;
// Logarithmic spiral example
public class Spiral extends Frame
{// The spiral consists of n line segments. Line segment 1
// has starting point (hc, vc). Line segment k, for 1<=k<=n,
// has length k*d. Each…

Aizzle
- 133
- 1
- 9
6
votes
2 answers
Traverse 2D Array in Spiral pattern using recursion
I am preparing for an interview and have been stuck on this question for quite some time now. Could anybody please help me with the code. If not complete then may be a snippet of it?
Please..

Chin Tser
- 2,799
- 2
- 18
- 6