1 /* Copyright (C) 1989, 1995, 1997, 1998 Aladdin Enterprises. All rights reserved. 2 3 This software is provided AS-IS with no warranty, either express or 4 implied. 5 6 This software is distributed under license and may not be copied, 7 modified or distributed except as expressly authorized under the terms 8 of the license contained in the file LICENSE in this distribution. 9 10 For more information about licensing, please refer to 11 http://www.ghostscript.com/licensing/. For information on 12 commercial licensing, go to http://www.artifex.com/licensing/ or 13 contact Artifex Software, Inc., 101 Lucas Valley Road #110, 14 San Rafael, CA 94903, U.S.A., +1(415)492-9861. 15 */ 16 17 /* $Id: gsmatrix.h,v 1.5 2002/06/16 08:45:42 lpd Exp $ */ 18 /* Definition of matrices and client interface to matrix routines */ 19 20 #ifndef gsmatrix_INCLUDED 21 # define gsmatrix_INCLUDED 22 23 /* See p. 65 of the PostScript manual for the semantics of */ 24 /* transformation matrices. */ 25 26 /* Structure for a transformation matrix. */ 27 #define _matrix_body\ 28 float xx, xy, yx, yy, tx, ty 29 struct gs_matrix_s { 30 _matrix_body; 31 }; 32 33 #ifndef gs_matrix_DEFINED 34 # define gs_matrix_DEFINED 35 typedef struct gs_matrix_s gs_matrix; 36 #endif 37 38 /* Macro for initializing constant matrices */ 39 #define constant_matrix_body(xx, xy, yx, yy, tx, ty)\ 40 (float)(xx), (float)(xy), (float)(yx),\ 41 (float)(yy), (float)(tx), (float)(ty) 42 43 /* Macros for testing whether matrix coefficients are zero, */ 44 /* for shortcuts when the matrix is simple. */ 45 #define is_xxyy(pmat) is_fzero2((pmat)->xy, (pmat)->yx) 46 #define is_xyyx(pmat) is_fzero2((pmat)->xx, (pmat)->yy) 47 48 /* The identity matrix (for structure initialization) */ 49 #define identity_matrix_body\ 50 constant_matrix_body(1, 0, 0, 1, 0, 0) 51 52 /* Matrix creation */ 53 void gs_make_identity(gs_matrix *); 54 int gs_make_translation(floatp, floatp, gs_matrix *), 55 gs_make_scaling(floatp, floatp, gs_matrix *), 56 gs_make_rotation(floatp, gs_matrix *); 57 58 /* Matrix arithmetic */ 59 int gs_matrix_multiply(const gs_matrix *, const gs_matrix *, gs_matrix *), 60 gs_matrix_invert(const gs_matrix *, gs_matrix *), 61 gs_matrix_translate(const gs_matrix *, floatp, floatp, gs_matrix *), 62 gs_matrix_scale(const gs_matrix *, floatp, floatp, gs_matrix *), 63 gs_matrix_rotate(const gs_matrix *, floatp, gs_matrix *); 64 65 /* Coordinate transformation */ 66 int gs_point_transform(floatp, floatp, const gs_matrix *, gs_point *), 67 gs_point_transform_inverse(floatp, floatp, const gs_matrix *, gs_point *), 68 gs_distance_transform(floatp, floatp, const gs_matrix *, gs_point *), 69 gs_distance_transform_inverse(floatp, floatp, const gs_matrix *, gs_point *), 70 gs_points_bbox(const gs_point[4], gs_rect *), 71 gs_bbox_transform_only(const gs_rect *, const gs_matrix *, gs_point[4]), 72 gs_bbox_transform(const gs_rect *, const gs_matrix *, gs_rect *), 73 gs_bbox_transform_inverse(const gs_rect *, const gs_matrix *, gs_rect *); 74 75 /* Serialization */ 76 #ifndef stream_DEFINED 77 # define stream_DEFINED 78 typedef struct stream_s stream; 79 #endif 80 int sget_matrix(stream *, gs_matrix *); 81 int sput_matrix(stream *, const gs_matrix *); 82 83 #endif /* gsmatrix_INCLUDED */ 84