This program is used to show how to generate an oval.

The moon's orbit around the sun is an oval two.

锘縰sing System;
using System.Windows.Forms;
using System.Drawing;
using System.Collections.Generic;
class Haha : Form
{
    Haha()
    {
        WindowState = FormWindowState.Maximized;
        Paint += draw;
        Timer t = new Timer();
        t.Tick += delegate
        {
            Invalidate();
        };
        init();
        t.Interval = 200;
        t.Start();
        Activated += delegate
        {
            t.Start();
        };
        SizeChanged += delegate
        {
            if (WindowState == FormWindowState.Minimized) t.Stop();
        };
    }
    const int period=100;
    int now=0;
    Bitmap[] bit=new Bitmap[period];
    void init()
    {
        double the=Math.PI*2/period;
        LinkedList<Point> mark = new LinkedList<Point>();
        var p = new Pen(new SolidBrush(Color.Tomato), 1);
        for (int i = 0; i < bit.Length; i++)
        {
            bit[i] = new Bitmap(200,200);
            var g = Graphics.FromImage(bit[i]);
            int R = Math.Min(bit[i].Width, bit[i].Height) >> 1;
            int x = bit[i].Width >> 1;
            int y = bit[i].Height >> 1;
            g.DrawEllipse(p, x - R, y - R, R << 1, R << 1);
            int RR = R >> 1;
            double xx = x + RR * Math.Cos(the * i);
            double yy = y + RR * Math.Sin(the * i);
            g.DrawEllipse(p, (float)(xx - RR), (float)(yy - RR), RR << 1, RR << 1);
            double r = RR * 0.5;
            double xxx = xx + r * Math.Cos(-the * i);
            double yyy = yy + r * Math.Sin(-the * i);
            mark.AddLast(new Point((int)xxx, (int)yyy));
            g.DrawEllipse(p, (float)(xxx - r), (float)(yyy - r), (float)r * 2, (float)r * 2);
            foreach (var point in mark)
            {
                g.FillEllipse(new SolidBrush(Color.Tomato), point.X, point.Y, 2, 2);
            }
            g.DrawLine(p, (float)xxx, (float)yyy, (float)xx, (float)yy);
            g.DrawLine(p, (float)xx, (float)yy, (float)x, (float)y);
        }
    }
    void draw(object o,PaintEventArgs e)
    {
        now = (now + 1) % period;
        int w = Math.Min(ClientSize.Width, ClientSize.Height);
        e.Graphics.DrawImage(bit[now],0,0,w,w);
    }
    static void Main()
    {
        Application.Run(new Haha());
    }
}

The oval rotates around its own corner.

 using System;
 using System.Windows.Forms;
 using System.Drawing;
 class Haha : Form
 {
     Haha()
     {
         Text = "椭圆焦点极坐标方程:顺时针旋转减去旋转角,逆时针旋转加上旋转角";
         Paint += draw;
         WindowState = FormWindowState.Maximized;
     }
     double a, b, w, h;
     double c, e, k;
     double fx(double the, double phi)
     {
          + e * Math.Cos(the - phi)) * Math.Cos(the);
     }
     double fy(double the, double phi)
     {
          + e * Math.Cos(the - phi)) * Math.Sin(the);
     }
     Point mix, miy, corner;
     double minX(double phi)
     {
         , r = Math.PI /  * ;
         )
         {
             ;
             double lm = l + d;
             double rm = r - d;
             if (fx(lm, phi) > fx(rm, phi)) l = lm;
             else r = rm;
         }
         mix.X = (int)fx(l, phi);
         miy.Y = (int)fy(l, phi);
         return fx(l, phi);
     }
     double minY(double phi)
     {
         ;
         )
         {
             ;
             double lm = l + d;
             double rm = r - d;
             if (fy(lm, phi) > fy(rm, phi)) l = lm;
             else r = rm;
         }
         miy.X = (int)fx(l, phi);
         miy.Y = (int)fy(l, phi);
         return fy(l, phi);
     }
     void draw(object o, PaintEventArgs pe)
     {
         /;
         Text = ;
         pe.Graphics.Clear(Color.Wheat);
         );
          * Math.PI / ;
         a=Math.Min(ClientSize.Width,ClientSize.Height)>>;
         b=0.618*a;
         k=b*b/a;
         c=Math.Sqrt(a*a-b*b);
         e=c/a;
         ;
         ;
         ; i<  * Math.PI; i += the)
         {
             +e*Math.Cos(i-phi))*Math.Cos(i);
              + e * Math.Cos(i-phi)) * Math.Sin(i);
             pe.Graphics.FillEllipse(,);
         }
         pe.Graphics.FillEllipse(,);
         minX(phi);
         minY(phi);
         corner.X=mix.X;
         corner.Y=miy.Y;
         mix.X += centerX;
         mix.Y += centerY;
         miy.X += centerX;
         miy.Y += centerY;
         corner.X += centerX;
         corner.Y += centerY;
         pen.Color = Color.Black;
         pe.Graphics.DrawLine(pen, mix, corner);
         pen.Color = Color.Blue;
         pe.Graphics.DrawLine(pen, miy, corner);
         pe.Graphics.FillEllipse(, );
     }
     static void Main()
     {
         Application.Run(new Haha());
     }
 }

