Sign in to follow this  
Followers 0
Qwerty212

Help with trigonometrics

23 posts in this topic

#1 ·  Posted (edited)

Hello again from Barcelona  :bye:

I'm trying to do a spheric spring in my job. The cnc machines that I use do let you introduce the desired diameter of each coil and the amount of wire that you want to do it.

I can calculate the diameter of each coil manually, but I though that it was going to be the easy thing to create a little script in Autoit to do the job for me.

This image shows perfectly what I'm trying to do:

Dibujo+zoom+bola2.jpg

This is what I have done so far:

#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StructureConstants.au3>
#include <Misc.au3>
#include <Array.au3>
#include <ComboConstants.au3>
#include <StaticConstants.au3>
#include <GuiEdit.au3>

Global Const $M_PI = 3.14159265358979323846
Global $iDecimal = 7

;I do declare the global variables with dummy data to prevent warnings during compilation
Global $possibleballs = 1
Global $finalballs = 1
Global $middlediameterfinal = 1
Global $wire = 1


$hWnd = GUICreate("Calculador Ø", 210, 210); the gui

;$Pic1 = GUICtrlCreatePic("", 20, 10, 298 / 3, 221 / 3)

$label1 = GUICtrlCreateLabel("Wire Ø", 10, 15, 75);an input to ask for the wire to be used.
GUICtrlSetFont(-1, 12)
$input1 = GUICtrlCreateInput("1", 98, 15, 50, 20)


$label2 = GUICtrlCreateLabel("Max Ø", 10, 50, 75); another input asking for the maximum outer diameter of the spring
GUICtrlSetFont(-1, 12)
$input2 = GUICtrlCreateInput("10", 98, 50, 50, 20)

$labelnt = GUICtrlCreateLabel("Nt", 10, 85, 75); total number of coils that we want (depending of the outer diameter you will be tied to use more or less)
GUICtrlSetFont(-1, 12)
$inputnt = GUICtrlCreateInput("10", 98, 85, 50, 20)

$button = GUICtrlCreateButton("CALCULATE", 10, 148 + 35, 90, 22); a button to calculate the maximum allowed coils with the desired wire and outer diameter)

$button2 = GUICtrlCreateButton("PROCEED", 110, 148 + 35, 90, 22); When we have already deerminated the desired coils and outer diameter we proceed to look for the diameter of each coil

$label3 = GUICtrlCreateLabel("", 10, 85 + 35, 190, 25);blank labels to be filled later with data
GUICtrlSetFont(-1, 12)
$label4 = GUICtrlCreateLabel("", 10, 115 + 35, 190, 25);blank labels to be filled later with data
GUICtrlSetFont(-1, 12)
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND"); based on forum search to allow decimal places inside the previous inputs
GUISetState()


While 1

    $msg = GUIGetMsg()
    Select

        Case $msg = $GUI_EVENT_CLOSE
            Exit

        Case $msg = $button
            $Maxdiameter = GUICtrlRead($input2)
            $Maxradius = Number($Maxdiameter) / 2 ;with that we do know the radius of the spring
            $wire = GUICtrlRead($input1)
            $Middlediameter = $Maxdiameter - $wire ; I do calculate an imaginated sphere with the spring's diameter - the diameter of the wire, so every point
            ; of the new sphere will pass through the middle of the wire
            calculate()

        Case $msg = $button2 ;when all the data has been confirmed the I read again the inputs and I do proceed to search the diameter of each coil
            $Maxdiameter = GUICtrlRead($input2)
            $Maxradius = Number($Maxdiameter) / 2
            $wire = GUICtrlRead($input1)
            $Middlediameter = $Maxdiameter - $wire
            proceed()
    EndSelect
    Sleep(20)
WEnd

