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;
        }
    }
}
相关推荐
R-G-B2 小时前
【02】大恒相机SDK C#开发 —— 初始化相机,采集第一帧图像
c#·大恒相机sdk·大恒相机初始化·大恒相机采集图像
韩立学长4 小时前
【开题答辩实录分享】以《制造型企业供应商档案管理系统设计与开发》为例进行答辩实录分享
sqlserver·c#
ajassi20009 小时前
开源 C# 快速开发(十七)进程--消息队列MSMQ
windows·开源·c#
葡萄城技术团队13 小时前
C# SIMD向量索引实战:从理论到高性能实现
c#
c#上位机15 小时前
wpf之TabControl
c#·wpf
玩泥巴的15 小时前
打造.NET平台的Lombok:实现构造函数注入、日志注入、构造者模式代码生成等功能
c#·.net·代码生成·roslyn
张人玉1 天前
C# TCP 客户端开发笔记(TcpClient)
笔记·tcp/ip·c#
张人玉1 天前
C# 通讯关键类的API
开发语言·c#
William_cl1 天前
C# MVC 修复DataTable时间排序以及中英文系统的时间筛选问题
开发语言·c#·mvc