## Spiral algorithms

### Spiral algorithms

1-2 radius spiral and Archimedean spiral sphere algorithms.

I know there are a few great and free plugins out there, but maybe you want to use these functions inside your own program. So just sharing:

Code: Select all
model = Sketchup.active_model
entities = model.active_entities

@TotalEdges = laps * edgesperlap
@Zincrement = height / @TotalEdges
@EdgeAngle = 360.00.degrees / edgesperlap
@LapHeight = height / laps

#Make 1st lap
for step in 0..edgesperlap
@x = Math.cos(@EdgeAngle * step) * radius
@y = Math.sin(@EdgeAngle * step) * radius
@z = step * @Zincrement
@point2 = [@x, @y, @z]
@point1 = @point2
end

#Copy-Paste all laps
for step in 1..(laps-1)
@Copy = @Lap.copy
@Copy = @Copy.move! [0, 0, @LapHeight*step]
@Copy.explode
end
@Lap.explode
@Pt1 = @Spiral1.entities.add_cpoint [0, 0, 0]
@Pt2 = @Spiral1.entities.add_cpoint [0, 0, height]
end

spiral1(5.mm, 100.mm, 25, 36)

Code: Select all
model = Sketchup.active_model
entities = model.active_entities

@TotalEdges = laps * edgesperlap
@Zincrement = height / @TotalEdges
@EdgeAngle = 360.00.degrees / edgesperlap
@LapHeight = height / laps

@ReductionPerEdge = @Reduction / @TotalEdges

for step in 0..@TotalEdges
@x = Math.cos(@EdgeAngle * step) * @Radius
@y = Math.sin(@EdgeAngle * step) * @Radius
@z = step * @Zincrement
@point2 = [@x, @y, @z]
@point1 = @point2
end
@Pt1 = @Spiral2.entities.add_cpoint [0, 0, 0]
@Pt2 = @Spiral2.entities.add_cpoint [0, 0, height]
end

spiral2( 5.mm, 15.mm, 100.mm, 10, 36)

Archimedean Spiral Sphere:
Code: Select all
#Defining group
model = Sketchup.active_model
entities = model.active_entities

#Defining variables
revolutions = revolutions.to_i
edgesperrev = edgesperrev.to_i
cutoff = cutoff.to_i

@TotalEdges = revolutions * edgesperrev
@VerticalStep = 180.00.degrees / @TotalEdges
@HorizontalStep = 360.00.degrees / edgesperrev

#CutOff (0% - 100%)
@cut = (@TotalEdges / 100.00 * cutoff)
@start = (@cut).to_i
@ending = (@TotalEdges - @cut).to_i

#Defining 1st point
@x = Math.cos(@HorizontalStep * @start) * @LocalRadius
@y = Math.sin(@HorizontalStep * @start) * @LocalRadius
@z = Math.cos(@VerticalStep * @start) * radius
@point1 = [@x, @y, @z]

#Making spiral
for edge in @start+1..@ending

@x = Math.cos(@HorizontalStep * edge) * @LocalRadius
@y = Math.sin(@HorizontalStep * edge) * @LocalRadius
@z = Math.cos(@VerticalStep * edge) * radius

@point2 = [@x, @y, @z]
@point1 = @point2
end
@CenterPoint = @Sphere.entities.add_cpoint [0, 0, 0]
end

spiral_sphere(50.00.mm, 10, 36, 0)

- https://sketchucation.com/plugin/1379-helix_along_curve
- viewtopic.php?f=323&t=33139
- https://sketchucation.com/plugin/878-jwm_shapes
1

Tax

### Re: Spiral algorithms

Some helix here : http://www.drawmetal.com
1
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie

pilou
Top SketchUcator

Robot

## Who is online

Users browsing this forum: No registered users and 12 guests