• Status: Solved
• Priority: Medium
• Security: Public
• Views: 333

# Geometry question? corners of a circle.

I bet this is one of those "oh man that was simple" things.. I have a RECT which I use to draw an ellipse (not necessarilly circle). my ellipse gets drag handles on the north/east/south/west edges and I determine those simply with the mid position of the sides of the RECT.

How can I calculate the x/y coordinates of the "corners of the circle" - that is, the NE, SE, SW and NW points along the circumference?   Conceptually, if I could take that same RECT and rotate it 45deg I could then simply take the center points again, and that would give me the corners along the circumference.

but how do I rotate a rect?
0
PMH4514
• 4
• 3
1 Solution

Commented:
Hi PMH4514,
Do you want only the co-ordinates of the points ??
Then it is easy...

Bye
---
Harish
0

Commented:
PMH4514,
OOPS....

or..

0

Author Commented:
the ellipse is not necessarilly a circle, I don't know the radius.

0

Author Commented:
picture a vector drawing program - you draw a circle and it has 4 handles for dragging at North, East, South, West.

Now imagine there were 4 more handles, at Northeast, Southeast, Southwest and Northwest.

as the circle is dragged into an oblong ellipse in any direction, I need to calculate the x/y location at which to draw the northeast, southeast, southwest and northwest handles. The only coordinates I do know are that of the RECT that I passed to CDC::Ellipse() to draw the ellipse.
0

Commented:
x co-ord = width * 0.707
y co-ord = height * 0.707
0

Commented:
Note that the co-ordinates specified are from centre...

___________
|                   |     ^
|                   |      y
|                   |     V
¯¯¯¯¯¯¯¯¯¯¯
<-----  x  ----->

Then

x/2, y/2 will be the centre of the elliplse

x/2 + x/2 * 0.707, y/2 + y/2 * 0.707 will be the NE corner
x/2 - x/2 * 0.707, y/2 + y/2 * 0.707 will be the NW corner
x/2 + x/2 * 0.707, y/2 - y/2 * 0.707 will be the SE corner
x/2 - x/2 * 0.707, y/2 - y/2 * 0.707 will be the SW corner

0

Author Commented:
oooh.. I see what you're doing..  I think that will work just fine.

thanks!
0

## Featured Post

• 4
• 3
Tackle projects and never again get stuck behind a technical roadblock.