import java.io.*; import java.util.*; import java.awt.geom.*; /** * Solution to Overlapping Maps. * * @author vanb */ public class overlappingmaps_vanb { public Scanner sc; public PrintStream ps; public static final double epsilon = 0.000001; /** * Driver. * @throws Exception */ public void doit() throws Exception { sc = new Scanner (System.in); ps = System.out; for(;;) { int w = sc.nextInt(); int h = sc.nextInt(); int x = sc.nextInt(); int y = sc.nextInt(); int s = sc.nextInt(); int r = sc.nextInt(); if( w==0 ) break; double xoffset = (double)x; double yoffset = (double)y; double scale = (double)s/100.0; double degrees = (double)r; double theta = Math.toRadians( degrees ); // The solution is based on this insight: // // Let [x0,y0] (a position on the big map, 0<=x0<=w, 0<=y0<=h) be an arbitrary guess. // Figure out where that spot is on the small map, and then figure out where that is on the big map. // Call that point [x1,y1]. Suppose we use that as our next guess, do the same thing, and get [x2,y2]. // Then the vector [x0,y0]-[x1,y1] on the big map is the same as [x1,y1]-[x2,y2] on the small map. // Since the small map is guaranteed to be smaller than the big map, that means that the distance // from [x1,y1] to [x2,y2] MUST be smaller than the distance from [x0,y0] to [x1,y1]. // If we keep going, then [x2,y2]-[x3,y3] must be smaller than [x1,y1]-[x2,y2], // [x3,y3]-[x4,y4] must be smaller than [x2,y2]-[x3,y3]. In other words, the distance between // guesses MUST go down, and eventually, converge! // Start out with an initial guess right in the middle of the big map. double newx = w/2.0; double newy = h/2.0; double oldx, oldy; do { oldx = newx; oldy = newy; // This is the distance from the lower left corner to the point, // projected on the smaller map. double rho = scale * Math.hypot( oldx, oldy ); // This is the angle of that vector, on the big map double angle = Math.atan2( oldy, oldx ) + theta; // And, here's the new guess! newx = xoffset + rho * Math.cos( angle ); newy = yoffset + rho * Math.sin( angle ); } // Keep going until convergence! while( Math.abs(oldx-newx)>epsilon || Math.abs(oldy-newy)>epsilon ); // Judges' stuff, to make sure roundoff error isn't a problem. String xstr = String.format( "%.4f", newx ); String ystr = String.format( "%.4f", newx ); boolean good = true; if( xstr.endsWith( "50" ) ) good = false; if( xstr.endsWith( "49" ) ) good = false; if( ystr.endsWith( "50" ) ) good = false; if( ystr.endsWith( "49" ) ) good = false; if( !good ) { System.err.println( w + " " + h + " " + x + " " + y + " " + s + " " + r ); } // Print the answer! ps.printf( "%.2f %.2f", newx, newy ); ps.println(); } } /** * @param args */ public static void main( String[] args ) throws Exception { new overlappingmaps_vanb().doit(); // Random random = new Random(); // double epsilon = 0.01; // for( int i=0; i<100; i++ ) // { // int w, h, x, y, s, a; // for(;;) // { // w = random.nextInt( 901 ) + 100; // h = random.nextInt( 901 ) + 100; // x = random.nextInt( w ); // y = random.nextInt( h ); // s = random.nextInt( 99 ) + 1; // a = random.nextInt( 360 ); // // double angle = Math.toRadians( (double)a ); // double perp = Math.toRadians( (double)(a+90) ); // double scale = (double)s/100.0; // // double swx = (double)x; // double swy = (double)y; // double sex = swx + w*scale*Math.cos( angle ); // double sey = swx + w*scale*Math.sin( angle ); // double nwx = swx + h*scale*Math.cos( perp ); // double nwy = swx + h*scale*Math.sin( perp ); // double nex = nwx + w*scale*Math.cos( angle ); // double ney = nwx + w*scale*Math.sin( angle ); // // if( swx<=epsilon || swx>=(double)w-epsilon ) continue; // if( swy<=epsilon || swy>=(double)h-epsilon ) continue; // if( sex<=epsilon || sex>=(double)w-epsilon ) continue; // if( sey<=epsilon || sey>=(double)h-epsilon ) continue; // if( nwx<=epsilon || nwx>=(double)w-epsilon ) continue; // if( nwy<=epsilon || nwy>=(double)h-epsilon ) continue; // if( nex<=epsilon || nex>=(double)w-epsilon ) continue; // if( ney<=epsilon || ney>=(double)h-epsilon ) continue; // break; // } // // System.out.printf( "%d %d %d %d %d %d", w, h, x, y, s, a ); // System.out.println(); // } } }