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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

刘欣的博客

你将成为第一个打赏博主的人!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值