Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how do i find points along the circumferance of a circle

 
Roby Jose
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Bailey
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes it works.
but you were a bit late.
anyway, thanks for spending time on it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic