Draw a spiral

0

Please login or register to vote for this query.

(click on this box to dismiss)

Run query and go to the "GRAPH" tab

Motor Vehicle Maintenance and Repair Meta

Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles

--calculate circle points, gradually decreasing decrease radius  (circle: query #882633)
set nocount on
declare @Radius decimal(28,23) = 1400  
declare @spirals float = 10
declare @numberOfPositions float = 180
declare @radiansPerPosition float = (360/@numberOfPositions)*pi()/180.0 --'radians = degrees × pi / 180°
declare @xStop float, @yStop float
create table #x ( groupSpace varchar(10), x float, y float)
declare @z float, @spiral int=0

while @spiral <= @spirals 
  begin
    set @spiral=@spiral+1
    set @z=0
    while @z <= @numberOfPositions  -2
      begin --calculate points
        set @xStop = Cos(@radiansPerPosition * (@z*1.20)) * @Radius
        set @yStop = Sin(@radiansPerPosition * (@z*1.20)) * @Radius
        insert into #x(groupSpace,x,y) values (' ',@xStop,@yStop)  --write to table (double the height)
        set @z=@z+1
        set @radius = 1.0*@radius - ((1.0*@radius/@spirals)/@numberOfPositions)
      end
  end
	
print @z
select x,groupspace,y from #x 
union all select 2660.0,'   ',1333.0 --the keep circle away from edge
union all select -2660.0,'     ',-1333.0

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results