5 public struct Point { int x, y; };
6 public struct Pointf { float x, y; };
8 public class MinMaxValue : int
10 const char * OnGetString(char * string, void * fieldData, bool * needClass)
13 sprintf(string, "Inf");
14 else if(this == MININT) //-MAXINT)
15 sprintf(string, "-Inf");
17 sprintf(string, "%d", this);
21 bool OnGetDataFromString(const char * string)
23 if(!strcmpi(string, "Inf"))
25 else if(!strcmpi(string, "-Inf"))
26 this = MININT; //-MAXINT;
28 this = strtol(string, null, 0);
33 public struct Size { MinMaxValue w, h; };
38 int left, top, right, bottom;
40 // Clip "box" against "Against" after adjusting position by (x,y)
41 void ClipOffset(Box against, int x, int y)
46 if(left + x < against.left) left = against.left - x;
47 if(top + y < against.top) top = against.top - y;
48 if(right + x > against.right) right = against.right - x;
49 if(bottom + y > against.bottom) bottom = against.bottom - y;
51 if((left + x > against.right) || // left = against.right - x +1;
52 (top + y > against.bottom)|| // top = against.bottom - y +1;
53 (right + x < against.left) || // right = against.left - x;
54 (bottom + y < against.top)) // bottom = against.top - y;
64 void Clip(Box against)
69 if(left < against.left) left = against.left;
70 if(top < against.top) top = against.top;
71 if(right > against.right) right = against.right;
72 if(bottom > against.bottom) bottom = against.bottom;
74 if((left > against.right) ||
75 (top > against.bottom) ||
76 (right < against.left) ||
77 (bottom < against.top))
89 return left < box.right && right > box.left && top < box.bottom && bottom > box.top;
92 bool IsPointInside(Point point)
94 return point.x >= left && point.y >= top && point.x <= right && point.y <= bottom;
99 set { right = left + value - 1; }
100 get { return right - left + 1; }
105 set { bottom = top + value - 1; }
106 get { return bottom - top + 1; }
110 public class Radians : Angle
112 public property Angle { };
115 public class Degrees : Angle
117 public property Radians
119 //get { return (Angle)this * Pi / 180; }
120 //set { return (Angle)(value * 180 / Pi); }
121 get { return this * (double)Pi / 180; }
122 set { return (double)value * 180 / Pi; }
126 public define Pi = Radians { 3.1415926535897932384626433832795028841971 };
128 public class Distance : double;
129 public class Meters : Distance { public property Distance {} };
130 public class Centimeters : Distance { public property Meters { set { return value * 100.0f; } get { return this / 100.0f; } } };
131 public class Feet : Distance { public property Meters { set { return value / 0.3048f; } get { return this * 0.3048f; } } };
132 public class NauticalMiles : Distance { public property Meters { set { return value / 1852; } get { return this * 1852; } } };
134 public struct WorldPoint
139 public struct PolarPoint
142 NauticalMiles distance;
148 angle = atan2(value.y, value.x);
149 distance = Distance { sqrt((double)(Distance)value.x * (Distance)value.x + (double)(Distance)value.y * (Distance)value.y) };
154 value.x = cos(angle) * distance;
155 value.y = sin(angle) * distance;
160 public struct GeoPoint