欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 家装 > C# 25Dpoint

C# 25Dpoint

2026/4/23 19:33:25 来源:https://blog.csdn.net/ot512csdn/article/details/145137197  浏览:    关键词:C# 25Dpoint

C# 25Dpoint ,做一个备份

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;}}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词