Beispiel #1
0
 /// <summary>
 /// 数乘
 /// </summary>
 /// <param name="p"></param>
 /// <param name="f"></param>
 /// <returns></returns>
 public static _2D_Point operator *(_2D_Point p, double f)
 {
     _2D_Point t = new _2D_Point();
     t.X = p.X * f;
     t.Y = p.Y * f;
     return t;
 }
Beispiel #2
0
 /// <summary>
 /// 坐标变换
 /// </summary>
 /// <param name="p">需要变换的点</param>
 /// <returns>变换后的点</returns>
 public _2D_Point Change(_2D_Point p)
 {
     double x=dx+(1+m)*(p.X*cos(xita)+p.Y*sin(xita)),
            y=dy+(1+m)*(-p.X*sin(xita)+p.Y*cos(xita));
     return new _2D_Point(x, y);
 }
Beispiel #3
0
 /// <summary>
 /// 返回绝对值
 /// </summary>
 /// <returns></returns>
 public _2D_Point Abs()
 {
     _2D_Point t = new _2D_Point();
     t.X = Math.Abs(this.X);
     t.Y = Math.Abs(this.Y);
     return t;
 }
Beispiel #4
0
 /// <summary>
 /// 转换成整数,四舍五入
 /// </summary>
 /// <returns></returns>
 public _2D_Point ChangeToInt()
 {
     _2D_Point t = new _2D_Point();
     t.X = (int)(this.X + 0.5);
     t.Y = (int)(this.Y + 0.5);
     return t;
 }
Beispiel #5
0
 /// <summary>
 /// 输出点数组
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="p"></param>
 public static void Output(string filename, _2D_Point[] p)
 {
     StreamWriter writer = new StreamWriter(filename);
     for (int i = 0; i < p.Length; i++)
         writer.WriteLine(p[i].ToString());
     writer.Close();
 }
Beispiel #6
0
 /// <summary>
 /// 计算一条边的方位角
 /// </summary>
 /// <param name="pre"></param>
 /// <param name="pos"></param>
 /// <returns></returns>
 public static Angle Get_PAngle(_2D_Point pre, _2D_Point pos)
 {
     _2D_Point preDxy;
     preDxy = pos - pre;
     //posDxy = pos - cur;
     double a;
     Angle pAngle;
     a = Math.Atan(preDxy.Y / preDxy.X);
     //b = Math.Atan(posDxy.Y / posDxy.X);
     if (a >= 0)
     {
         if (preDxy.X > 0)
         {
             pAngle = Angle.ChangeToAngle(a);
         }
         else
         {
             pAngle = Angle.ChangeToAngle(a + Math.PI);
         }
     }
     else
         if (preDxy.X >= 0)
         {
             pAngle =Angle.ChangeToAngle(a + Math.PI * 2);
         }
         else
         {
             pAngle = Angle.ChangeToAngle(a + Math.PI);
         }
     return pAngle;
 }
Beispiel #7
0
 /// <summary>
 /// 两点间距离或向量模
 /// </summary>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 /// <returns></returns>
 public static double Get_Norm(_2D_Point p1, _2D_Point p2)
 {
     return Math.Sqrt((p1 - p2).X * (p1 - p2).X + (p1 - p2).Y * (p1 - p2).Y);
 }
Beispiel #8
0
 /// <summary>
 /// 均取相反数
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public static _2D_Point operator -(_2D_Point p)
 {
     _2D_Point t = new _2D_Point();
     t.X = -p.X;
     t.Y = -p.Y;
     return t;
 }
Beispiel #9
0
 /// <summary>
 /// 对应相减
 /// </summary>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 /// <returns></returns>
 public static _2D_Point operator -(_2D_Point p1, _2D_Point p2)
 {
     _2D_Point t = new _2D_Point();
     t.X = p1.X - p2.X;
     t.Y = p1.Y - p2.Y;
     return t;
 }