CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010
    Posts
    4

    Graphing a Rotated Ellipse

    So i have code to draw an Ellipse, but I need to modify it so i can rotate it about an angle (namely, 45 deg) but can't seem to figure it out. If you can show me how to do this, I would appreciate it.
    Code:
    struct Ellipse : Shape {
        Ellipse(Point p, int w, int h)    // center, min, and max distance from center
            : w(w), h(h)
        { 
            add(Point(p.x-w,p.y-h));
        }
    
        void draw_lines() const;
    
        Point center() const { return Point(point(0).x+w,point(0).y+h); }
        Point focus1() const { return Point(center().x+int(sqrt(double(w*w-h*h))),center().y); }
        Point focus2() const { return Point(center().x-int(sqrt(double(w*w-h*h))),center().y); }
    
        void set_major(int ww) { w=ww; }
        int major() const { return w; }
        void set_minor(int hh) { h=hh; }
        int minor() const { return h; }
    private:
        int w;
        int h;
    };

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Re: Graphing a Rotated Ellipse


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured