//----------------------------------------------------------------------------- // Copyright © 2006 - Philip Howard - All rights reserved // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //----------------------------------------------------------------------------- // package libh/arith // homepage http://libh.slashusr.org/ //----------------------------------------------------------------------------- // author Philip Howard // email libh at ipal dot org // homepage http://phil.ipal.org/ //----------------------------------------------------------------------------- // This file is best viewed using a fixed spaced font such as Courier // and in a display at least 120 columns wide. //----------------------------------------------------------------------------- #include "arith_lib.h" __PROTO_BEGIN__ //----------------------------------------------------------------------------- // function zoom_calc_d // // purpose Given a set of multiply/add values from a zoom scan, and a set // of 2D view coordinates, transform the coordinates into the new // zoomed in view. // // arguments 1 (double *) edge position on X axis on left // 2 (double *) edge position on Y axis on top // 3 (double *) edge position on X axis on right // 4 (double *) edge position on Y axis on bottom // 5 (double) already scanned X axis multiplier // 6 (double) already scanned Y axis multiplier // 7 (double) already scanned X axis adder // 8 (double) already scanned Y axis adder // // returns (int) == -1 : failure // (int) >= 0 : success //----------------------------------------------------------------------------- int zoom_calc_d ( double * arg_xl_p , double * arg_yt_p , double * arg_xr_p , double * arg_yb_p , double arg_mul_x , double arg_mul_y , double arg_add_x , double arg_add_y ) __PROTO_END__ { { double dx,mx,xl,xr; xl = * arg_xl_p; xr = * arg_xr_p; dx = ( xr - xl ) * arg_mul_x / 2.0; mx = ( xr + xl ) / 2.0 + arg_add_x; * arg_xl_p = mx - dx; * arg_xr_p = mx + dx; } { double dy,my,yt,yb; yt = * arg_yt_p; yb = * arg_yb_p; dy = ( yt - yb ) * arg_mul_y / 2.0; my = ( yt + yb ) / 2.0 + arg_add_y; * arg_yt_p = my + dy; * arg_yb_p = my - dy; } return 0; }