public NormalLocation(double x, double y) { this.x = x; this.y = y; field[0] = new NormalLocation(0, 0, true); // To avoid loops, the field ILocations field[1] = new NormalLocation(1, 1, true); // have an alternate constructor. }
public XYIntLocation(NormalLocation normLoc, XYIntLocation[] field) { if (!SetField(field)) { throw (new Exception("Invalid Field in XYIntLocation")); } else { XYIntLocation[] tempField = (XYIntLocation[])this.Field; int dX = tempField[1].X - tempField[0].X; int dY = tempField[1].Y - tempField[0].Y; double X = dX * normLoc.X; double Y = dY * normLoc.Y; this.x = (int)(X + tempField[0].X); this.y = (int)(Y + tempField[0].Y); } }
// Any non-Normal Location can be constructed using a Normal and a Field. public XYDoubleLocation(NormalLocation normLoc, XYDoubleLocation[] field) { // (Note that this constructor would be much more complex for something like Lat/Long) if (!SetField(field)) // First, set the field and verify it. { throw (new Exception("Invalid Field in XYDoubleLocation")); } else { // Next, measure the size of the field in the X and Y locations XYDoubleLocation[] tempField = (XYDoubleLocation[])this.Field; double dX = tempField[1].X - tempField[0].X; double dY = tempField[1].Y - tempField[0].Y; // Transform the magnitude of the Normal double X = dX * normLoc.X; double Y = dY * normLoc.Y; // Transform the translation of the Normal this.x = X + tempField[0].X; this.y = Y + tempField[0].Y; } }