C# Rotating Oval的更多相关文章

  1. Rotating Image Slider - 图片旋转切换特效

    非常炫的图片旋转滑动特效,相信会给你留下深刻印象.滑动图像时,我们会稍稍旋转它们并延缓各元素的滑动.滑块的不寻常的形状是由一些预先放置的元素和使用边框创建.另外支持自动播放选项,鼠标滚轮的功能. 在线 ...

  2. Java对象校验框架之Oval

      只要有接口,就会有参数的校验,目前开源的校验框架已经非常多了,不过不得不提一下Oval.OVal 是一个可扩展的Java对象数据验证框架,验证的规则可以通过配置文件.Annotation.POJO ...

  3. 【POJ 3335】 Rotating Scoreboard (多边形的核- - 半平面交应用)

    Rotating Scoreboard Description This year, ACM/ICPC World finals will be held in a hall in form of a ...

  4. Python Tkinter canvas oval原理

    Ovals, mathematically, are ellipses, including circles as a special case. The ellipse is fit into a ...

  5. poj 3335 Rotating Scoreboard - 半平面交

    /* poj 3335 Rotating Scoreboard - 半平面交 点是顺时针给出的 */ #include <stdio.h> #include<math.h> c ...

  6. Android - shape圆形画法(oval)

    shape圆形画法(oval) 本文地址: http://blog.csdn.net/caroline_wendy 1. 创建一个目录drawable, 用于存放xml类型的图片资源; 2. 在dra ...

  7. poj 3335 Rotating Scoreboard(半平面交)

    Rotating Scoreboard Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6420   Accepted: 25 ...

  8. 山东省ACM多校联盟省赛个人训练第六场 poj 3335 D Rotating Scoreboard

    山东省ACM多校联盟省赛个人训练第六场 D Rotating Scoreboard https://vjudge.net/problem/POJ-3335 时间限制:C/C++ 1秒,其他语言2秒 空 ...

  9. 通过groovy表达式拓展oval——实现根据同一实体中的其他属性值对某个字段进行校验

    在java的参数校验中,开源验证框架OVAL基本能够满足所有需求,如下面通过简单的添加注解,就可实现对参数的非空和长度校验. @NotNull(message="计息周期月数不能为空&quo ...

随机推荐

  1. linux添加开机自启动脚本示例详解

    linux下(以RedHat为范本)添加开机自启动脚本有两种方法,先来简单的; 一.在/etc/rc.local中添加如果不想将脚本粘来粘去,或创建链接什么的,则:step1. 先修改好脚本,使其所有 ...

  2. 浅谈C++设计模式之单例模式

    单例模式:保证一个类仅有一个实例,并提供一个访问它的全局访问点. 通常我们可以让一个全局变量使得一个对象被访问,但它不能防止客户实例化多个对象,一个最好的办法就是让类自身负责保护它的唯一实例,这个类可 ...

  3. 浅谈Java泛型之<? extends T>和<? super T>的区别

    关于Java泛型,这里我不想总结它是什么,这个百度一下一大堆解释,各种java的书籍中也有明确的定义,只要稍微看一下就能很快清楚.从泛型的英文名字Generic type也能看出,Generic普通. ...

  4. web进阶之jQuery操作DOM元素&&MySQL记录操作&&PHP面向对象学习笔记

    hi 保持学习数量和质量 1.jQuery操作DOM元素 ----使用attr()方法控制元素的属性 attr()方法的作用是设置或者返回元素的属性,其中attr(属性名)格式是获取元素属性名的值,a ...

  5. [麦先生]初学Laravel框架与ThinkPHP框架的不同(2)

    在经过了一段时间的开发后,我对Laravel框架的认识又在逐步的加深,对于这个世界占有量NO.1的框架...  我想说,我已经在逐步的感受到他的恐怖之处... 一.建表--Laravel在数据库建表上 ...

  6. POJ 3384 Feng Shui --直线切平面

    题意:房间是一个凸多边形,要在里面铺设两条半径为r的圆形地毯,可以重叠,现在要求分别铺设到哪,使地毯所占的地面面积最大. 解法:要使圆形地毯所占面积最大,圆形地毯一定是与边相切的,这样才能使尽量不重叠 ...

  7. HDU3535AreYouBusy[混合背包 分组背包]

    AreYouBusy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  8. 第14章 位图和位块传输_14.4 GDI位图对象(2)

    14.4.7 在位图上绘图 (1)在内存设备环境中绘图(与真实DC不同的是,内存DC的显示表面是个位图) (2)GetTextExtentPoint32函数:用于确定文本字符串的像素大小.(此大小就是 ...

  9. wireshark过滤语法总结

    抓包采用wireshark,提取特征时,要对session进行过滤,找到关键的stream,这里总结了wireshark过滤的基本语法,供自己以后参考.(脑子记不住东西) wireshark进行过滤时 ...

  10. python日期格式化与绘图

    画一个量随着时间变化的曲线是经常会遇到的需求,比如画软件用户数的变化曲线.画随时间变化的曲线主要用到的函数是matplotlib.pyplot.plot_date(date,num).由于其第一个变量 ...