Geometry question? corners of a circle.

Posted on 2005-05-10
Last Modified: 2010-04-01
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?
Question by:PMH4514
    LVL 37

    Expert Comment

    by:Harisha M G
    Hi PMH4514,
        Do you want only the co-ordinates of the points ??
        Then it is easy...
        sqrt(2) * radius


    LVL 37

    Expert Comment

    by:Harisha M G


        0.707 * radius

    Author Comment

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


    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.
    LVL 37

    Expert Comment

    by:Harisha M G
    x co-ord = width * 0.707
    y co-ord = height * 0.707
    LVL 37

    Accepted Solution

    Note that the co-ordinates specified are from centre...
            |                   |     ^
            |                   |      y
            |                   |     V
            <-----  x  ----->


    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


    Author Comment

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


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    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.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now