WIP for spiral and Helix 2D and 3D

New version with activated addon spirals
5 Jan 2016 and tested in 2.6 and 2.7

so save the script in a folder then copy it to the addon folder
and it will be available under 3D view in the addon window

added a multi level menu
and converted to Bmesh data API
update for Nmesh look up table

let me know if you have other spirals / helix type not included

[ATTACH]323461[/ATTACH]

Runing the script

run the script from the text editor then go to the top header Add menu select Mesh and then at the end yo will find the New script menus

select one of the spiral / Helix and it will draw it in top view

hope it is usefull

To do List:

1 - finish all the functions/class

2 - Complete the PDF documentation

Thanks for any C & C
happy 2.7

Attachments

addspiral2level-Jan2016-42.blend (307 KB)

Hey Ricky,

thanks for sharing!

Can you attach the PDF documentation and
some screenshots of what the script does?

-Simon

addspiral2level2671.blend (293 KB)

well doc is still being done and not completed at all
so i need to work on this later on in next few weeks
and also other things like i’v indicated in first post

but it’s easy to use just select one of the spiral or helix and a new panel will appear in the Tool pro panel
where you can change some of the parameters like Z for height / turn and radius ect

try it and see what happen

i added many differrent type of spirals so you have many choice available here!

here is a pic for the main menu with list of items


second picture show the first selection archimedes spiral
which appears as very small so look into the outliner and select the spiral and dot on numerical keyboard
to center it and zoom in


happy 2.5

Wow ! I will never be without a spiral ! A lot of things in nature are based on various types of spiral so these could be a very good basis for natural objects :D.

Only error I got was with the Cornu Spiral:

read blend: /media/anubis/DJ_Barney_Docs/Forge/ShipYards/Operations/BREAKTHROUGH TECHNOLOGIES/spiral2574_1.blend
 begin  Cornu Spiral 
Traceback (most recent call last):
  File "/media/anubis/DJ_Barney_Docs/Forge/ShipYards/Operations/BREAKTHROUGH TECHNOLOGIES/spiral2574_1.blend/spire2574.py", line 2139, in execute
TypeError: 'float' object cannot be interpreted as an integer

location:<unknown location>:-1

location:<unknown location>:-1

I’ve been working on creating this kind of curve …


http://files.djbarney.org/perfectscalar.gif


http://files.djbarney.org/slide0402_image857.gif
http://files.djbarney.org/Slide0248.gif

I notice you have included a lot of maths links, so, along with all the examples I have to hand, time for me to get down to studying (puts student cap on).

EDIT: Here we are … I can see from the description for the Fibonacci Spiral on this page that the last image above is describing what is shown in the image above “powers of PHI” …

These are the Fibonacci numbers, which you can find by the recursive formula a(n)=a(n-1)+a(n-2) with [a(1)=1, a(2)=1, n>2].
So I need to put in this mathematical description of that on the Z axis in your script as I think that is only coded in X and Y dimensions, at least with what I could see on my screen.

1- t’s possible the Cornu is not working yet but i’ll review it later on

got to admit this one is the most difficult of all !

2- Your Golden spiral with Z value
well i already have a fibonaci function check it out

just look at the the archemedes spiral it has a Z value which you could use
but instead of having a Z value / turn it could change for something else
like delta Z following the Fibonaci serie
that should be easy to do

the only problem i 'm not cetain is how do you get the side walls on it for the tower as a spiral 3D
let me know if you find how to do that i can include it in a function !

3- i’m looking for an helix along a path in 3D
if you see anything let me know!

hope it helps
happy 2.5

Yes that helps. Great to know I’m on the right path. BTW I included the tower to show the basic principal of the curve. I don’t want to model the tower itself, but it could make an interesting project for someone.

EDIT: I just spoke to Dan Winter who uses this spiral in his physics (for example he produces a water imploder device that uses it). He confirmed to me that it is in fact , not the Fibonacci Spiral, but the Golden Spiral that I need to be looking at (Golden Spiral 2 in your script)). The Z axis can apparently be calculated with x2[squared]+y = radius, then radius * golden mean = the Z value.

I got a Z dimension for your Golden Spiral 2. But I am having trouble getting the Z dimension “stretched” enough to match the golden mean proportions on the X and Y axis. I assume the value ANGTR is important so that the Z plot matches the turns of the X/Y spiral (removing it or putting it in wrong leads to plots that go all over the place). I got closest with ANGTRhtphi. Attached are a couple of my results.

I think I’m very close but I have some bad maths teaching in the way from my past. My maths teacher used to shout at us and I have fears instilled in me from having to wrote learn those awful times tables.BTW I’m not trying to ask for sympathy, this is just a sad fact of very bad maths teaching. It’s probably a miracle I can even look at these equations and understand some of it.



ok but how is it going ?

is it beginning to give the right result

can you upload the new function you did so i can test it !

and yes the Z value is the Delta Height / turn !

not certain i will have much time this week to get back to this script!

The Golden and fibonacci spiral are close to each other in shape

thanks

happy 2.5

This is fascinating, but I have nothing useful to add. Thanks for the work. I’ll be using this when it’s done. I have the perfect application for it.

Hello, I got it ! :cool:

