⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 position.cs

📁 苏金明编写的《用VB.NET和VC#.NET开发交互式CAD系统》一书的源代码
💻 CS
字号:
using System;

namespace Base
{
	/// <summary>
	/// Position 的摘要说明。
	/// </summary>
	public class Position
	{
		private float m_x;
		private float m_y;
		private int m_ID;

		public float x
		{
			get{return m_x;}
			set{m_x = value;}
		}

		public float y
		{
			get{return m_y;}
			set{m_y = value;}
		}
		public float Disto
		{
			get{return checked((float)(Math.Sqrt(m_x * m_x + m_y * m_y)));}
		}

		public int ID
		{
			get{return m_ID;}
			set{m_ID = value;}
		}

		public float GetAngle()
		{
			//坐标原点为Org,全局变量
			Position org=new Position(0, 0);
			float sita,tanSita,subx;
			float angle=0;
			subx = Math.Abs(m_x - org.x);
			if (org.x == m_x) {subx = 0.0001f;}
			tanSita = (Math.Abs(m_x - org.x)) / subx;
			sita = checked((float)(Math.Atan(tanSita)));
			if (m_x >= org.x && m_y <= org.y)
			{
				angle=sita;
			}
			else if (m_x <= org.x && m_y >= org.y)
			{
				angle=3.1416f - sita;
			}
			else if (m_x <= org.x && m_y >= org.y)
			{
				angle=3.1416f + sita;
			}
			else if (m_x >= org.x && m_y >= org.y)
			{
				angle=2 * 3.1416f - sita;
			}

			return angle;
		}

		public Position(){
		}

		public Position(  float xx,float yy )
		{
			m_x = xx;
			m_y = yy;
		}

		public Position(Position aPos)
		{
			m_x =aPos.x;
			m_y =aPos.y;
		}

		public void Move(float deltaX )
		{
			m_x += deltaX;
		}

		public void Move(float deltaX, float deltaY)
		{
			m_x += deltaX;
			m_y += deltaY;
		}

		public void thisTest()
		{
			Console.WriteLine("坐标为:{0},{1}", this.x, this.y);
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -