Recommended Posts

Hi all,

I'd like to make a polar coordinate system for a loading screen, but i don't have understand the math behind it ( i'm not good in math but i like programming )

This is the basic script:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

\$Form1 = GUICreate("Form1", 450, 450, -1, -1)
\$Label1 = GUICtrlCreateLabel("a", 225, 15, 20, 50)
GUICtrlSetBkColor(-1, "000000")
For \$x = 1 To 12
;how to do?
Next
GUISetState(@SW_SHOW)

While 1
\$nMsg = GUIGetMsg()
Switch \$nMsg
Case \$GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

I'd like to di it with simply colored label and GuiCtrlSetPos.

A little help, thanks Nothing is so strong as gentleness. Nothing is so gentle as real strength

Share on other sites

Terenz,

This explains the entire deal in easy to understand terms.

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share on other sites

This is the basic script:

As a base, you can choose any script in this forum. It makes no sense, if your script does not contain that relates to the topic.

Local Const \$pi = 4 * ATan(1)

\$x = -6
\$y = 5

Select
Case \$x > 0 And \$y >= 0
\$f = ATan(\$y / \$x)
Case \$x > 0 And \$y < 0
\$f = ATan(\$y / \$x) + 2 * \$pi
Case \$x < 0
\$f = ATan(\$y / \$x) + \$pi
Case \$x = 0 And \$y > 0
\$f = \$pi / 2
Case \$x = 0 And \$y < 0
\$f = 3 * \$pi / 2
Case \$x = 0 And \$y = 0
\$f = 0
EndSelect
\$r = Sqrt(\$x ^ 2 + \$y ^ 2)
MsgBox(0, 'Polar coordinate', _
'angle = ' & \$f & ' radians,     = ' & Round(\$f / \$pi * 180, 1) & ' degrees' & @LF & _
'radius = ' & \$r)

\$x = \$r * Cos(\$f)
\$y = \$r * Sin(\$f)
MsgBox(0, 'Cartesian coordinates', _
'x = ' & \$x & @LF & _
'y = ' & \$y)
Edited by AZJIO

Share on other sites

kylomas, i can't check video from here because i have some problem with flash player

AZJIO, you have absolutely right but was just for make an idea of what i want to do, this: Sorry for the horrible draw. I have try something like this:

\$PI = 3.14159
Global \$Label

For \$index = 0 To 12
\$xsp = \$Radius * Sin(\$PI * \$index / 8)
\$ysp = -1 * \$Radius * Cos(\$PI * \$index / 8)
\$xep = 1.15 * \$Radius * Sin(\$PI * \$index / 8)
\$yep = -1.15 * \$Radius * Cos(\$PI * \$index / 8)
GUICtrlSetPos(\$Label[\$index], \$xsp + 45, \$ysp + 45)
Next

But don't work, thanks for any help

Nothing is so strong as gentleness. Nothing is so gentle as real strength

Share on other sites

This is what i have do until now:

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

HotKeySet("{Esc}", "_Exit")

Global \$PI = 3.1415926535897932384626433832795
Global \$Width = 300, \$Height = \$Width, \$iX = -1, \$iY = -1
Global \$Radius = Int(\$Width * 0.5)
Global \$Label

GUICreate("", \$Width, \$Height, \$iX, \$iY)

For \$n = 0 To 60 - 1 Step 5
For \$i = 0 To \$Radius - 5
\$curX = \$Width / 2 + Cos(\$PI / 2 - (\$Radius * \$n / 60 * \$PI / (\$Radius / 2))) * \$i
\$curY = \$Width / 2 - Sin(\$PI / 2 - (\$Radius * \$n / 60 * \$PI / (\$Radius / 2))) * \$i
\$Label[\$n] = GUICtrlCreateLabel("", \$curX, \$curY, 2, 2)
GUICtrlSetBkColor(-1, 000000)
Next
Next
GUISetState(@SW_SHOW)

While 1
Sleep(100)
WEnd

Func _Exit()
Exit
EndFunc   ;==>_Exit

And i don't know if it is the correct approach to my final result...

Anyaway, the script do this: My goal is this: How to do that? Where is my mistake?

Thanks

Nothing is so strong as gentleness. Nothing is so gentle as real strength

Share on other sites

For \$n = 0 To 60 - 1 Step 5
For \$i = 90 To \$Radius - 5
\$curX = \$Width / 2 + Cos(\$PI / 2 - (\$Radius * \$n / 60 * \$PI / (\$Radius / 2))) * \$i
\$curY = \$Width / 2 - Sin(\$PI / 2 - (\$Radius * \$n / 60 * \$PI / (\$Radius / 2))) * \$i
\$Label[\$n] = GUICtrlCreateLabel("", \$curX, \$curY, 1, 1)
GUICtrlSetBkColor(-1, 000000)
Next
Next

Monkey's are, like, natures humans.

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