我正在编写一个用于解释和绘制G-Code(用于CNC机器)的小程序
为了连接两条半径的线,我写了一个小程序,并且必须使用Vector.Add函数。
No code, had probelems with formatting :)
p1,p2,p3 are the three points
p1->p2 = vector ab
p2->p3 = vector bc
eab = Unit vector ab
ebc = Unit vector bc
eres = resulting vector
我的问题是:对于Vector.Add()
操作,我需要Vector
和Point
(PointF
不允许)但我必须使用PointF
由于准确性。
我该怎么办?
eab = ab / ab.Length;
ebc = bc / bc.Length;
eres = Vector.Add(eab, ebc);
PointF test= new PointF();
test= Vector.Add(5 * eres, test );
我使用System.Windows.Drawing
进行绘制,使用System.Windows.Base
进行向量。
答案 0 :(得分:0)
在System.Drawing.dll,名称空间System.Drawing
中,有:
public struct Point { ... }
public struct PointF { ... }
的坐标分别为int
(System.Int32
)和float
(System.Single
)。
在WindowsBase.dll,名称空间System.Windows
中,有另一个:
public struct Point { ... }
,其坐标为double
(System.Double
)。
如果你需要两者,你可以
using System.Drawing;
和using System.Windows;
放在文件的同一级别,然后在代码中提供全名(例如System.Winodws.Point
而不是Point
每当存在歧义时(即编译器需要时)。或者:using
alias directives (see link)。