public static PointD ToCartesian(RadialPointD location, PointD origin) { PointD p = new PointD(); p.X = location.R * Math.Cos(location.Theta); p.Y = location.R * Math.Sin(location.Theta); return p + origin; }
public static PointD UnitVector(PointD vector) { if (vector.Magnitude() < 0.0001) return PointD.Empty; else return vector / vector.Magnitude(); }
public static System.Drawing.Rectangle PointBounds(PointD point1, PointD point2) { double left = Math.Min(point1.X, point2.X); double top = Math.Min(point1.Y, point2.Y); double right = Math.Max(point1.X, point2.X); double bottom = Math.Max(point1.Y, point2.Y); return new System.Drawing.Rectangle((int)left, (int)top, (int)(right - left), (int)(bottom - top)); }
public static PointD Orthogonal(PointD a) { PointD newPoint = new PointD(); double temp = -a.Y; newPoint.Y = a.X; newPoint.X = temp; return newPoint; }
public static double DotProduct(PointD a, PointD b) { return a.X * b.X + a.Y * b.Y; }
public static RadialPointD ToPolar(PointD location, PointD origin) { PointD v = location - origin; RadialPointD n = new RadialPointD(); n.m_r = v.Magnitude(); n.m_theta = Math.Atan2(v.Y, v.X); return n; }