Func calculate()

    $perimeter = $Middlediameter * $M_PI ; with this I know the lenght of the little sphere that will hold the wire

    $possibleballs = $perimeter / $wire ;now we know how many times we can fit the wire inside this sphere

    ;ConsoleWrite ( $possibleballs & @CRLF)

    GUICtrlSetData($label3, "nt = " & (Round($possibleballs / 2, 2))) ;and I do write it in the gui. Notice that I have divided the possible times that wire can
    ; be fitted in the new sphere because every coil of the spring is going to be formed by 2 times the wire

    $finalballs = Round($possibleballs, 0); I round the number of possible balls of wire

    ;ConsoleWrite ( $finalballs & @CRLF)

    $perimeterparcial = $finalballs * $wire ; and I do calculate what do exactly would be the diameter of the spring if you input more coils than the wire that fits
    ;in the max outer diameter

    $middlediameterfinal = $perimeterparcial / $M_PI ; if we do keep the number of coils (even if they don't fit in the max outer diameter
    ;I do calculate the diamter that a perfect spheric spring would have with this number of coils

    ;ConsoleWrite ( $middlediameterfinal & @CRLF)

    $Maxdiameterfinal = $middlediameterfinal + $wire ;the sring diameter would be the middle diameter of the new sphere plus the diameter of the wire

    GUICtrlSetData($label4, "With nt =" & $finalballs / 2 & " Ø =" & Round($Maxdiameterfinal, 4))
    ;I do inform int he gui about what size would have the spring to be completely shperic with this number of coils


EndFunc   ;==>calculate

Func proceed()
    $i = 1 ;a variable to increase during the loop to get the new position of every coil
    $degreejump = 360 / (Number(GUICtrlRead($inputnt)) * 2);    I calculate in how many degrees are we going to find the middle of each coil
    ;it is *2 because every coil is going to be formed by 2 wires (one on each side of the sphere)

    ConsoleWrite("One wire ball every " & $degreejump & " degree" & @CRLF & @CRLF)

    $firstdegree = $degreejump / 2 ;I do that to don't cut th first wire by the half like it is the 12 in a clock.

    Do
        $diameter0 = $middlediameterfinal * Cos($firstdegree) ; I look for the lenght of the c side of the triangle knowing that the hipotenuse = radius of the middle sphere * cos of the
        ;A angle (look to the drawing)
        $diameter1 = ($diameter0 * 2) + $wire ;so now, knowing the lenght of the c side I multiplicate it by 2 and I add the wire diameter to get the diameter of the spring
        ;in that point
        ConsoleWrite("The outer diameter of the " & $i & " coil is: " & $diameter1 & @CRLF)
        $i = $i + 1
        ;$degreejump = $degreejump * $i
        $firstdegree = $firstdegree + $degreejump

    Until $firstdegree > 90
    Exit


EndFunc   ;==>proceed

Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    Local $iIDFrom = BitAND($wParam, 0xFFFF);LoWord
    Local $iCode = BitShift($wParam, 16) ;HiWord

    If $iIDFrom = $input1 And $iCode = $EN_CHANGE Then

        $Read_Input = GUICtrlRead($input1)
        If StringRegExp($Read_Input, '[^\d.-]|([{0-9,1}^\A-])[^\d.]') Then $Read_Input = StringRegExpReplace($Read_Input, '[^\d.-]|([{0-9,1}^\A-])[^\d.]', '\1')
        $Point1 = StringInStr($Read_Input, ".", 0)
        $Point2 = StringInStr($Read_Input, ".", 0, 2)
        If $Point2 <> 0 Then $Read_Input = StringLeft($Read_Input, $Point2 - 1)
        If $Point1 <> 0 Then $Read_Input = StringLeft($Read_Input, $Point1 + $iDecimal)
        GUICtrlSetData($input1, $Read_Input)

    EndIf

    If $iIDFrom = $input2 And $iCode = $EN_CHANGE Then

        $Read_Input2 = GUICtrlRead($input2)
        If StringRegExp($Read_Input2, '[^\d.-]|([{0-9,1}^\A-])[^\d.]') Then $Read_Input2 = StringRegExpReplace($Read_Input2, '[^\d.-]|([{0-9,1}^\A-])[^\d.]', '\1')
        $Point11 = StringInStr($Read_Input2, ".", 0)
        $Point22 = StringInStr($Read_Input2, ".", 0, 2)
        If $Point22 <> 0 Then $Read_Input2 = StringLeft($Read_Input2, $Point22 - 1)
        If $Point11 <> 0 Then $Read_Input2 = StringLeft($Read_Input2, $Point11 + $iDecimal)
        GUICtrlSetData($input2, $Read_Input2)

    EndIf

    If $iIDFrom = $inputnt And $iCode = $EN_CHANGE Then

        $Read_Inputnt = GUICtrlRead($inputnt)
        If StringRegExp($Read_Inputnt, '[^\d.-]|([{0-9,1}^\A-])[^\d.]') Then $Read_Inputnt = StringRegExpReplace($Read_Inputnt, '[^\d.-]|([{0-9,1}^\A-])[^\d.]', '\1')
        $Point11 = StringInStr($Read_Inputnt, ".", 0)
        $Pointntnt = StringInStr($Read_Inputnt, ".", 0, 2)
        If $Pointntnt <> 0 Then $Read_Inputnt = StringLeft($Read_Inputnt, $Pointntnt - 1)
        If $Point11 <> 0 Then $Read_Inputnt = StringLeft($Read_Inputnt, $Point11 + $iDecimal)
        GUICtrlSetData($inputnt, $Read_Inputnt)

    EndIf

EndFunc   ;==>MY_WM_COMMAND

My goal is to fill an array with the needed diameters in each coil (I can program the machine increasing 1 coil while it is increasing the diameter to the next calculated point).

My problem is that I don't know how to correctly do the looping to get the lenght of the c side of the triangle everytime that I pass from one coil to another.

Could anybody please bring some light?

Thanks a lot for all your help.

Edited by adolfito121

Share this post


Link to post
Share on other sites



Sorry but I don't understand what a "spherical spring" means. Can you post a link to a picture of such a real-world object?

In your picture the arm 'c' depends on which little circle (coil or whorl?) you choose.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Sorry but I don't understand what a "spherical spring" means. Can you post a link to a picture of such a real-world object?

In your picture the arm 'c' depends on which little circle (coil or whorl?) you choose.

 

Hello and thanks for taking a look.

This is a spherical spring:

88oz.jpg

(Not perfect yet).

The c side of the triangle changes as we are passing from one coil to the next one.

Dibujo+zoom+bola2.jpg

The blue sphere is the outer diameter of the spring.

The green one has the same diameter minus the wire diameter. The little circles are the wire cutted.

Edited by adolfito121

Share this post


Link to post
Share on other sites

Ha! What you're looking at is a spiral mapped on a sphere.

In your idealized drawing, there are 15 wires (turns) for the (right or left) upper half-sphere drawn. The first half-turn on the right (the wire just above the right angle named B) makes angle A = 90/15 = 6° or (Pi/2 * 1/15) = Pi/30.

If we call R the radius, then c = R * Sin(Pi/30)

For the second wire on the right, c = R * Sin(2 * Pi/30)

For the third wire on the right, c = R * Sin(3 * Pi/30)

I leave it to you to code the loop.

2 people like this

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Thanks a lot for your help!

your "spiral mapped on a sphere" sounds far better than my spherical spring :D

I'll try it as soon as we get back home from the cinema, but I can't wait to say thanks.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

This is rather interesting. Of course the radius R decreases (or increases) in relation to the thickness of the coil as you follow the spring round. I'm not sure what the best approach is to work this out. Perhaps calculating the length of coil needed to cover the surface area of the sphere is a useful step, but I'll leave this to the experts. I'm curious how this would be done.

BTW adolfito121 it's spelt hypotenuse. ;)

Edited by czardas
1 person likes this

Share this post


Link to post
Share on other sites

This is rather interesting. Of course the radius R decreases (or increases) in relation to the thickness of the coil as you follow the spring round. I'm not sure what the best approach is to work this out. Perhaps calculating the length of coil needed to cover the surface area of the sphere is a useful step, but I'll leave this to the experts. I'm curious how this would be done.

BTW adolfito121 it's spelt hypotenuse. ;)

 

You're right. The thickness of the wire lets you have more or less coils to get a better spheric shape. The thinner the better. One of the good things or our CNC machines is that you can program the amount of milimeters on each step or just say to the machine "go from an Outer Diameter of 4.00mm to an Outer Diameters of 5.17mm using one coil" and it will do it smoothly and synchronizing the movement of the diameter with the wire feeding.

I guess that is very complicated to get a perfect shape because is not possible to start the spring with a diameter of 2 times the wire (you have to cut the finished spring). And also there is the point that the coils that I've drawed are represented perfectly paralel to the ecuator of the sphere and in the real world they are a spiral and not cutted rings superposed (as jchd has pointed it is an idealized drawing).

Another interesting possibilty is that I can create the same shape with less wire giving some space beetween the coils (so it would be a real spring that can be compressed).

I'm going to test now the solution given by jchd. If it works I will post pictures of the finished spring when I have it (there are no requeriments in the size or the wire, we are just playing to see how we can do it).

Thanks again.

PS: thanks a lot for the hypotenuse correction. As a non-English speaker I really appreciate any correction in my grammar.

1 person likes this

Share this post


Link to post
Share on other sites

You can find a representation of your spiral on this page: it is the animation at the right in Three-dimensional spirals.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

@jchd I have tested your solution and it gives back some realistic results (first coil uses to be 2 if the wire is 1):

Now my proceed function looks like:

Func proceed()
    $i = 1 ;a variable to increase during the loop to get the new position of every coil
    $degreejump = 360 / (Number(GUICtrlRead($inputnt)) * 2);    I calculate in how many degrees are we going to find the middle of each coil
    ;it is *2 because every coil is going to be formed by 2 wires (one on each side of the sphere)

    ConsoleWrite("One wire ball every " & $degreejump & " degree" & @CRLF & @CRLF)
    ConsoleWrite ("there are " & GUICtrlRead($inputnt)* 2 & " balls" & @CRLF & @CRLF)
    Consolewrite ("I'm going to put " & GUICtrlRead($inputnt) / 2 & " balls on each cuarter of the sphere"& @CRLF & @CRLF)

    $firstdegree = $degreejump / 2 ;I do that to don't cut th first wire by the half like it is the 12 in a clock.
    $jchd = ($M_PI/2)*(1/(GUICtrlRead($inputnt)/2)) ;as the input indicates the amount of desired coils and I'm looking for cuts of wire
                                                    ;I divide the coils by 2
    Do
        ;ConsoleWrite($firstdegree & @CRLF)
        $diameter0 = $middlediameterfinal * sin($i*$jchd) ; I look for the lenght of the c side of the triangle knowing that the hipotenuse = radius of the middle sphere * cos of the
        ;ConsoleWrite($diameter0 & @CRLF)
        ;A angle (look to the drawing)
        $diameter1 = ($diameter0 * 2) + $wire ;so now, knowing the lenght of the c side I multiplicate it by 2 and I add the wire diameter to get the diameter of the spring
        ;in that point
        ConsoleWrite("The outer diameter of the " & $i & " coil is: " & $diameter1 & @CRLF & @CRLF)
        $i = $i + 1
        $degreejump = $degreejump * $i
        $firstdegree = $firstdegree + $degreejump

    Until $i > GUICtrlRead($inputnt)/2 + 1
    Exit


EndFunc   ;==>proceed

But I never rise the desired max outer diameter in the created spring. For example, with a wire diameter of 1, a max outer diameter of 30 and using 45 coils this is what the program gives back:

The outer diameter of the 1 coil is: 2.01105977821666
 
The outer diameter of the 2 coil is: 3.02181157783053
 
The outer diameter of the 3 coil is: 4.03194751405206
 
The outer diameter of the 4 coil is: 5.04115988968967
 
The outer diameter of the 5 coil is: 6.04914128887729
 
The outer diameter of the 6 coil is: 7.05558467071618
 
The outer diameter of the 7 coil is: 8.06018346280261
 
The outer diameter of the 8 coil is: 9.06263165461274
 
The outer diameter of the 9 coil is: 10.0626238907164
 
The outer diameter of the 10 coil is: 11.0598555637914
 
The outer diameter of the 11 coil is: 12.0540229074096
 
The outer diameter of the 12 coil is: 13.0448230885674
 
The outer diameter of the 13 coil is: 14.0319542999317
 
The outer diameter of the 14 coil is: 15.0151158517729
 
The outer diameter of the 15 coil is: 15.9940082635581
 
The outer diameter of the 16 coil is: 16.968333355176
 
The outer diameter of the 17 coil is: 17.9377943377652
 
The outer diameter of the 18 coil is: 18.9020959041191
 
The outer diameter of the 19 coil is: 19.860944318639
 
The outer diameter of the 20 coil is: 20.8140475068094
 
The outer diameter of the 21 coil is: 21.7611151441663
 
The outer diameter of the 22 coil is: 22.7018587447328
 
The outer diameter of the 23 coil is: 23.635991748895
 
 
 
It doesn't arrives at a diameter of 29mm. elboinas.gif

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Brilliant topic! Unfortunately I can't contribute much, but I would love to understand the maths involved. I imagine calculus would be perfect for this, but it's so long ago since I used calculus and I'm not really sure.

Your CNC machine sounds very cool. :thumbsup:

Edited by czardas

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

If you want your turns (coils) to be joined (i.e. leaving no gap between successive turns) you can't just select wire diameter, outer diameter and number of turns by yourself. These three parameters are inter-dependant. You can choose two of them and the third will result from a fairly complex computation. If you select wire and outer diameters, then keep on looping more turns until you reach the outer diameter assigned. But, as you'll instantly notice, you can't do that that easily, since to compute the angle between successive wires, you have to decide how many turns will make it. Your best bet is trial and error.

To illustrate that, have a look at the Mathematica notebook I just rushed. You can download a free demo version of Wolfram Mathematica to run this notebook. Observe that the curve is wrong at top or bottom of the shape. This is due to the simplistic approach I used to create the representation. Making the wires joined everywhere is (mathematically) much harder. I left the curve drawn as a single line to simplify viewing. You can rotate the drawing in all three axes by using the mouse on it.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Although you won't get exactly to the starting point, due to floating point computational limits.


"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Brilliant topic! Unfortunately I can't contribute much, but I would love to understand the maths involved. I imagine calculus would be perfect for this, but it's so long ago since I used calculus and I'm not really sure.

 

Your CNC machine sounds very cool. :thumbsup:

 

Thanks! I also would love to understand how can I get it instead of just get the soultion. I've never heard about calculus before. I'm going to google it while I'm having my matinal coffee roto2cafe.gif

 

Certainly we are very happy with our machines. We are very lucky to have machine builders like Wafios in Europe.

 

 

 

If you want your turns (coils) to be joined (i.e. leaving no gap between successive turns) you can't just select wire diameter, outer diameter and number of turns by yourself. These three parameters are inter-dependant. You can choose two of them and the third will result from a fairly complex computation. If you select wire and outer diameters, then keep on looping more turns until you reach the outer diameter assigned. But, as you'll instantly notice, you can't do that that easily, since to compute the angle between successive wires, you have to decide how many turns will make it. Your best bet is trial and error.

 

To illustrate that, have a look at the Mathematica notebook I just rushed. You can download a free demo version of Wolfram Mathematica to run this notebook. Observe that the curve is wrong at top or bottom of the shape. This is due to the simplistic approach I used to create the representation. Making the wires joined everywhere is (mathematically) much harder. I left the curve drawn as a single line to simplify viewing. You can rotate the drawing in all three axes by using the mouse on it.

 

I guess that I'll have just to select the wire and the desired outer diameter then. I guess that I will have to do a loop after the first loop increasing the number of turns or something like that facepalm.gif

 

Anyway thanks a lot for taking the time to read and try to help (you did).

 

 

 

Although you won't get exactly to the starting point, due to floating point computational limits.

Yes, I know, in fact I'm not going to be able to reproduce any of the poles of the sphere (I can not bend the wire as much).

I know that the perfect sphere is not going to be possible, but at least I want a pretty rounded shape.

One of my goals was also to be able to include the starting diameter of the spring and then follow doing the sphere from there (like I I have cutted the poles).

I hoped to find a constant diameter increase from one coil to the next one or something like that... sisi3.gif

Edited by adolfito121

Share this post


Link to post
Share on other sites

 I've never heard about calculus before. I'm going to google it while I'm having my matinal coffee roto2cafe.gif

 

It's a big subject and well worth your time if you study it. You'll need several more coffees though. I need some coffee myself right now.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Czardas linked me to this thread, and it's a very cool problem.

Unfortunately I don't have nearly as much time as I'd like to have on fun maths problems, but the maths isn't actually that complex if you base it on the radius of the large circle R, and the radius of the smaller circles r. The angle A for circle n, and then the length C is:

A = (2n+1)atan(r/(R-r))
C = (R-r)sin(A)

I haven't really checked it and it's based on a bit of scribbling at the side of my lecture notes. It looks about right though.

Good luck :-)

