Click here to Skip to main content
16,019,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to move a circle along a circular path(circumference of another circle). How can i do it?Any help will be appreciated but not links from google. Because i searched for it but couldnot find any help about my task. Article explaining it will be more appreciated.and i think there is no need of source.

What I have tried:

i tried moving x and y co-ordinates of object but it always moves in horizontal or vertical line
Posted
Updated 26-Dec-17 1:31am
Comments
Afzaal Ahmad Zeeshan 26-Dec-17 7:03am    
What objects? What framework are you using?

1 solution

Circular movement isn't complicated, provided you change the x and y coordinates correctly: for a straight line, xn+1 = xn + c1 and yn+1 = yn + c2 where c1 and c2 are constant values.
For a circle, they aren't constants - they need to be recalculated for each step:
xn = r * cos(a) and yn = r * sin(a) where r is the radius and a in the angle in radians. For each step, you change a slightly (how much depends on you and how accurate you need your circle: the bigger the increment, the less circular and the more polygonal it looks). Try 0.1, and check it's value against pi * 2 to see if you have reached the end of the circle.
 
Share this answer
 
Comments
[no name] 26-Dec-17 7:36am    
Please give me sample code.
OriginalGriff 26-Dec-17 7:39am    
You are kidding, right?
You can't convert
x = r * cos(a)
into VB yourself?
[no name] 26-Dec-17 7:41am    
I am confusing in defining variables
OriginalGriff 26-Dec-17 7:54am    
You can;t define a variable on your own? :OMG:

Dim nameOfMyVariable As typeOfMyVariable = initialValueForMyVariable

E.g.:

Dim i As Integer = 666

You need to go back to basics and ready through your first few classes again...
[no name] 26-Dec-17 8:34am    
i mean can you tell me values for angle and radius(as sample) and then tell new coordinates of object

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900