• 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

  • 相关阅读:
    thinkphp6原生SQL查询
    Uniapp打包的APP后,微信支付只能支付一次,然后就支付不了,报100的错误【解决办法和思路】
    vue区域打印HTML
    Uniapp微信授权登录不了了
    AN渐变填充
    微信全局access_token和网页授权access_token的用法
    VUE打印不居中的问题【解决办法】
    Uniapp微信APP支付解决报错requestPayment:fail:[payment微信:1]General errors
    AN绘制图形并上色
    Mysql批量替换字符串
  • 原文地址:https://www.cnblogs.com/teyond/p/Sensor.html
Copyright © 2020-2023  润新知