/* $XConsortium: comptran.pi,v 5.3 94/04/17 20:47:04 hersh Exp $ */ /***************************************************************** Copyright (c) 1989, 1990, 1991,1990 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. Copyright (c) 1989, 1990, 1991,1990 by Sun Microsystems, Inc. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Sun Microsystems, and the X Consortium, not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ ## comptran.pi - ## Test matrix utility functions pcompose_tran_matrix, pcompose_tran_matrix3 ## Test using different ## matrices: non-identity ## reference points: origin,non-origin ## tranlation vectors: some values ## scaling vectors: some values ## rotation angles: some values ## The resulting matrix from the utility is compared to the matrix ## from the same operation performed in the test code. source macro.pi tbegintest("comptran","compose transformation utilities"); # SETUP: open phigs i_open_phigs(NULL,PDEF_MEM_SIZE); # INITIALIZE: matrices I_Pmatrix(mtx1, 0.0,0.1,0.1, 1.0,0.0,0.3, -2.0,0.5,1.0); I_Pmatrix3(mtx31, 0.0,0.1,0.1,-1.0, 1.0,0.0,0.3,0.0, -2.0,0.5,1.0,0.8, 0.0,0.0,1.0,1.0); foreach @rx @ry @rz @tx @ty @tz @sx @sy @sz @xang @yang @zang ( 0.0;0.0;0.0; 0.5; 1.0; 0.3; 0.5; 0.25;0.35; 1.25; 0.0; -1.0; -1.0;1.0;0.5; -1.0;0.5;-0.1; 2.0;2.5;3.0; -0.1; 3.14; 1.0; ) # INITIALIZE: 2D scale and translate vectors xlate = I_Pvec(@tx,@ty); scale = I_Pvec(@sx,@sy); ref = I_Ppoint(@rx,@ry); # OPERATION: pbuild_tran_matrix err = i_bogus_error(); pcompose_tran_matrix(mtx1,&ref,&xlate,@zang,&scale,&err,mtx2); im_ifneq(err,0,"ERROR: %d in pcompose_tran_matrix",err); # VERIFICATION: verify the resulting 2D mtx i_composetran(mtx1,ref,xlate,@zang,scale,mtx3); status = i_compare_Pmatrix(mtx2,mtx3); if (status != 1) tvprintf(1,"reference point (%.2f,%.2f),xlate(%.2f,%.2f)\n", @rx,@ry,@tx,@ty); tvprintf(1,"rotate angle(%.4f),scale(%.2f,%.2f)\n", @zang,@sx,@sy); tfprintf("failed: pcompose_tran_matrix,resulting mtx!=expected\n",NULL); endif # INITIALIZE: 3D scale and translate vectors xlate3 = I_Pvec3(@tx,@ty,@tz); scale3 = I_Pvec3(@sx,@sy,@sz); ref3 = I_Ppoint3(@rx,@ry,@rz); # OPERATION: pbuild_tran_matrix3 err = i_bogus_error(); pcompose_tran_matrix3(mtx31,&ref3,&xlate3,@xang,@yang,@zang,&scale3,&err,mtx32); im_ifneq(err,0,"ERROR: %d in pcompose_tran_matrix",err); # VERIFICATION: verify the resulting 3D mtx i_composetran3(mtx31,ref3,xlate3,@xang,@yang,@zang,scale3,mtx33); status = i_compare_Pmatrix3(mtx32,mtx33); if (status != 1) tvprintf(1,"ref pt(%.2f,%.2f,%.2f),xlate(%.2f,%.2f,%.2f)\n", @rx,@ry,@rz,@tx,@ty,@tz); tvprintf(1,"rotate ang(%.4f,%.4f,%4f),scale(%.2f,%.2f,%.2f)\n", @xang,@yang,@zang,@sx,@sy,@sz); tfprintf("failed: pcompose_tran_matrix3, resulting mtx != expected\n", NULL); endif end tendtest()