Click here to Skip to main content
12,957,071 members (62,813 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am trying to create a 3D spring (helix, Spiral, ...) with a specific length and number of turns. I have the code written to create a spring using a line_strip, but I want to extend it to be an actual 3d surface (look like a real spring on a car). I figure this can be done using a quad_strip, but not sure what the best way to create this is.

Has someone done this?

        Gl.glColor4f(0, 0.28, 0.48, Alpha)
        Dim length As Double = glVectorRotation(point1, point2, False)
        Dim coils As Integer = 5
        Dim segs As Integer = 100
        Dim Radius As Single = 2.5
        Dim pitch As Double = length / coils
        For icoil As Integer = 0 To coils
            For iseg As Integer = 0 To segs
                Dim theta As Single = CSng((2 * PI) / segs * iseg)
                Dim z As Single = CSng((icoil + (iseg / segs)) * pitch)
                Dim x As Single = CSng(Radius * Cos(theta))
                Dim y As Single = CSng(Radius * Sin(theta))
                If z > length Then Exit For 'z = CSng(length)
                Gl.glVertex3d(x, y, z)
Posted 3-Dec-09 9:59am
Updated 10-Feb-10 5:32am

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,924
CHill60 3,550
Maciej Los 3,312
ppolymorphe 2,120
Jochen Arndt 1,973

Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100