Edited by Mat

Share this post


Link to post
Share on other sites

Nah, unless I misunderstand you, you're confusing the apotheme with the inner (empty) sphere radius and the circumcicle with the outer (visible) sphere.

Allow me some time to make a drawing of that.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

As always, been attracted elsewhere...

Here is another Mathematica notebook for drawing a cut the beast.

The same thing in web format.

EDIT: fix html download

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

I based my maths completely off the diagram provided in the first post, which shows a circle, with smaller circles arranged around the outside. The OP asked to find the distance C. I assumed the variables were the radii of the circles, though reading through the thread it seems more sensible that one of them should be replaced by the number of circles instead (as you want an exact number). I then looked at the change of angle from one circle to the next, which I got to be 2atan(r/(R-r)). 

That's all I was doing. As mentioned above I was not considering that the circles have to meet at the other side, because the diagram does not imply that, so I didn't consider the center points of the circles to be a polygon like you have (I can't see any of the images on your web link, and don't have mathematica, but I'm 99% sure that's what you are trying to say).

Share this post


Link to post
Share on other sites

Mat,

I've read you too fast. Yes but you can't do that in practice, as you can't select the radii arbitrarily (again if one wants an integral number of "turns"). I've fixed the html download. And if you look at my previous posts you'll find a link to a free Mathematica player.

