예제 #1
0
 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;
 }
예제 #2
0
 public static PointD UnitVector(PointD vector)
 {
     if (vector.Magnitude() < 0.0001)
         return PointD.Empty;
     else
         return vector / vector.Magnitude();
 }
예제 #3
0
 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));
 }
예제 #4
0
 public static PointD Orthogonal(PointD a)
 {
     PointD newPoint = new PointD();
     double temp = -a.Y;
     newPoint.Y = a.X;
     newPoint.X = temp;
     return newPoint;
 }
예제 #5
0
 public static double DotProduct(PointD a, PointD b)
 {
     return a.X * b.X + a.Y * b.Y;
 }
예제 #6
0
 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;
 }