
lemon juice hurts your eyes
Finding centre coordinates of a circle
Hi!
I'm trying to rotate objects around a certain point, but I don't know how to calculate the position of it..
As the title mentions, it's got something to do with a circle, so instead of trying to explain everything in words, here is a simple representation of the situation:
Things I know:
 width and height of the screen
 position of the top of the circle inside of the screen
Things I might be able to know (needs testing):
 positions of intersection points of the circle with the left and right side of the screen
So how do I get the x and y position of O?
Thanks in advance
Florian Vanthuyne
WAR AGAINST SOLVED THREADS
mark yours as Resolved under Thread Tools!

if you know the interesction points with the circle and the left and right of the screen, you can compute the center from those and the top points: http://local.wasp.uwa.edu.au/~pbourk...y/circlefrom3/
it seems strange that you don't have more information than this though, can you explain what exactly you're working with?

lemon juice hurts your eyes
Thanks for your reply
Let me further explain myself then!
So on the bottom screen I have a part of a circle, that I stretch to fit the width of the screen, thus changing the size of the circle.
Since it's not a complete circle, I can't determine where it's origin lies just by checking, and the radius is also not directly determinable..
I want to be able to rotate the object from outside of the screen onto the circle part (doesn't have to be an exact circular rotation, but the closer the better), to give the illusion that the circle itself is rotating.
Hope this helps
I did find this somewhere:
h = r  d
d = sqrt(4r2c2)/2 = r cos(theta/2) = c cot(theta/2)/2
Would that serve to my purposes?
Florian Vanthuyne
WAR AGAINST SOLVED THREADS
mark yours as Resolved under Thread Tools!

Senior Member
Originally Posted by florianvanthuyn
Since it's not a complete circle, I can't determine where it's origin lies just by checking, and the radius is also not directly determinable..
yes you can, read post #2 again.

The formula for a circle:
(xh)^2+(yk)^2=r^2
(h,k) is the center
r is the radius
You will need to know the distance formula too:
d= sqrt[(x2x1)^2+(y2y1)^2]
p1= (x1,y1)
p2 is (x2,y2)
p1 means "first point"
p2 means "second point"
The distance between two points is the squaroot of the square of the differnce of the x values of the points minus the square of the difference of the y values of the points.
Now I will try to help you with your problem:
You can use:
trace(obj.x)
to see the object's x position and:
trace(obj.y)
to get the objects y position. This should give you a point (x,y) which should be the center of the object.
To get the center of your stage you just take the width and divide by 2 and the same with the height. All you have to do is make your object's x and y position match the stage's center
Last edited by Suthers; 04202010 at 01:50 PM.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