It's true that a precise description of a cut isn't hard, but I was refering to the equations for drawing the 3D curve when one insist in making all wires touch everywhere.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Czardas linked me to this thread, and it's a very cool problem.

Unfortunately I don't have nearly as much time as I'd like to have on fun maths problems, but the maths isn't actually that complex if you base it on the radius of the large circle R, and the radius of the smaller circles r. The angle A for circle n, and then the length C is:

A = (2n+1)atan(r/(R-r))

C = (R-r)sin(A)

I haven't really checked it and it's based on a bit of scribbling at the side of my lecture notes. It looks about right though.

Good luck :-)

 

 

 

I based my maths completely off the diagram provided in the first post, which shows a circle, with smaller circles arranged around the outside. The OP asked to find the distance C. I assumed the variables were the radii of the circles, though reading through the thread it seems more sensible that one of them should be replaced by the number of circles instead (as you want an exact number). I then looked at the change of angle from one circle to the next, which I got to be 2atan(r/(R-r)). 

 

That's all I was doing. As mentioned above I was not considering that the circles have to meet at the other side, because the diagram does not imply that, so I didn't consider the center points of the circles to be a polygon like you have (I can't see any of the images on your web link, and don't have mathematica, but I'm 99% sure that's what you are trying to say).

 

 

