Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Circles & Perimeters + Points + Moving Question
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Kharybdis




PostPosted: Sun Mar 30, 2008 2:34 pm   Post subject: Circles & Perimeters + Points + Moving Question

Now, this is quite a puzzling question to me.

How would you move a point (x,y) on the perimeter of a perfect circle using a mathematical formula/equation/function.

I have no clue...

I'm just thinking that while i find the answer by other means, if any of the people here would help me.
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: Sun Mar 30, 2008 2:40 pm   Post subject: RE:Circles & Perimeters + Points + Moving Question

((x-k)^2+(y-h)^2=r^2. That is the equation of a circle. Try to expand on that formula.
A.J




PostPosted: Sun Mar 30, 2008 8:37 pm   Post subject: Re: Circles & Perimeters + Points + Moving Question

its called circumference, not perimeter.....
anyhow, if x**2 + y**2=radius**2 then your point's on the circle...
then try/experiment with different things, like try increasing.decreasing the x and y values and see if it is still is in accordance with the circle's equation etc...
CodeMonkey2000




PostPosted: Sun Mar 30, 2008 8:40 pm   Post subject: RE:Circles & Perimeters + Points + Moving Question

Using trig is better, but I doubt you know trig.
A.J




PostPosted: Sun Mar 30, 2008 10:43 pm   Post subject: Re: Circles & Perimeters + Points + Moving Question

you talking to me codemonkey200? cause i do know trig..... Confused
Clayton




PostPosted: Mon Mar 31, 2008 7:55 am   Post subject: RE:Circles & Perimeters + Points + Moving Question

A.J. wrote:
anyhow, if x**2 + y**2=radius**2 then your point's on the circle...


Not if the centre of your circle is anywhere but the origin. CodeMonkey2000's equation is correct. The one you have is only iff the center is the origin. the x^2 + y^2 = r^2 is usually taught in grade 10 because students never go beyond using the origin as the center (correct me if I'm wrong though). Using (x-k)^2 + (y-h)^2 = r^2, we can say that the centre of our circle lies at (k, h).
Vermette




PostPosted: Mon Mar 31, 2008 11:25 am   Post subject: Re: Circles & Perimeters + Points + Moving Question

A.J @ March 30th 2008, 20:37 wrote:
its called circumference, not perimeter.....


He was correct in saying perimeter. Circumference is a scalar, perimeter is the abstract definition of the boundary surrounding the area of the circle, which is what he wants to work move along.

As to your question Kharybdis, moving along a perfect circle means you can employ a simple rotation matrix, which can be expressed in the following parametric form:

code:
x' = x*cos(theta) - y*sin(theta)
y' = x*sin(theta) + y*cos(theta)


Theta is the degree of rotation counterclockwise. (x,y) is your original coordinates, and (x',y') is the result of the rotation. When adapting these equations you will have to keep in mind that:
1. The typical coordinate system on a GUI has the coordinate origin (0,0) in the top left, with both axes growing downward and to the right, producing a vertical mirror image of what you'd normally expect to happen on screen.
2. This equation rotates the coordinate system around the origin. If you want to rotate around the center of your circle, you will need to transpose the equation to place the origin at the center of your circle.

edit: I will do the transposition for you, so that you can rotate around the center of your circle (represented by the coordinates (cx,cy)):
code:

x' = ((x1-cx)*cos(theta) - (y1-cy)*sin(theta))+cx
y' = ((x1-cx)*sin(theta) + (y1-cy)*cos(theta))+cy


If you have difficulty understanding why this works I may try to produce a more in-depth explanation later.
A.J




PostPosted: Mon Mar 31, 2008 1:12 pm   Post subject: Re: Circles & Perimeters + Points + Moving Question

my bad guys..........i was in a hurry................
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: