I am programming a little program for interpreting and drawing G-Code (used for CNC – machines)
For linking two lines with a radius i wrote a little program and have to use the function 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
My problem is: For the operation Vector.Add() I need a Vector and a Point(PointF is not allowed) but I have to use PointF due to the accuracy.
What shall I do?
eab = ab / ab.Length;
ebc = bc / bc.Length;
eres = Vector.Add(eab, ebc);
PointF test= new PointF();
test= Vector.Add(5 * eres, test );
I use System.Windows.Drawing for drawing and System.Windows.Base for the vectors.
In the System.Drawing.dll, namespace
System.Drawing, there are:whose coordinates are
int(System.Int32) andfloat(System.Single), respectively.In the WindowsBase.dll, namespace
System.Windows, there is another:whose coordinates are
double(System.Double).If you need both, you can
using System.Drawing;andusing System.Windows;at the same level in your file, and then inside the code give the full name (like e.g.System.Winodws.Pointinstead of justPoint) whenever there’s disambiguity (that is whenever the compiler requires that). Or:usingalias directives (see link).