By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

rotate around button

P: n/a
Hi!
How to rotate one button around another like Sun and Planet?
Sample, please!
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Magic Gooddy" <go****@rambler.ru> wrote in message
news:uq*************@TK2MSFTNGP11.phx.gbl...
Hi!
How to rotate one button around another like Sun and Planet?
Sample, please!


I suppose manipulating the location with a loop would do it. Just be sure to
watch the "bring to front" property.
Nov 21 '05 #2

P: n/a

"Magic Gooddy" <go****@rambler.ru> wrote in message
news:uq*************@TK2MSFTNGP11.phx.gbl...
How to rotate one button around another like Sun and Planet?
Sample, please!


I don't have a sample, but I can suggest a direction. You just need to use a
little trigonometry to calculate the x and y coordinates that the revolving
button will need as you go from 0 to 360 degrees. Cosine will give you the x
and Sine will give you the y.
Nov 21 '05 #3

P: n/a
VB uses Radians, not degrees for all of its trig. Remeber
to convert from one to the other to make sure everthing
works out fine.

2PI radians = 360 degrees.

1Pi radians = 180 degrees.

The code below draws a second hand on a clock face
using trig and radians.

Private Sub DrawSeconds()

Dim x As Double
Dim y As Double
Dim x1, y1 As Double
Dim myPen As New Pen(Color.Black, 1)

Dim rads As Double = ((Second * 6) - 180) * (PI / 180)

x = Centre.X - (((FaceWidth / 2) - 10) * Sin(rads))
x1 = Centre.X - (10 * Sin(rads))
y = Centre.Y + (((FaceWidth / 2) - 10) * Cos(rads))
y1 = Centre.Y + (10 * Cos(rads))
g.DrawLine(myPen, CInt(x1), CInt(y1), CInt(x), CInt(y))

End Sub
Good luck.

On Wed, 18 Aug 2004 12:03:53 -0400, "Jeff Johnson [MVP: VB]"
<i.***@enough.spam> wrote:

"Magic Gooddy" <go****@rambler.ru> wrote in message
news:uq*************@TK2MSFTNGP11.phx.gbl...
How to rotate one button around another like Sun and Planet?
Sample, please!


I don't have a sample, but I can suggest a direction. You just need to use a
little trigonometry to calculate the x and y coordinates that the revolving
button will need as you go from 0 to 360 degrees. Cosine will give you the x
and Sine will give you the y.


Nov 21 '05 #4

P: n/a
Magic,

As Jason points out, everything is done in Radians. This isn't just a VB thing,
every app that uses trigonometry nowadays really uses Radians internally.

Now I hate to ask, but why do you want Buttons to do this? Would someone be
trying to click the thing?
What will be your trigger? Will it just revolve at a particular interval, say
using a timer? Or will it move based another event of some sort?
Do you need to deal with the fact that mathematically you will get a point, but
since the button has width and height, it won't appear to make a circle unless
you account for this and use the calculated center point of the button.

Gerald

"Jason L James" <ja***@no-spam.dive-master.org> wrote in message
news:41***************@news.demon.co.uk...
VB uses Radians, not degrees for all of its trig. Remeber
to convert from one to the other to make sure everthing
works out fine.

2PI radians = 360 degrees.

1Pi radians = 180 degrees.

The code below draws a second hand on a clock face
using trig and radians.

Private Sub DrawSeconds()

Dim x As Double
Dim y As Double
Dim x1, y1 As Double
Dim myPen As New Pen(Color.Black, 1)

Dim rads As Double = ((Second * 6) - 180) * (PI / 180)

x = Centre.X - (((FaceWidth / 2) - 10) * Sin(rads))
x1 = Centre.X - (10 * Sin(rads))
y = Centre.Y + (((FaceWidth / 2) - 10) * Cos(rads))
y1 = Centre.Y + (10 * Cos(rads))
g.DrawLine(myPen, CInt(x1), CInt(y1), CInt(x), CInt(y))

End Sub
Good luck.

On Wed, 18 Aug 2004 12:03:53 -0400, "Jeff Johnson [MVP: VB]"
<i.***@enough.spam> wrote:

"Magic Gooddy" <go****@rambler.ru> wrote in message
news:uq*************@TK2MSFTNGP11.phx.gbl...
How to rotate one button around another like Sun and Planet?
Sample, please!


I don't have a sample, but I can suggest a direction. You just need to use a
little trigonometry to calculate the x and y coordinates that the revolving
button will need as you go from 0 to 360 degrees. Cosine will give you the x
and Sine will give you the y.

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.