473,386 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Rotating a shape

Ali Rizwan
925 512MB
Hi all,
I have a big circle, and a small circle inside the big one.
Now I want to make a motion to small circle so that it will move with the boundary of the big circle inside or outside boundary.
How can I do this?
Thanks.
Oct 8 '07 #1
4 3817
debasisdas
8,127 Expert 4TB
Use SIN and COS for the purpose.
Oct 8 '07 #2
Killer42
8,435 Expert 8TB
I have a big circle and a small circle inside the big one.
Now i want to make a motion to small circle so that it will moves with the boundry of the big circle inside or outside boundry.
So in fact, this question has nothing to do with rotating a shape - correct?

As for how, I'd say all you need to do is make sure that the Distance between the two centre-points plus the radius of the smaller circle doesn't exceed the radius of the larger one.

Pythagorus' theorem will give you the distance, and presumably you already know the radii, from drawing the circles.

Can you please explain in more detail what you mean by "move with the boundary of the big circle inside or outside boundary"? Also, what version of VB are you using?
Oct 9 '07 #3
This code will rotate a circle within a circle, and can be modified for rotation on the outside. Could be a start for a Spirograph program.

Expand|Select|Wrap|Line Numbers
  1. Sub Demo()
  2.     Const Pi = 3.1415
  3.     Dim radius1    As Long, radius2    As Long
  4.     Dim Alpha      As Single, dAlpha     As Single
  5.     Dim X1         As Single, X2         As Single
  6.     Dim X3         As Single, Y1         As Single
  7.     Dim Y2         As Single, Y3         As Single
  8.     Dim cx         As Single, cy         As Single
  9.     Dim i          As Integer, j          As Integer
  10.     Dim z          As Long, offset        As Integer
  11.     Dim k          As Integer, num        As Integer
  12.     BackColor = vbWhite
  13.     AutoRedraw = True
  14.     Cls
  15.     radius1 = ScaleHeight / 2 - 100
  16.     radius2 = 1600
  17.  
  18.     ' find center screen and Draw the circle.
  19.     ForeColor = vbRed
  20.     cx = (ScaleWidth) / 2
  21.     cy = (ScaleHeight) / 2
  22.     Circle (cx, cy), radius1
  23.     ForeColor = vbBlack
  24.  
  25.     dAlpha = Pi / 10     'test value for 20 lines
  26.  
  27.     Alpha = 0
  28.     For i = 1 To 21
  29.         'Draw radiating lines.
  30.         X1 = cx + (radius1) * Cos(Alpha)
  31.         Y1 = cy + (radius1) * Sin(Alpha)
  32.         'Line (cx, cy)-(X1, Y1)
  33.  
  34.         'determine new position where smaller circles will be drawn
  35.         X3 = cx + ((radius1 - (radius2 + 20)) * Cos(Alpha))
  36.         Y3 = cy + ((radius1 - (radius2 + 20)) * Sin(Alpha))
  37.  
  38.         'draw dots on the lines showing center point for smaller circles
  39.         DrawWidth = 4
  40.         'PSet (X3, Y3)
  41.         DrawWidth = 1
  42.         'draw the smaller circle
  43.         If radius2 > 0 Then
  44.           Circle (X3, Y3), radius2
  45.         End If
  46.  
  47.         'blank out the last line/circle drawn to creat rotating line/circle
  48.         If i < 21 Then
  49.           For z = 1 To 5000000: Next
  50.           DoEvents
  51.           ForeColor = vbWhite
  52.           Circle (X3, Y3), radius2
  53.           Line (cx, cy)-(X1, Y1)
  54.         End If
  55.         ForeColor = vbBlack
  56.         'draw dots on the outer circle
  57.         DrawWidth = 4
  58.         'PSet (X2, Y2)
  59.         DrawWidth = 1
  60.         Alpha = Alpha + dAlpha
  61.     Next i
  62.  
  63. End Sub
Nov 20 '07 #4
Killer42
8,435 Expert 8TB
This code will rotate a circle within a circle...
I think we have a terminology problem here. If you rotate a circle, surely this has no effect.

Ali, can you give us some feedback here, on what you actually wanted to do, and how it's going?
Nov 20 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ian Hubling | last post by:
I'm trying to complete a rotating banner ad within a page I have. The rotating add has four images that rotate in three-second increments. I've got the images to rotate ok - but now I want to go...
1
by: Sandy Bremmer | last post by:
I have seen many Javascripts that rotate images with each load or refresh of the page but so far all I've found require hard coding the image filename into the script. Does anyone know of a script...
3
by: no.reply7 | last post by:
I used script CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D to rotate an image but it does not seem to work in internet explore 7. Does anyone know a work around?
3
by: avalence | last post by:
Hello, I am trying to create a nice rotating earth globe (on mouse) on my web site, in order to display my professional relationships all over the world. The best way seems to be a javascript. In...
1
by: AR123 | last post by:
Hi I want to set up a rotating banner. Not sure how to incorporate my rotating banner code into the code below. I want the rotating banner to be the main feature image? This is set up in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.