C# 25Dpoint

C# 25Dpoint ,做一个备份

cs 复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace _25Dpoint
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {            
            Graphics g = this.CreateGraphics(); 
            SolidBrush brushBlack = new SolidBrush(Color.Black);

            g.DrawLine(Pens.Black, 200, 0, 200, 400); //画出直角坐标系的x,y轴
            g.DrawLine(Pens.Black, 0, 200, 400, 200);

            float x1 = 20, y1 = 180;   //假设黑点的坐标为20,180 (这个坐标数字是WIN屏幕的坐标,从直角坐标系到WIN屏幕坐标系是不同的,需要转换一下)

            Point winpoint1 = screen_point(x1, y1); //直角坐标系到WIN屏幕坐标系
            g.DrawString(winpoint1.X.ToString() + "," + winpoint1.Y.ToString(), Font, brushBlack, winpoint1.X, winpoint1.Y); //显示字符串
            g.FillEllipse(brushBlack, winpoint1.X, winpoint1.Y, 5, 5);        //显示点

            float x2 = (float) (x1 * Math.Cos(-45) - y1 * Math.Sin(-45)); //坐标转轴公式 顺时针转45度
            float y2 = (float) (x1 * Math.Sin(-45) + y1 * Math.Cos(-45)); 

            Point winpoint2 = screen_point(x2, y2);
            g.FillEllipse(brushBlack, winpoint2.X, winpoint2.Y, 5, 5); //显示字符串
            g.DrawString(winpoint2.X.ToString() + "," + winpoint2.Y.ToString(), Font, brushBlack, winpoint2.X, winpoint2.Y); //显示转换后的点


        }

        public Point screen_point(float cartX, float cartY)
        {
            Point screenpoint =  new Point();
            screenpoint.X = (int) cartX + ( 400/2  );
            screenpoint.Y = (400/2) - (int)cartY;

            return screenpoint;
        }
    }
}
相关推荐
懒人咖9 小时前
缺料分析时携带用料清单的二开字段
c#·金蝶云星空
bugcome_com10 小时前
深入了解 C# 编程环境及其开发工具
c#
wfserial12 小时前
c#使用微软自带speech选择男声仍然是女声的一种原因
microsoft·c#·speech
阔皮大师13 小时前
INote轻量文本编辑器
java·javascript·python·c#
kylezhao201914 小时前
C# 中的 SOLID 五大设计原则
开发语言·c#
啦啦啦_999915 小时前
Redis-5-doFormatAsync()方法
数据库·redis·c#
Porco.w15 小时前
C#与三菱PLC FX5U通信
网络·c#
E_ICEBLUE17 小时前
PPT 批量转图片:在 Web 预览中实现翻页效果(C#/VB.NET)
c#·powerpoint·svg
JQLvopkk19 小时前
C# 轻量级工业温湿度监控系统(含数据库与源码)
开发语言·数据库·c#
wxin_VXbishe1 天前
C#(asp.net)学员竞赛信息管理系统-计算机毕业设计源码28790
java·vue.js·spring boot·spring·django·c#·php