Solved

# Geometry question? corners of a circle.

Posted on 2005-05-10
326 Views
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
Question by:PMH4514

LVL 37

Expert Comment

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

Bye
---
Harish
0

LVL 37

Expert Comment

PMH4514,
OOPS....

or..

0

Author Comment

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

0

Author Comment

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

LVL 37

Expert Comment

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

LVL 37

Accepted Solution

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 Comment

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

thanks!
0

## Join & Write a Comment Already a member? Login.

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. â€¦
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilationâ€¦
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

#### 746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

#### Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!