?? position.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 + -