zoukankan      html  css  js  c++  java
  • C#绘制传感器代码

    //以下代码添加到任一窗口下即可
            private int 旋转角度 = 0;
            private int 边长 = 10;
            protected override void OnPaint(PaintEventArgs e)
            {
                base.OnPaint(e);
                DrawSensor(e.Graphics, new Point(200, 200), 旋转角度, 边长);
            }
            /// <summary>
            /// 应力传感器代码,其他类型自己修改字符串值
            /// </summary>
            /// <param name="g"></param>
            /// <param name="p">三角形顶点坐标</param>
            /// <param name="sinta">旋转角度(顺时针正,逆时针负)</param>
            /// <param name="a">边长</param>
            private void DrawSensor(Graphics g,Point p,int sinta ,int a)
            {
                //设置线条平滑
                g.SmoothingMode = SmoothingMode.AntiAlias;
                Pen pen=new Pen(Color.Black);
                pen.StartCap=pen.EndCap=LineCap.Round;
                pen.LineJoin = LineJoin.Round;
                //应力传感器符号p
                PointF Pstr=new PointF((float)p.X+((float)a)/2f*(float)Math.Cos(Math.PI*((float)sinta )/180f)-5f,(float)p.Y+((float)a)/2f*(float)Math.Sin(Math.PI*((float)sinta )/180f)-5f);
                g.DrawString("p", new Font("楷体_GB2312", 10), new SolidBrush(Color.FromArgb(0xff, 0xff, 0, 0)),Pstr);
                //方框所在圆半径
                double r = ((double)a) / Math.Sqrt(2);
                //方框中心坐标
                Point Po = new Point(p.X + (int)((a * Math.Sqrt(3) / 2d + a / 2d) * Math.Cos(Math.PI * sinta / 180d)), p.Y + (int)((a * Math.Sqrt(3) / 2d + a / 2d) * Math.Sin(Math.PI * sinta / 180d)));
                //三角形顶点坐标
                Point Ao = p;
                Point Bo = new Point(Po.X + (int)(r * Math.Cos(Math.PI * (225d + sinta) / 180d)), Po.Y + (int)(r * Math.Sin(Math.PI * (225d + sinta) / 180d)));
                Point Co = new Point(Po.X + (int)(r * Math.Cos(Math.PI * (135d + sinta) / 180d)), Po.Y + (int)(r * Math.Sin(Math.PI * (135d + sinta) / 180d)));
                Point Do = new Point(Po.X + (int)(r * Math.Cos(Math.PI * (315d + sinta) / 180d)), Po.Y + (int)(r * Math.Sin(Math.PI * (315d + sinta) / 180d)));
                Point Eo = new Point(Po.X + (int)(r * Math.Cos(Math.PI * (45d + sinta) / 180d)), Po.Y + (int)(r * Math.Sin(Math.PI * (45d + sinta) / 180d)));
                Point[] lp = new Point[] { Ao,Bo,Do,Eo,Co };
                g.DrawPolygon(pen,lp );
                g.DrawLine(pen,Co,Bo);
                g.DrawLine(pen, Co, Do);
            }

    //传感器符号标准请查阅 http://www.myltem.com/use%5CGBT14479-1993.PDF

  • 相关阅读:
    js(5)关于this的指代值
    bootstrap(2)关于表单
    bootstrap(1)关于排版
    bootstrap基础(0)写在前面的一些话
    js(4) 继承
    js(3)面向对象的程序设计
    js(2)关于作用域和作用域链
    鼠标事件(jQuery方法)
    鼠标事件(JS原生方法)
    键盘事件(在输入框中输入内容后按回车键)
  • 原文地址:https://www.cnblogs.com/teyond/p/Sensor.html
Copyright © 2011-2022 走看看