Thanks for coming to bring up some light. I'm trying to port to my script your example but I get werid result:

One wire ball every 5 degree

 

The outer diameter of the 0 coil is: 43.9947518820494

The outer diameter of the 1 coil is: -2.03997184601894

The outer diameter of the 2 coil is: -43.7194019972262

The outer diameter of the 3 coil is: -21.3304347602646

The outer diameter of the 4 coil is: 33.0508021443449

The outer diameter of the 5 coil is: 41.5136359244933

The outer diameter of the 6 coil is: -8.06642912953847

The outer diameter of the 7 coil is: -44.657242126958

The outer diameter of the 8 coil is: -15.8360370383747

The outer diameter of the 9 coil is: 37.1057480052676

The outer diameter of the 10 coil is: 38.3197078122921

The outer diameter of the 11 coil is: -13.9333682474999

The outer diameter of the 12 coil is: -44.7917715591181

The outer diameter of the 13 coil is: -10.0454197458846

The outer diameter of the 14 coil is: 40.5254357501655

The outer diameter of the 15 coil is: 34.4691627184411

The outer diameter of the 16 coil is: -19.5375640654908

The outer diameter of the 17 coil is: -44.1206233322574

 

In the beggining of my script I have three inputs where I input the desired wire diameter and the desired outer diameter. It doesn't mind if I input any amount of coils because the script tells me how many coils I'm going to need to get the desired diameter and rounding the number of coils it calculates the closer diameter I can get:

 

