// replace real to logical coordinates #include class CoorSys { public: CoorSys ( double xmin=-25, double xmax=25, double ymin=-25, double ymax=25, double zmin=-25, double zmax=25) : _xmin(xmin), _xmax(xmax), _ymin(xmin), _ymax(xmax), _zmin(xmin), _zmax(xmax) { } InitRECT(RECT XY, RECT XZ, RECT YZ) { _XY=XY; _XZ=XZ; _YZ=YZ; } SetPoint(double x, double y, double z) { _x=x; _y=y; _z=z; } SetPoint(int lx, int ly) { POINT p; p.x=lx; p.y=ly; if(PtInRect(&_XY, p)) { _x = _xmin + (_xmax - _xmin)*(lx - _XY.left)/(_XY.right - _XY.left); _y = _ymin + (_ymax - _ymin)*(ly - _XY.bottom)/(_XY.top - _XY.bottom); } if(PtInRect(&_XZ, p)) { _x = _xmin + (_xmax - _xmin)*(lx - _XZ.left)/(_XZ.right - _XZ.left); _z = _zmin + (_zmax - _zmin)*(ly - _XZ.bottom)/(_XZ.top - _XZ.bottom); } if(PtInRect(&_YZ, p)) { _y = _ymin + (_ymax - _ymin)*(lx - _YZ.left)/(_YZ.right - _YZ.left); _z = _zmin + (_zmax - _zmin)*(ly - _YZ.bottom)/(_YZ.top - _YZ.bottom); } } int xInXY() {return _XY.left + (_XY.right - _XY.left)*(_x - _xmin)/(_xmax - _xmin); } int xInXZ() {return _XZ.left + (_XZ.right - _XZ.left)*(_x - _xmin)/(_xmax - _xmin); } int yInXY() {return _XY.bottom + (_XY.top - _XY.bottom)*(_y - _ymin)/(_ymax - _ymin); } int yInYZ() {return _YZ.left + (_YZ.right - _YZ.left)*(_y - _ymin)/(_ymax - _ymin); } int zInXZ() {return _XZ.bottom + (_XZ.top - _XZ.bottom)*(_z - _zmin)/(_zmax - _zmin); } int zInYZ() {return _YZ.bottom + (_YZ.top - _YZ.bottom)*(_z - _zmin)/(_zmax - _zmin); } RECT GetXY() { return _XY; } RECT GetXZ() { return _XZ; } RECT GetYZ() { return _YZ; } double x() { return _x; } double y() { return _y; } double z() { return _z; } double xmin() { return _xmin; } double ymin() { return _ymin; } double zmin() { return _zmin; } double xmax() { return _xmax; } double ymax() { return _ymax; } double zmax() { return _zmax; } private: double _xmin, _xmax, _ymin, _ymax, _zmin, _zmax; double _x, _y, _z; RECT _XY; RECT _XZ; RECT _YZ; };