This week's giveaway is in the Groovy forum. We're giving away four copies of Groovy Fundamentals video training course and have Ken Kousen on-line! See this thread for details.

I have a circle drawn on a panel. now I want to mark points along the circumferance of the circle. I know the angle inscribed by 2 such points at the center which is (width/2,height/2) how do i find the points

Originally posted by Roby Jose: I have a circle drawn on a panel. now I want to mark points along the circumferance of the circle. I know the angle inscribed by 2 such points at the center which is (width/2,height/2) how do i find the points

Roby, not sure that you have two points there, but generay, a circle is the locus of all points a set distance form a center point, or something like that. on a 2D surface, it is all points such that x^2+y^2 = r^2 where r is the radius of your circle (assuming it is centered at (0,0). If it isn't there is another more general forumla you can use... but i won't waste your time with that. You will have to come up with a method of finding the points that you want to color, but generaly, you are going to want their int values to be such that x^2+y^2 is about equal to r^2. Hope this helps.

Hi Roby, From my geometry class I seem to remember that you can use triangles to get points around the circle. If we use a right-angle triangle (90 deg) we can use the following fomula to get at any point: x = r * cos( theta ) y = r * sin( theta ) where r is the circle radius and theta is the angle you want. The theta values start with 0 on the right side and goes counter clockwise (i.e., 90 up vertical, 180 left side, 270 down vertical, etc). Enjoy, Manfred.

Roby Jose
Greenhorn

Joined: May 21, 2001
Posts: 4

posted

0

thanks for the replies. my concern is the transformation from the window coordinates to the geometric cordinates so that i can apply the transformation formula for rotation about a point through an angle. the window coordinates are such that the top left corner has coordinates (0,0) and the bottom right corner has (xmax, ymax) which is not the case in the geometric cordinate system. please advise

Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492

posted

0

Hi Roby, Sorry for the confusion. You just need to flip all your y values for your coordinate system. X Drawing: 0,0 upper Left, xMax,yMax lower right Coor Sys?: 0,0 lower Left xMax,yMax upper right We can see that x direction works as is. For y we need to flip all the values we get: yCoor = DrawArea.height - yDraw That should do the trick ... Hope it helps, Manfred.

Roby Jose
Greenhorn

Joined: May 21, 2001
Posts: 4

posted

0

yes it works. but you were a bit late. anyway, thanks for spending time on it.