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;
        }
    }
}
相关推荐
神罚天下ET9 小时前
c# ACME client (补充)
开发语言·c#
噗噗夹的TA之旅14 小时前
Shader 学习 21:自定义 Render Feature
学习·游戏·unity·c#·游戏引擎·图形渲染
脚踏实地皮皮晨15 小时前
003006001_WrapPanel控件
开发语言·c#·.net·wpf·visual studio
脚踏实地皮皮晨16 小时前
003005002_WPF StackPanel 基类官方类定义逐行深度解析
开发语言·windows·算法·c#·wpf·visual studio
用户2986985301416 小时前
Excel 转 PDF 免费在线工具,格式完美保留
人工智能·c#·excel
库拉库拉里17 小时前
深入理解 C# 异步编程:同步、Task.Wait () 与 await 的本质区别及实践指南
开发语言·c#
神罚天下ET18 小时前
.NET 新增功能系列文章——C# 中的新增功能
开发语言·c#·.net
caishenzhibiao20 小时前
缠论画线主图 同花顺期货通指标
java·c语言·c#
C囧囧21 小时前
利用SharpShell为属性添加标签页
c#·winform·扩展属性·sharpshell
Alex Gram21 小时前
双机热备软件哪个好
java·系统架构·c#·keepalived·高可用·双机热备·双机热备软件