class Goldenspiral2(bpy.types.Operator):
    
    '''Add Golden Spiral 2'''
    
    bl_idname = "mesh.primitive_goldenspiral2_add"
    bl_label = "Add Golden Spiral 2"
    bl_options = {'REGISTER', 'UNDO','BLOCKING'}
    
    
    seg1 = IntProperty(name="Segments",
        description="Number  segments",
        default=32, min=4, max=100)
    
    nturn = FloatProperty(name="nturn",
        description="nturn",
        default=3, min=1, max=100.0)
    
    ht= FloatProperty(name="Height/turn",
        description="Height/turn",
        default=1.2, min=0.0, max=100.0)
    
    def execute(self, context):
    
        global  layers
        verts1,edges,faces,medges,vid=[],[],[],[],0
    
        seg1 = self.properties.seg1
        nturn = self.properties.nturn
        ht= self.properties.ht
    
        print (' begin Golden Spiral 2 ')
    
    #   R =  G^(2 Theta / pi )    
    #   R = a1  exp(b1 * phi)     b1 =a bs(log(phi)/90)
    #    R= a1* exp(b1 * n) 
    
        phi=(1.0+5.0**0.5)/2.0        # golden ratio ~ 1.618
        b1=abs(log(phi)/90.0)
        b2=log(2)
        a1=1
    
        minag=0
        maxag=nturn*360
    
        seg2=seg1*nturn
        step1=(maxag-minag)/seg2
    
        for n1 in float2_range(minag, maxag, 1):
    
            ANGTR=n1*pi/180
            ro= a1* exp(b1* n1)
            XC=ro*cos(ANGTR)
            YC=ro*sin(ANGTR)
            ZC=ANGTR*ro/(2*pi)
    
            verts1.extend([[XC,YC,ZC]])            # Add vertices
    
# Make edges
    
            if vid >0:
                edges.append([vid-1,vid])
    
            vid+= 1
    
        named1="Golden_Spiral2" 
    
        mesh = bpy.data.meshes.new(named1)
        mesh.from_pydata(verts1,edges,[])
    
        mesh.update()
    
        obj = bpy.data.objects.new( named1, mesh )
        scene = bpy.context.scene
        scene.objects.link( obj )
    
        return {'FINISHED'}
    
####

Once I’d grasped what is going on here I just took the Z part of the Archimedes spiral and replaced “ht” with “ro”.


ZC=ANGTR*ro/(2*pi)

The curve at least looks right now (compared to images I posted above). I’d like to confirm the mathematical basis is correct before I proceed. Can you confirm a few things for me ?

1. ro = the golden mean dimension expressed, now on the Z axis in the same way as it is on the X and Y axis ? I notice you define PHI as part of “b1” which is then used in “ro”.

2. The fragment

/(2*pi)

from the equation (Z part) … this is there to describe the curve on the Z axis ? … pi describes the circle based mathematics of the curve ?

3. Lastly, what exactly is ANGTR … this means “Angle Turn” ? I notice it’s defined as

ANGTR=n1*pi/180

“n1” appears to actually plot the points in the for loop. So ANGTR is basically the guts of the plotting function ?

So, please put the function into your script add-on once we’ve confirmed the mathematics here. Cheers ! :wink:

well the angtr= ang value in radians is just the radians value of the angle
cause the loop works with angle in degrees
and the X Y values with cos and sin needs the radians values!
so don’t worry about it

PHI value is from one of the site which described the Golden spiral using phi
so i did not really invented anything for this one just applied the equations from the site!

i could change it and works only with radians but i prefer to see angle in degrees its’ easier to visualize it !

Z vs turn
one turn is 2 PI radians =360 Deg and it simply means that for one full 360 degrees turn it will be raised by a certain amount per/turn

and this delta z value can be defined as anything you want
you could make = to phi / turn if that what’s you want !

what kind of name can you put on this new one

is it sort of a golden spiral with Z being golden too?

as soon as i get the new name i’ll upload a new version in first post!

happy 2.5

Thanks for the explanation :smiley: That makes sense now.

A name ? How about the Golden Mean Caduceus Spiral ?




Caduceus is one of the things this spiral actually maps out for use in energy medicine. Dan Winter (and Implosion Group) the fellow who is my mentor, sells a water Imploder that improves crop growth by putting the water through a vortex based on the spiral physics of this Caduceus Spiral.

I’ve read some of Dan Winters ramblings, ‘water imploder’ made me chuckle tho - what utter nonsense.

i can see how it can be used now for this medicine symbol and the water sprayer i guess

which might be usefull to other peoples too!

i’ll try to make one in 3D for the medecine symbol later on!

so thanks to DJ Barney for the idea about this new spiral type

if anybody else has some other simple spirals to be added let me know!

i mean i don’t want to add some of the new modern Chaos spirals which are a lot more complicated to do with meshes!

so have fun with spirals

happy 2.5

Don’t be so rude. You’re referring to a good friend of mine !

I enjoyed the ride :slight_smile:

@Ricky, Nice work… what a long script!

it’s more a compromise

you can copy any class / function to another script - easy and simple to read and understand for anybody

i can try to simplify it but then it would become more difficult to read and understand!

mind you this will be a little bit longer when i introduce my new 2 levels menu soon i hope
but more complicated for noobies to understand!

the important thing for me was to give lot’s of flexibility with different type of Spiral and Helix
at least compared to what we had in 2.49 which was very limited!

have fun with spirals/Helix

you can always suggest ways to make it shorter if not too complicated
now i still prefer to keep it realtively simple and easy to read!
but shoudl wait till i come up with the new 2 levels menu system

thanks
happy 2.5

If it was my code I would keep the references (and there are many, and that’s good) separate in a readme.txt in the folder. This way you aren’t making the .py unnecessarily long. There will come a time for refactoring i’m sure. Might i suggest looking at how ideasman breaks up his MathViz code into seperate .py . If you take a step back some of these functions can be grouped by the type of arithmetic involved.

that’s the idea for my double level menu
seperate different type of spirals into sub group
like one group for classical spirals
one group for the more modern spirals
one group for other spirals ect…

still would like to learn this multi py files things
might be usefull for other scripts i have in mind

is there a link for this mathviz script ?

thanks
happy 2.5

mathviz is in the addons folder by default. if not : http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/3D_interaction/Math_Viz