spiral

PHP script to draw a spiral?

别来无恙 提交于 2019-12-23 06:15:01
问题 Does anybody have a PHP (or other language) script for drawing a spiral. A simple (Archimedean spiral) would be just fine. Of course the principle is simple but coding it in SVG or GD would take some time, so I wonder if somebody has one ready :-) 回答1: See this page: Using GD (imagearc) and PHP to draw spirals (Listing 27.3) 来源: https://stackoverflow.com/questions/2546370/php-script-to-draw-a-spiral

How to draw a spiral of # with only for/while loops and if/else statements (without arrays) using C

和自甴很熟 提交于 2019-12-19 12:51:05
问题 so I'm very new to C and am wondering how I could create the following spiral shape: This is my comical attempt.. #include <stdio.h> int main(void) { int size; int i,j; printf("Enter size: "); scanf("%d", &size); for (i = 0, j = 0; i < size - 4; i++, j+=2) { int row = 1; while (row <= size) { int column = 1; while (column <= size) { if ((row == 1 + j && column > j && column < size - j)|| (row == size - (j) && column > j && column < size - j) || (column == size - (j) && row > j && row <= size

Nested loops for creating a spiral shape pattern in c

ぐ巨炮叔叔 提交于 2019-12-19 10:19:45
问题 I need to make a spiral pattern made of stars '*' using nested for loops. I managed to make outter lines, now I don't know how to repeat smaller swirls in the same place. What I should have: ********* * ******* * * * * * *** * * * * * * * ***** * * * ********* Any help would be greatly appreciated. 回答1: After being thoroughly nerd-sniped, I came up with this: #include <stdio.h> void print_spiral(int size) { for (int y = 0; y < size; ++y) { for (int x = 0; x < size; ++x) { // reflect (x, y) to

How do I make make spiral in python? [closed]

微笑、不失礼 提交于 2019-12-18 11:37:21
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . 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 nothing worked out. I just cant figure it out. Hope I explained

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

匆匆过客 提交于 2019-12-17 16:53:10
问题 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? 回答1: Your fail is due to that you handle your 2D curve as function which is not the case (you got

Looping in a spiral outside-in

可紊 提交于 2019-12-11 15:46:26
问题 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],

Coordinates for clockwise outwards spiral

本秂侑毒 提交于 2019-12-11 05:20:41
问题 I'm trying to make what I think is called an Ulam spiral using Haskell. It needs to go outwards in a clockwise rotation: 6 - 7 - 8 - 9 | | 5 0 - 1 10 | | | 4 - 3 - 2 11 | ..15- 14- 13- 12 For each step I'm trying to create coordinates, the function would be given a number and return spiral coordinates to the length of input number eg: mkSpiral 9 > [(0,0),(1,0),(1,-1),(0,-1),(-1,-1),(-1,0),(-1,1),(0,1),(1,1)] (-1, 1) - (0, 1) - (1, 1) | (-1, 0) (0, 0) - (1, 0) | | (-1,-1) - (0,-1) - (1,-1) I

Create a spiral between two cartesian points in MATLAB

不羁的心 提交于 2019-12-11 04:33:38
问题 Perhaps this is a basic question but I haven't been able to find anything specifically like this and I'm wondering how to do it in the best way. I have two sets of points (x1,y1,z1) and (x2,y2,z2) and I have converted them into polar coordinates. I would like to create a counter-clockwise helix of decreasing radius to reach the second point. I would also like to specify how many revolutions it takes. All of the examples I have seen are two points on the x axis and going clockwise. Any

Matrix and algorithm “spiral”

旧城冷巷雨未停 提交于 2019-12-05 20:38:55
问题 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 9 elements so defined: 5 6 7 4 9 8 3 2 1 or for una matrix 4 x 3 i have 12 elements, do defined: 8 9 10 1 7 12 11 2 6 5 4 3 or again, a matrix 5x2 i have 10 elements so defined: 3 4 7 8 10 9 6 5 2 1 etc. I have solved basically defining a array of

Matrix and algorithm “spiral”

我怕爱的太早我们不能终老 提交于 2019-12-04 03:45:29
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 9 elements so defined: 5 6 7 4 9 8 3 2 1 or for una matrix 4 x 3 i have 12 elements, do defined: 8 9 10 1 7 12 11 2 6 5 4 3 or again, a matrix 5x2 i have 10 elements so defined: 3 4 7 8 10 9 6 5 2 1 etc. I have solved basically defining a array of integer of m x n elements and loading manually the value, but in generel to me like that matrix maked