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. android java数组应用与说明

    如果定义类或结构数据则需每个都进行创建才可以使用,不然都为null 如: PointF pts[] = new PointF[5] ;//pts[0].x =CSSliderSize / 2;//这样 ...

  2. 当Sublime Text 2 遇到 EOFError: EOF when reading a line

    重新用Sublime Text, command+B运行一小段python程序时遇到 EOFError: EOF when reading a line 似曾相识哪里见过,但是想不起来该如何解决了 S ...

  3. TCP的关闭,到底是几次握手,每次的标志位到底是什么!

    做题的时候遇到一个问题,TCP关闭的时候到底是三次还是四次握手,如果是三次,少了哪部分?   按照 <计算机网络> -第五版-谢希仁       然而对于TCP关闭, 有的地方能找到   ...

  4. [转]nopcommerce商城系统--如何编写一个插件

    本文转自:http://www.cnblogs.com/ganqiyin/p/3680771.html 原址:http://www.nopcommerce.com/docs/77/how-to-wri ...

  5. SpringMVC从入门到精通之第二章

    这一章原本我是想写一个入门程序的,但是后来仔细想了一下,先从下面的图中的组件用代码来介绍,可能更效果会更加好一点.第一节:开发准备介绍之前先说下我的开发调试环境:JDK 1.7的64位 .Eclips ...

  6. MMORPG大型游戏设计与开发(客户端架构 part4 of vegine)

    昨天是七夕,祝大家都过的快乐,希望这句迟到的问候不会造成大家心中的困扰.这一节讲到了前端比较重要的模块,性能以及调试异常模块.一个应用的性能往往是最核心的部分,就像人身体的各个器官一样,一小部分也不能 ...

  7. Scikit-Learn模块学习笔记——数据集模块datasets

    scikit-learn 的 datasets 模块包含测试数据相关函数,主要包括三类: datasets.load_*():获取小规模数据集.数据包含在 datasets 里 datasets.fe ...

  8. 阻塞通信之Socket编程

    Socket通信,主要是基于TCP协议的通信.本文从Socket通信(代码实现).多线程并发.以及TCP协议相关原理方面 介绍 阻塞Socket通信一些知识. 本文从服务器端的视角,以“Echo Se ...

  9. 《MySchool数据库设计优化》内部测试

    1) 在SQL Server 中,为数据库表建立索引能够( C ). A. 防止非法的删除操作 B. 防止非法的插入操作 C. 提高查询性能 D. 节约数据库的磁盘空间 解析:索引的作用是通过使用索引 ...

  10. [No000028]Python的使用之禅及程序员应该明白的一些道理

    最近疯狂的学习ruby和python着两门语言,看到书本上一些比较赞同的段子,摘抄并翻译如下: Python的使用之禅 Beautiful is better than ugly. 美丽好过丑陋Exp ...