spiral

Algorithm to solve the points of a evenly-distributed / even-gaps spiral?

廉价感情. 提交于 2019-11-29 07:01:23
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 the problem I'm after. I would like to store an array of points of a very specific spiral algorithm. The points are evenly distributed The 360 degree cycles have an even gap If I'm not mistaken, the first two points would be: point[ 0 ] = new Point(0,0); point[ 1 ] = new Point(1,0); But where to go from here? The only arguments I'd like to provide

Iterate over 2d array in an expanding circular spiral

孤街醉人 提交于 2019-11-28 17:31:27
问题 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 returns True . So, f looks like this: def f(x, y): """do stuff with x and y, and return a bool""" and would be called like this: R = numpy.zeros(M.shape, dtype=numpy.int) # for (i, j) in M for (radius, (cx, cy)) in circle_around(i, j): if not f(M[i][j

how to build spiral square matrix using recursion?

℡╲_俬逩灬. 提交于 2019-11-28 06:22:53
问题 I wanted to build a spiral square matrix using recursion. I am able to build spiral square matrix using iterative method as below: void main() { int initial_direction = UP , n = MAX , p = 1 ; /* intial_direction is set to UP because we need to start moving right */ int r ,c , a[MAX][MAX]; int row_right = 0 , column_down = n-1 , row_left = n-1 , column_up = 0 ; clrscr (); //Set all elements of the matrix to 0 for(r = 0 ; r < MAX ; r++) { for(c = 0 ; c < MAX ; c++) a[r][c] = 0 ; } //Generate

2d Array in Spiral Order

牧云@^-^@ 提交于 2019-11-28 05:59:08
问题 I'm trying to fill an array in spiral order. So far, I can print the array in spiral order, but is there a way to modify the array so that i can fill it in spiral order and then just print the array? I'd like it to go in decreasing order like a countdown. Please help! public class Spiral { public static void main(int m, int n) { // create m by n array of integers 1 through m*n int[][] values = new int[m][n]; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) values[i][j] = 1 + (m*n)*i +

Curve fitting with y points on repeated x positions (Galaxy Spiral arms)

余生颓废 提交于 2019-11-28 01:29:13
I currently have a MATLAB program which takes RGB images of traced spiral arms from galaxies and selects the biggest arm component and plots only that. I have tried using matlab's built in curve fitting tool with smoothing spline to fit it and I get the following result: I have tried using interp1 with parametric fitting to only get bad results. Is there a way to fit this type of curve at all? Spektre Your fail is due to that you handle your 2D curve as function which is not the case (you got more y values for the same x ) and that is why the fit fails on the right side (when you hit the non

Algorithm to solve the points of a evenly-distributed / even-gaps spiral?

浪尽此生 提交于 2019-11-28 00:41:02
问题 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 the problem I'm after. I would like to store an array of points of a very specific spiral algorithm. The points are evenly distributed The 360 degree cycles have an even gap If I'm not mistaken, the first two points would be: point[ 0 ] = new Point

Draw equidistant points on a spiral

谁说我不能喝 提交于 2019-11-27 18:23:30
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 spiral to draw is an archimedean spiral and the points obtained must be equidistant from each other. The algorithm should print out the sequence of the Cartesian coordinates of single points, for example: Point 1: (0.0) Point 2: (..., ...) ........ Point N (..., ...) The programming language isn't important and all help greatly appreciated! EDIT: I

Looping in a spiral outside-in

纵然是瞬间 提交于 2019-11-27 15:43:55
I'm looking to loop through a matrix similar to Looping in a spiral but looping outside-in, instead of inside-out. Can anyone help me with a good way to do this for a matrix of any size, ideally in Ruby? Example: In a 3x4 matrix I want to start at [0,0] going right, then move down once I reach [3,0], move left at [3,2] etc. [0,0] [1,0] [2,0] [3,0] [0,1] [1,1] [2,1] [3,1] [0,2] [1,2] [2,2] [3,2] The order to move is shown below: 0 1 2 3 9 10 11 4 8 7 6 5 And the output would be: [0,0], [1,0], [2,0], [3,0], [3,1], [3,2], [2,2], [1,2], [0,2], [0,1], [1,1], [2,1] Without loss of generality, let's

Draw equidistant points on a spiral

梦想与她 提交于 2019-11-26 19:24:40
问题 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 spiral to draw is an archimedean spiral and the points obtained must be equidistant from each other. The algorithm should print out the sequence of the Cartesian coordinates of single points, for example: Point 1: (0.0) Point 2: (..., ...) ........

Looping in a spiral outside-in

南笙酒味 提交于 2019-11-26 17:19:53
问题 I'm looking to loop through a matrix similar to Looping in a spiral but looping outside-in, instead of inside-out. Can anyone help me with a good way to do this for a matrix of any size, ideally in Ruby? Example: In a 3x4 matrix I want to start at [0,0] going right, then move down once I reach [3,0], move left at [3,2] etc. [0,0] [1,0] [2,0] [3,0] [0,1] [1,1] [2,1] [3,1] [0,2] [1,2] [2,2] [3,2] The order to move is shown below: 0 1 2 3 9 10 11 4 8 7 6 5 And the output would be: [0,0], [1,0],