Jump to content

Spiral Creator


AutoItKing
 Share

Recommended Posts

I used some of my Algebra 2 skills for this one. The unit Circle. You know: p = [ r cos(ÆŸ) , r sin(ÆŸ) ]

ÆŸ = Theta

Making the unit circle is really easy.

The Unit Circle:

Posted Image

#include<GuiConstants.au3>
$theta = 1
$r = 250
GUICreate("Unit circle",500,500)
GUISetState()
$label = GUICtrlCreateLabel($theta,1,1,20)
While $theta <= 360
    GUICtrlCreatePic("px.bmp",($r*Cos($theta))+(500/2),($r*Sin($theta))+(500/2),1,1)
    $theta += 15
    GUICtrlSetData($label,$theta)
WEnd
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
oÝ÷ ØÚ0¶æ¬¦*ÚØ^®ö¥¹èZ²Ú"ÊÞjÇ°Ø^iÈmëZw+y«N¬²Ö«µçhºÚ'$Èóv¬¶¬r^¬9÷°ëkRªæ«{MQÐT-¹@+)¶©ûNr8ÓQ²)øÓx×íQûMQh÷(uäáÇ(uì"Y欦*Úéí¨º×¥+m¢Ëh¤ò¢ì"²h©¢w­«pYe¢+méâqêí¯+aÇ(u䨢{hrmjÜ©z+_»-çÃÿr^:K(¶­ßÛ²«jZ'iÆ¥réZ¶ÛºÜ!jÖ¢ë@ºÚµ8b²+0«HßÛÞrº"¶®¶­s`¢6æ6ÇVFRfÇC´wV6öç7FçG2æS2fwC°¢b33c·FWFÒ¢b33c¶Ò¢b33c·"ÒçWD&÷gV÷C²gV÷C²ÂgV÷CµvBvÆÂ"&SòBb33·27F'FærfÇVRgV÷C²Ã¢b33c·%òÒçWD&÷gV÷C²gV÷C²ÂgV÷C´'÷r×V6vÆÂ"æ7&V6RâV6FW&FöãògV÷C²Âã"¢b33c¶òÒçWD&÷gV÷C²gV÷C²ÂgV÷C´÷rÖçFW&Föç3ògV÷C²Ã2 ¤uT7&VFRgV÷Cµ7&ÂgV÷C²ÃSÃS ¤uT6WE7FFR¢b33c¶Æ&VÂÒuT7G&Ä7&VFTÆ&VÂb33c·FWFÃà ¥vÆRb33c¶fÇC³Òb33c¶ð uT7G&Ä7&VFU2gV÷C·æ&×gV÷C²Âb33c·"¤6÷2b33c·FWF²Só"Âb33c·"¥6âb33c·FWF²Só"Ã"Ã" b33c·"³Òb33c·%ð b33c·FWF³Ò uT7G&Å6WDFFb33c¶Æ&VÂÂb33c·FWF bb33c·FWFfwC³Ò3cFVâ b33c·FWFÒ b33c¶³Ò VæD`¥tVæ@¥vÆR b33c¶×6rÒuTvWD×6r 7vF6b33c¶×6p 66Rb33c´uTôUdTåEô4Äõ4P W@ VæE7vF6¥tVæ@

You'll need to make a Bitmap that is 1x1 pixels, in any color other than what the GUI color is, preferably black.

Or you can use mine:

px.bmp

Feedback is welcome.

Edited by AutoItKing
http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script]
Link to comment
Share on other sites

This is pretty cool, but I don't even know what a therta is. lol

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

Just a bit of rework so you don't consume all of the AutoIt control IDs (and fix the "=<" bug too):

#include <GuiConstants.au3>

$theta = 1
$r = 250
$hGUI = GUICreate("Unit circle",500,500)
GUISetState()
$hDC = GetDC($hGUI)
$label = GUICtrlCreateLabel($theta,1,1,20)
While $theta <= 360
  SetPixel($hDC, ($r*Cos($theta))+(500/2), ($r*Sin($theta))+(500/2))
  $theta += 1
  GUICtrlSetData($label,$theta)
WEnd

do
until GUIGetMsg() = $GUI_EVENT_CLOSE

Func GetDC($hWnd)
  Local $aResult
  $aResult = DllCall("User32.dll", "hwnd", "GetDC", "hwnd", $hWnd)
  Return $aResult[0]
EndFunc

Func SetPixel($hDC, $iX, $iY, $iColor=0)
  DllCall("GDI32.dll", "int", "SetPixel", "hwnd", $hDC, "int", $iX, "int", $iY, "int", $iColor)
EndFunc
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

In a unit circle, for the formula p = [ r cos(Æ) , r sin(Æ) ], r=1.....

Also note that another formula for a unit circle at the origin is x^2 + y^2 = 1

So, what you're really doing is representing 250 pixels as 1 unit.

#)

Link to comment
Share on other sites

Here is a script I wrote a while back to draw spirals in MS paint for fun.

Press middle mouse button to draw spiral.

#include <Misc.au3>

HotKeySet("{ESC}","_Exit")
_Singleton("win")
While 1
    Local $pos = MouseGetPos()
    If _IsPressed("04") Then _MouseMoveCircle($pos[0],$pos[1], 1, 7000)
    Sleep(1000/@DesktopRefresh)
WEnd

Func _MouseMoveCircle($x, $y, $r, $t); x coord, y coord, radius, time to loop (milliseconds)
    $tInit = TimerInit()
    MouseDown("left")
    Do
        $timer = TimerDiff($tInit)
        $r += 0.1 ;Increase radius a little bit at a time to make spiral
        MouseMove($x + ($r * Sin($timer/100)), $y + ($r * Cos($timer/100)) ,1)
    Until $timer > $t
    MouseUp("left")
EndFunc

Func _Exit()
    Exit
EndFunc
Edited by Toady

www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Link to comment
Share on other sites

I like that one Toady, an actual continous spiral.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

In a unit circle, for the formula p = [ r cos(ÆŸ) , r sin(ÆŸ) ], r=1.....

Also note that another formula for a unit circle at the origin is x^2 + y^2 = 1

So, what you're really doing is representing 250 pixels as 1 unit.

#)

Another formula for a circle is:

(x2+h) + (y2+k) = r2

h is the x coord of the center, and k is the y coord. depending on how you change the r value, the size will change.

Edited by AutoItKing
http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script]
Link to comment
Share on other sites

  • 6 months later...

O boy i better learn alot this year or when i get to Alg2 im definatly going to fail.

So how is Algebra for you? Not too hard I hope.
http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script]
Link to comment
Share on other sites

Another formula for a circle is:

(x2+h) + (y2+k) = r2

h is the x coord of the center, and k is the y coord. depending on how you change the r value, the size will change.

I don't think it is.

Do you mean

(X - H)2 + (Y - K)2 = r2

with Xmax = h + r, Xmin = h - r ?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...