A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: The Archimedian Spiral.

  1. #1
    Junior Member
    Join Date
    Mar 2006
    Posts
    20

    The Archimedian Spiral.

    This is the formula that I found on Wikipedia for the Archimedian Spiral (in polar coordinates).

    R = A + B * theta

    Where R is radius, A determines the number of spirals, B determines the distance between the spiral arms, and theta is the degree of rotation.

    Now what I want to do is have a line that has one end follow the path of an Archimedian Spiral and the other stay at a fixed point. Also, while the line follows the path of the spiral, I'd like it to fill in the space it passes over with color (or an assload of line copies, whichever is better).

    Now I've tried this with Actionscript and a 1 x 50 pixel line, but to no avail. Any help would be great.

  2. #2
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    here's some code that would draw the spiral

    copy and paste and it should work

    Code:
    seg = 1000
    
    a=2 //spirals
    b=1 //dist
    
    mX=200
    mY=200
    
    maxTheta = Math.PI*2 * 6
    
    _root.lineStyle(1)
    _root.moveTo(mX,mY)
    
    for(i=0;i<seg;i++){
    	cP = i/(seg-1)
    	theta = (maxTheta) * cP
    	r = a + b * theta
    	
    	cX = Math.sin(theta)*r
    	cY = Math.cos(theta)*r
    	
    	_root.lineTo(cX+mX,cY+mY)
    }

  3. #3
    Junior Member
    Join Date
    Mar 2006
    Posts
    20
    If you don't mind my asking, could you explain the code? If it's too much of a hassle, don't worry about it, but I just like to know the details of things.

    I know the math formulas and the for loop, but most of the other stuff is new functions and/or variables to me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center