public class CoordTransform
{
    float x0, y0;
    float m0, n0;
    float dx, dy;
    public CoordTransform()
    {
        x0 = 0;
        y0 = 0;
        m0 = 0;
        n0 = 0;
        dx = 1;
        dy = 1;
    }
    public CoordTransform( float m0, float n0, float m1, float n1, float x0, float y0, float x1, float y1 ) {
        this.x0 = x0;
        this.y0 = y0;
        this.m0 = m0;
        this.n0 = n0;
        dx = ( x1 - x0 ) / ( m1 - m0 );
        dy = ( y1 - y0 ) / ( n1 - n0 );
    }
    
    public float transformx( float x )    {
        return x0 + ( x - m0 ) * dx;
    }
    public float transformy( float y )    {
        return y0 + ( y - n0 ) * dy;
    }
    public float scalex( float x ) {
        return x * dx;
    }
    public float scaley( float y ) { 
        return y * dy;
    }
}
