aspose file tools*
The moose likes Applets and the fly likes how do i find points along the circumferance of a circle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "how do i find points along the circumferance of a circle" Watch "how do i find points along the circumferance of a circle" New topic
Author

how do i find points along the circumferance of a circle

Roby Jose
Greenhorn

Joined: May 21, 2001
Posts: 4
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

Joined: Oct 20, 2000
Posts: 91
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

Joined: Jan 09, 2001
Posts: 1492
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
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
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
yes it works.
but you were a bit late.
anyway, thanks for spending time on it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how do i find points along the circumferance of a circle
 
Similar Threads
Intersecting circles
JLabel Height
Question about packages.
How to access the property of action in case of ModelDriven
Really strange behavior in an ArrayList