I made a small mistake because you want to know if the points are in the circle you don't use equals in the if statement you use greater than of course since the point is the corner of the rectangle you could use greater than and equals so it would look like this: If (x-h)**2+(y-k)**2>=r**2: Now I haven't tested it but that is the idea. If it doesn't work let me know I know I can make it work but I might have the formula not in the same form I am sure being that Sina is closer to school than I am he can check it and make sure it's right. That or have his friend the one with the strange name check it. Ken From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Ken Perry Sent: Sunday, February 08, 2009 12:24 PM To: programmingblind@xxxxxxxxxxxxx Subject: RE: Positioning text within a circle Ok now that I understand that you don't want it centered what you have to do is find the formula for a circle then plug the four corner points of the rectangle in the formula. If they all work then your set. Suppose you have circle, with diameter endpoints (a,b) and (c,d). The midpoint of these two endpoints is the center of the circle. Let the center be (h,k). Then the equation of the circle will be (x-h)^2+(y-k)^2=r^2. In order to find r, find the diameter and divide it by 2. Then to plug your values in and test them you would do If (x-h)^2+(y-k)^2=r^2 That of course depends on what language your using you need to do power function for example if you're using python it would be If (x-h)**2+(y-k)**2=r**2: Then you plug the values in and you know if it works There will be four tests one for each corner. Ken From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Ian D. Nichols Sent: Sunday, February 08, 2009 12:28 AM To: programmingblind@xxxxxxxxxxxxx Subject: Re: Positioning text within a circle Hi Ken, Thanks very much for your reply. Unfortunately I didn't make it clear that I do not want to centre the text in the circle. I want to place text anywhere in the circle and make sure that no part of the text accidentally lands outside the circle. What I need to obtain, or calculate for myself, are the coordinates of a sufficient number of points on the dircumference so that I can check to see that the corners of the rectangle containing the text are all within the circle. I have that logic worked out already. What I am lacking are the numbers to compare the coordinates of the text with. I recognize that it is a rather complicated procedure. Windows must know how to do it because the ellipse function with equal x and y axes draws a perfect circle. I've calculated the coordinates of the 4 points where the diagonals intersect the circumference, and I did it using the theorem of Pythagarus, as you did in your reply. But only the diagonals of the circle's bounding square coincide with the hypotenuses of right-angled triangles, so that method is very limited in what it can do. Thanks again. I live in hope! All the best, Ian Ian D. Nichols, Toronto, Canada ----- Original Message ----- From: Ken Perry <mailto:whistler@xxxxxxxxxxxxx> To: programmingblind@xxxxxxxxxxxxx Sent: Saturday, February 07, 2009 9:07 PM Subject: RE: Positioning text within a circle Ok you can use the formula s1^2+s2^2=h^2 to make sure your rectangles cross hypotenuse fits as the diameter of the circle. From there you just need to place the center point of the rectangle in the middle of the circle. So just Using small numbers I will say that your long side is 4, your short side is 3 and your circle is 5 diameter. We can find if the rectangle has the same diameter by doing: 3^2 +4^2 =5^2 Which it does. Most of the circle drawing functions I have used draw the circle from a midpoint so you drawCircle(10+l/2,10+s/2)) When you print the text starting at upper left hand corner of the box 10,10 you should get it in the center So if I am being confusing the thing I am doing is splitting your rectangle into two right triangles. Finding the hypotenuse which will criss cross the rectangle right in the middle. That becomes both the center point of the rectangle and the circle. It also will be the diameter of the circle and the rectangle. So if your hypotenuse fits as the diameter then it fits. Then its just simply finding the center and calculating where to place the first part so the centers of the rectangle and the circle corresponds. If you need help and I am being too confusing just send me your circle drawing function and text writing function and I will try and help you out. Ken From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Ian D. Nichols Sent: Saturday, February 07, 2009 6:57 PM To: program-l@xxxxxxxxxxxxx; programmingblind@xxxxxxxxxxxxx Subject: Positioning text within a circle Hi Listers, I have a circle drawn on the monitor screen. I know its diameter and its centre point in screen pixels. I want to make sure that text I draw on the screen is completely within this circle. I use the TextOut function, which uses a POINT sructure for positioning the text. I can use GetTextExtentPoint32 to calculate the size and location of the enclosing rectangle of the text. I need to make sure that all four of the corners of that rectangle are going to fall within the circle. Can some one please tell me how I can determine the location of the circumference of the circle, so that I can check that my text rectangle will fall completely within it? I'm more than 50 years out of high school, and didn't study mathematics or geometry, or whatever it is that I need, at university. Thanks in advance. Ian Ian D. Nichols, Toronto, Canada