72yu.jpg

 

As I have no diameter or wire or coils requeriments (I'm just playing with the machine to learn) so when I proceed the amount of coils to be used and the outer diameter to reach is going to be nt=96.5 coils (193 cuts of wire) and the max outer diameter would be 24.9735 (it is pretty close and the springs made of stainless material do grow their outer diameter when I put them in a hoven).

 

Now that the coils do match with the max outer diameter I get the angle A for circle n just dividing the 360 possible degrees in the circle per the number of cuts of wire. Till here we get the same result.

 

But when I try to do the loop with C = (R-r)sin(A)  I fail somewhere nusenuse.gif

 

I tried:

Func proceed()
    $i = 0 ;a variable to increase during the loop to get the new position of every coil
    $degreejump = 360 / (Number(GUICtrlRead($inputnt)) * 2);    I calculate in how many degrees are we going to find the middle of each coil
    ;it is *2 because every coil is going to be formed by 2 wires (one on each side of the sphere)

    ConsoleWrite("One wire ball every " & $degreejump & " degree" & @CRLF & @CRLF)

    $firstdegree = $degreejump / 2 ;I do that to don't cut th first wire by the half like it is the 12 in a clock.

    Do
        $firstdegree = $firstdegree + $degreejump ;I do that to don't cut th first wire by the half like it is the 12 in a clock.
        $diameter0 = $middlediameterfinal * sin($firstdegree) ; I look for the lenght of the c side of the triangle knowing that the hipotenuse = radius of the middle sphere * cos of the
        ;A angle (look to the drawing)
        $diameter1 = ($diameter0 * 2) + $wire ;so now, knowing the lenght of the c side I multiplicate it by 2 and I add the wire diameter to get the diameter of the spring
        ;in that point
        ConsoleWrite("The outer diameter of the " & $i & " coil is: " & $diameter1 & @CRLF)
        $i = $i + 1


    Until $firstdegree > 90
    Exit


EndFunc   ;==>proceed

The funny part is that if I take the A angle for each wire segment and use an app I get (what it looks like) correct results

b70d.jpg

 

So my problem is that I still suck coding in Autoit

 

Mat,

 

I've read you too fast. Yes but you can't do that in practice, as you can't select the radii arbitrarily (again if one wants an integral number of "turns"). I've fixed the html download. And if you look at my previous posts you'll find a link to a free Mathematica player.

 

It's true that a precise description of a cut isn't hard, but I was refering to the equations for drawing the 3D curve when one insist in making all wires touch everywhere.

Thanks for your help. Even when I don't understand you most of the time I really enjoy reading you both abrazo.gif

One thing that I have noticed now is that I haven't explained how I do code in the CNC machines. They have a nice gui where I do indicate the current diameter of the spring and how much coils I do want it to feed while it increases the diameter.

When I have coiled the wire with the smallest diameter that I can I can "lie" to the machine telling it that this diameter is whatever value that I want. So if the diameter at the beggining is 2.40 mm and doing the calculation of the sphere I have a similar value (like 2.10mm) I can just input 2.10 as first diameter and fill the rest of the program with the others diameters obtained with the calculator (or maybe with a _arrayDisplay f5.gif). As the movements of the machine are always syncronized I guess that the real spring is going to be more similar to a torus than similar to my first drawing.

Greets from Barcelona

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0