gsmatrix.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* Copyright (C) 1989, 1995, 1997, 1998 Aladdin Enterprises. All rights reserved.
  2. This file is part of AFPL Ghostscript.
  3. AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  4. distributor accepts any responsibility for the consequences of using it, or
  5. for whether it serves any particular purpose or works at all, unless he or
  6. she says so in writing. Refer to the Aladdin Free Public License (the
  7. "License") for full details.
  8. Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. in a plain ASCII text file named PUBLIC. The License grants you the right
  10. to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. conditions described in the License. Among other things, the License
  12. requires that the copyright notice and this notice be preserved on all
  13. copies.
  14. */
  15. /*$Id: gsmatrix.h,v 1.2 2000/09/19 19:00:29 lpd Exp $ */
  16. /* Definition of matrices and client interface to matrix routines */
  17. #ifndef gsmatrix_INCLUDED
  18. # define gsmatrix_INCLUDED
  19. /* See p. 65 of the PostScript manual for the semantics of */
  20. /* transformation matrices. */
  21. /* Structure for a transformation matrix. */
  22. #define _matrix_body\
  23. float xx, xy, yx, yy, tx, ty
  24. struct gs_matrix_s {
  25. _matrix_body;
  26. };
  27. #ifndef gs_matrix_DEFINED
  28. # define gs_matrix_DEFINED
  29. typedef struct gs_matrix_s gs_matrix;
  30. #endif
  31. /* Macro for initializing constant matrices */
  32. #define constant_matrix_body(xx, xy, yx, yy, tx, ty)\
  33. (float)(xx), (float)(xy), (float)(yx),\
  34. (float)(yy), (float)(tx), (float)(ty)
  35. /* Macros for testing whether matrix coefficients are zero, */
  36. /* for shortcuts when the matrix is simple. */
  37. #define is_xxyy(pmat) is_fzero2((pmat)->xy, (pmat)->yx)
  38. #define is_xyyx(pmat) is_fzero2((pmat)->xx, (pmat)->yy)
  39. /* The identity matrix (for structure initialization) */
  40. #define identity_matrix_body\
  41. constant_matrix_body(1, 0, 0, 1, 0, 0)
  42. /* Matrix creation */
  43. void gs_make_identity(P1(gs_matrix *));
  44. int gs_make_translation(P3(floatp, floatp, gs_matrix *)),
  45. gs_make_scaling(P3(floatp, floatp, gs_matrix *)),
  46. gs_make_rotation(P2(floatp, gs_matrix *));
  47. /* Matrix arithmetic */
  48. int gs_matrix_multiply(P3(const gs_matrix *, const gs_matrix *, gs_matrix *)),
  49. gs_matrix_invert(P2(const gs_matrix *, gs_matrix *)),
  50. gs_matrix_translate(P4(const gs_matrix *, floatp, floatp, gs_matrix *)),
  51. gs_matrix_scale(P4(const gs_matrix *, floatp, floatp, gs_matrix *)),
  52. gs_matrix_rotate(P3(const gs_matrix *, floatp, gs_matrix *));
  53. /* Coordinate transformation */
  54. int gs_point_transform(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  55. gs_point_transform_inverse(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  56. gs_distance_transform(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  57. gs_distance_transform_inverse(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  58. gs_points_bbox(P2(const gs_point[4], gs_rect *)), gs_bbox_transform_only(P3(const gs_rect *, const gs_matrix *, gs_point[4])),
  59. gs_bbox_transform(P3(const gs_rect *, const gs_matrix *, gs_rect *)),
  60. gs_bbox_transform_inverse(P3(const gs_rect *, const gs_matrix *, gs_rect *));
  61. /* Serialization */
  62. #ifndef stream_DEFINED
  63. # define stream_DEFINED
  64. typedef struct stream_s stream;
  65. #endif
  66. int sget_matrix(P2(stream *, gs_matrix *));
  67. int sput_matrix(P2(stream *, const gs_matrix *));
  68. #endif /* gsmatrix_INCLUDED */