2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
29 /** \file blender/blenlib/intern/rct.c
32 * A minimalist lib for functions doing stuff with rectangle structs.
43 #include "BLI_utildefines.h"
45 #include "DNA_vec_types.h"
47 /* avoid including BLI_math */
48 static void unit_m4(float m[4][4]);
51 * Determine if a rect is empty. An empty
52 * rect is one with a zero (or negative)
55 * \return True if \a rect is empty.
57 bool BLI_rcti_is_empty(const rcti *rect)
59 return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin));
62 bool BLI_rctf_is_empty(const rctf *rect)
64 return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin));
67 bool BLI_rcti_isect_x(const rcti *rect, const int x)
69 if (x < rect->xmin) return false;
70 if (x > rect->xmax) return false;
74 bool BLI_rcti_isect_y(const rcti *rect, const int y)
76 if (y < rect->ymin) return false;
77 if (y > rect->ymax) return false;
81 bool BLI_rcti_isect_pt(const rcti *rect, const int x, const int y)
83 if (x < rect->xmin) return false;
84 if (x > rect->xmax) return false;
85 if (y < rect->ymin) return false;
86 if (y > rect->ymax) return false;
90 bool BLI_rcti_isect_pt_v(const rcti *rect, const int xy[2])
92 if (xy[0] < rect->xmin) return false;
93 if (xy[0] > rect->xmax) return false;
94 if (xy[1] < rect->ymin) return false;
95 if (xy[1] > rect->ymax) return false;
99 bool BLI_rctf_isect_x(const rctf *rect, const float x)
101 if (x < rect->xmin) return false;
102 if (x > rect->xmax) return false;
106 bool BLI_rctf_isect_y(const rctf *rect, const float y)
108 if (y < rect->ymin) return false;
109 if (y > rect->ymax) return false;
113 bool BLI_rctf_isect_pt(const rctf *rect, const float x, const float y)
115 if (x < rect->xmin) return false;
116 if (x > rect->xmax) return false;
117 if (y < rect->ymin) return false;
118 if (y > rect->ymax) return false;
122 bool BLI_rctf_isect_pt_v(const rctf *rect, const float xy[2])
124 if (xy[0] < rect->xmin) return false;
125 if (xy[0] > rect->xmax) return false;
126 if (xy[1] < rect->ymin) return false;
127 if (xy[1] > rect->ymax) return false;
132 * \returns shortest distance from \a rect to x/y (0 if inside)
135 int BLI_rcti_length_x(const rcti *rect, const int x)
137 if (x < rect->xmin) return rect->xmin - x;
138 if (x > rect->xmax) return x - rect->xmax;
142 int BLI_rcti_length_y(const rcti *rect, const int y)
144 if (y < rect->ymin) return rect->ymin - y;
145 if (y > rect->ymax) return y - rect->ymax;
149 float BLI_rctf_length_x(const rctf *rect, const float x)
151 if (x < rect->xmin) return rect->xmin - x;
152 if (x > rect->xmax) return x - rect->xmax;
156 float BLI_rctf_length_y(const rctf *rect, const float y)
158 if (y < rect->ymin) return rect->ymin - y;
159 if (y > rect->ymax) return y - rect->ymax;
164 * is \a rct_b inside \a rct_a
166 bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
168 return ((rct_a->xmin <= rct_b->xmin) &&
169 (rct_a->xmax >= rct_b->xmax) &&
170 (rct_a->ymin <= rct_b->ymin) &&
171 (rct_a->ymax >= rct_b->ymax));
173 bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b)
175 return ((rct_a->xmin <= rct_b->xmin) &&
176 (rct_a->xmax >= rct_b->xmax) &&
177 (rct_a->ymin <= rct_b->ymin) &&
178 (rct_a->ymax >= rct_b->ymax));
182 /* based closely on 'isect_seg_seg_v2_int', but in modified so corner cases are treated as intersections */
183 static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
185 const double div = (double)((v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]));
187 return 1; /* co-linear */
190 const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
191 const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div;
192 return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
195 static int isect_segments_fl(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
197 const double div = (double)((v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]));
199 return 1; /* co-linear */
202 const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
203 const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div;
204 return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
208 bool BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
210 /* first do outside-bounds check for both points of the segment */
211 if (s1[0] < rect->xmin && s2[0] < rect->xmin) return false;
212 if (s1[0] > rect->xmax && s2[0] > rect->xmax) return false;
213 if (s1[1] < rect->ymin && s2[1] < rect->ymin) return false;
214 if (s1[1] > rect->ymax && s2[1] > rect->ymax) return false;
216 /* if either points intersect then we definetly intersect */
217 if (BLI_rcti_isect_pt_v(rect, s1) || BLI_rcti_isect_pt_v(rect, s2)) {
221 /* both points are outside but may insersect the rect */
225 tvec1[0] = rect->xmin; tvec1[1] = rect->ymin;
226 tvec2[0] = rect->xmin; tvec2[1] = rect->ymax;
227 if (isect_segments_i(s1, s2, tvec1, tvec2)) {
232 tvec1[0] = rect->xmin; tvec1[1] = rect->ymax;
233 tvec2[0] = rect->xmax; tvec2[1] = rect->ymin;
234 if (isect_segments_i(s1, s2, tvec1, tvec2)) {
238 /* no intersection */
243 bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[2])
245 /* first do outside-bounds check for both points of the segment */
246 if (s1[0] < rect->xmin && s2[0] < rect->xmin) return false;
247 if (s1[0] > rect->xmax && s2[0] > rect->xmax) return false;
248 if (s1[1] < rect->ymin && s2[1] < rect->ymin) return false;
249 if (s1[1] > rect->ymax && s2[1] > rect->ymax) return false;
251 /* if either points intersect then we definetly intersect */
252 if (BLI_rctf_isect_pt_v(rect, s1) || BLI_rctf_isect_pt_v(rect, s2)) {
256 /* both points are outside but may insersect the rect */
260 tvec1[0] = rect->xmin; tvec1[1] = rect->ymin;
261 tvec2[0] = rect->xmin; tvec2[1] = rect->ymax;
262 if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
267 tvec1[0] = rect->xmin; tvec1[1] = rect->ymax;
268 tvec2[0] = rect->xmax; tvec2[1] = rect->ymin;
269 if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
273 /* no intersection */
278 bool BLI_rcti_isect_circle(const rcti *rect, const float xy[2], const float radius)
282 if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) dx = 0;
283 else dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax);
285 if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) dy = 0;
286 else dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax);
288 return dx * dx + dy * dy <= radius * radius;
291 bool BLI_rctf_isect_circle(const rctf *rect, const float xy[2], const float radius)
295 if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) dx = 0;
296 else dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax);
298 if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) dy = 0;
299 else dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax);
301 return dx * dx + dy * dy <= radius * radius;
304 void BLI_rctf_union(rctf *rct1, const rctf *rct2)
306 if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin;
307 if (rct1->xmax < rct2->xmax) rct1->xmax = rct2->xmax;
308 if (rct1->ymin > rct2->ymin) rct1->ymin = rct2->ymin;
309 if (rct1->ymax < rct2->ymax) rct1->ymax = rct2->ymax;
312 void BLI_rcti_union(rcti *rct1, const rcti *rct2)
314 if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin;
315 if (rct1->xmax < rct2->xmax) rct1->xmax = rct2->xmax;
316 if (rct1->ymin > rct2->ymin) rct1->ymin = rct2->ymin;
317 if (rct1->ymax < rct2->ymax) rct1->ymax = rct2->ymax;
320 void BLI_rctf_init(rctf *rect, float xmin, float xmax, float ymin, float ymax)
340 void BLI_rcti_init(rcti *rect, int xmin, int xmax, int ymin, int ymax)
360 void BLI_rctf_init_pt_radius(rctf *rect, const float xy[2], float size)
362 rect->xmin = xy[0] - size;
363 rect->xmax = xy[0] + size;
364 rect->ymin = xy[1] - size;
365 rect->ymax = xy[1] + size;
368 void BLI_rcti_init_pt_radius(rcti *rect, const int xy[2], int size)
370 rect->xmin = xy[0] - size;
371 rect->xmax = xy[0] + size;
372 rect->ymin = xy[1] - size;
373 rect->ymax = xy[1] + size;
376 void BLI_rcti_init_minmax(rcti *rect)
378 rect->xmin = rect->ymin = INT_MAX;
379 rect->xmax = rect->ymax = INT_MIN;
382 void BLI_rctf_init_minmax(rctf *rect)
384 rect->xmin = rect->ymin = FLT_MAX;
385 rect->xmax = rect->ymax = -FLT_MAX;
388 void BLI_rcti_do_minmax_v(rcti *rect, const int xy[2])
390 if (xy[0] < rect->xmin) rect->xmin = xy[0];
391 if (xy[0] > rect->xmax) rect->xmax = xy[0];
392 if (xy[1] < rect->ymin) rect->ymin = xy[1];
393 if (xy[1] > rect->ymax) rect->ymax = xy[1];
396 void BLI_rctf_do_minmax_v(rctf *rect, const float xy[2])
398 if (xy[0] < rect->xmin) rect->xmin = xy[0];
399 if (xy[0] > rect->xmax) rect->xmax = xy[0];
400 if (xy[1] < rect->ymin) rect->ymin = xy[1];
401 if (xy[1] > rect->ymax) rect->ymax = xy[1];
404 /* given 2 rectangles - transform a point from one to another */
405 void BLI_rctf_transform_pt_v(const rctf *dst, const rctf *src, float xy_dst[2], const float xy_src[2])
407 xy_dst[0] = ((xy_src[0] - src->xmin) / (src->xmax - src->xmin));
408 xy_dst[0] = dst->xmin + ((dst->xmax - dst->xmin) * xy_dst[0]);
410 xy_dst[1] = ((xy_src[1] - src->ymin) / (src->ymax - src->ymin));
411 xy_dst[1] = dst->ymin + ((dst->ymax - dst->ymin) * xy_dst[1]);
415 * Calculate a 4x4 matrix representing the transformation between two rectangles.
417 * \note Multiplying a vector by this matrix does *not* give the same value as #BLI_rctf_transform_pt_v.
419 void BLI_rctf_transform_calc_m4_pivot_min_ex(
420 const rctf *dst, const rctf *src, float matrix[4][4],
423 BLI_assert(x < 3 && y < 3);
427 matrix[x][x] = BLI_rctf_size_x(src) / BLI_rctf_size_x(dst);
428 matrix[y][y] = BLI_rctf_size_y(src) / BLI_rctf_size_y(dst);
429 matrix[3][x] = (src->xmin - dst->xmin) * matrix[x][x];
430 matrix[3][y] = (src->ymin - dst->ymin) * matrix[y][y];
433 void BLI_rctf_transform_calc_m4_pivot_min(
434 const rctf *dst, const rctf *src, float matrix[4][4])
436 BLI_rctf_transform_calc_m4_pivot_min_ex(dst, src, matrix, 0, 1);
439 void BLI_rcti_translate(rcti *rect, int x, int y)
446 void BLI_rctf_translate(rctf *rect, float x, float y)
454 void BLI_rcti_recenter(rcti *rect, int x, int y)
456 const int dx = x - BLI_rcti_cent_x(rect);
457 const int dy = y - BLI_rcti_cent_y(rect);
458 BLI_rcti_translate(rect, dx, dy);
460 void BLI_rctf_recenter(rctf *rect, float x, float y)
462 const float dx = x - BLI_rctf_cent_x(rect);
463 const float dy = y - BLI_rctf_cent_y(rect);
464 BLI_rctf_translate(rect, dx, dy);
467 /* change width & height around the central location */
468 void BLI_rcti_resize(rcti *rect, int x, int y)
470 rect->xmin = BLI_rcti_cent_x(rect) - (x / 2);
471 rect->ymin = BLI_rcti_cent_y(rect) - (y / 2);
472 rect->xmax = rect->xmin + x;
473 rect->ymax = rect->ymin + y;
476 void BLI_rctf_resize(rctf *rect, float x, float y)
478 rect->xmin = BLI_rctf_cent_x(rect) - (x * 0.5f);
479 rect->ymin = BLI_rctf_cent_y(rect) - (y * 0.5f);
480 rect->xmax = rect->xmin + x;
481 rect->ymax = rect->ymin + y;
484 void BLI_rcti_scale(rcti *rect, const float scale)
486 const int cent_x = BLI_rcti_cent_x(rect);
487 const int cent_y = BLI_rcti_cent_y(rect);
488 const int size_x_half = BLI_rcti_size_x(rect) * (scale * 0.5f);
489 const int size_y_half = BLI_rcti_size_y(rect) * (scale * 0.5f);
490 rect->xmin = cent_x - size_x_half;
491 rect->ymin = cent_y - size_y_half;
492 rect->xmax = cent_x + size_x_half;
493 rect->ymax = cent_y + size_y_half;
496 void BLI_rctf_scale(rctf *rect, const float scale)
498 const float cent_x = BLI_rctf_cent_x(rect);
499 const float cent_y = BLI_rctf_cent_y(rect);
500 const float size_x_half = BLI_rctf_size_x(rect) * (scale * 0.5f);
501 const float size_y_half = BLI_rctf_size_y(rect) * (scale * 0.5f);
502 rect->xmin = cent_x - size_x_half;
503 rect->ymin = cent_y - size_y_half;
504 rect->xmax = cent_x + size_x_half;
505 rect->ymax = cent_y + size_y_half;
508 void BLI_rctf_interp(rctf *rect, const rctf *rect_a, const rctf *rect_b, const float fac)
510 const float ifac = 1.0f - fac;
511 rect->xmin = (rect_a->xmin * ifac) + (rect_b->xmin * fac);
512 rect->xmax = (rect_a->xmax * ifac) + (rect_b->xmax * fac);
513 rect->ymin = (rect_a->ymin * ifac) + (rect_b->ymin * fac);
514 rect->ymax = (rect_a->ymax * ifac) + (rect_b->ymax * fac);
517 /* BLI_rcti_interp() not needed yet */
520 bool BLI_rctf_clamp_pt_v(const rctf *rect, float xy[2])
522 bool changed = false;
523 if (xy[0] < rect->xmin) { xy[0] = rect->xmin; changed = true; }
524 if (xy[0] > rect->xmax) { xy[0] = rect->xmax; changed = true; }
525 if (xy[1] < rect->ymin) { xy[1] = rect->ymin; changed = true; }
526 if (xy[1] > rect->ymax) { xy[1] = rect->ymax; changed = true; }
530 bool BLI_rcti_clamp_pt_v(const rcti *rect, int xy[2])
532 bool changed = false;
533 if (xy[0] < rect->xmin) { xy[0] = rect->xmin; changed = true; }
534 if (xy[0] > rect->xmax) { xy[0] = rect->xmax; changed = true; }
535 if (xy[1] < rect->ymin) { xy[1] = rect->ymin; changed = true; }
536 if (xy[1] > rect->ymax) { xy[1] = rect->ymax; changed = true; }
541 * Clamp \a rect within \a rect_bounds, setting \a r_xy to the offset.
543 * \return true if a change is made.
545 bool BLI_rctf_clamp(rctf *rect, const rctf *rect_bounds, float r_xy[2])
547 bool changed = false;
552 if (rect->xmin < rect_bounds->xmin) {
553 float ofs = rect_bounds->xmin - rect->xmin;
560 if (rect->xmax > rect_bounds->xmax) {
561 float ofs = rect_bounds->xmax - rect->xmax;
568 if (rect->ymin < rect_bounds->ymin) {
569 float ofs = rect_bounds->ymin - rect->ymin;
576 if (rect->ymax > rect_bounds->ymax) {
577 float ofs = rect_bounds->ymax - rect->ymax;
587 bool BLI_rcti_clamp(rcti *rect, const rcti *rect_bounds, int r_xy[2])
589 bool changed = false;
594 if (rect->xmin < rect_bounds->xmin) {
595 int ofs = rect_bounds->xmin - rect->xmin;
602 if (rect->xmax > rect_bounds->xmax) {
603 int ofs = rect_bounds->xmax - rect->xmax;
610 if (rect->ymin < rect_bounds->ymin) {
611 int ofs = rect_bounds->ymin - rect->ymin;
618 if (rect->ymax > rect_bounds->ymax) {
619 int ofs = rect_bounds->ymax - rect->ymax;
629 bool BLI_rctf_compare(const rctf *rect_a, const rctf *rect_b, const float limit)
631 if (fabsf(rect_a->xmin - rect_b->xmin) < limit)
632 if (fabsf(rect_a->xmax - rect_b->xmax) < limit)
633 if (fabsf(rect_a->ymin - rect_b->ymin) < limit)
634 if (fabsf(rect_a->ymax - rect_b->ymax) < limit)
640 bool BLI_rcti_compare(const rcti *rect_a, const rcti *rect_b)
642 if (rect_a->xmin == rect_b->xmin)
643 if (rect_a->xmax == rect_b->xmax)
644 if (rect_a->ymin == rect_b->ymin)
645 if (rect_a->ymax == rect_b->ymax)
651 bool BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest)
656 xmin = (src1->xmin) > (src2->xmin) ? (src1->xmin) : (src2->xmin);
657 xmax = (src1->xmax) < (src2->xmax) ? (src1->xmax) : (src2->xmax);
658 ymin = (src1->ymin) > (src2->ymin) ? (src1->ymin) : (src2->ymin);
659 ymax = (src1->ymax) < (src2->ymax) ? (src1->ymax) : (src2->ymax);
661 if (xmax >= xmin && ymax >= ymin) {
681 bool BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
686 xmin = (src1->xmin) > (src2->xmin) ? (src1->xmin) : (src2->xmin);
687 xmax = (src1->xmax) < (src2->xmax) ? (src1->xmax) : (src2->xmax);
688 ymin = (src1->ymin) > (src2->ymin) ? (src1->ymin) : (src2->ymin);
689 ymax = (src1->ymax) < (src2->ymax) ? (src1->ymax) : (src2->ymax);
691 if (xmax >= xmin && ymax >= ymin) {
711 void BLI_rcti_rctf_copy(rcti *dst, const rctf *src)
713 dst->xmin = floorf(src->xmin + 0.5f);
714 dst->xmax = dst->xmin + floorf(BLI_rctf_size_x(src) + 0.5f);
715 dst->ymin = floorf(src->ymin + 0.5f);
716 dst->ymax = dst->ymin + floorf(BLI_rctf_size_y(src) + 0.5f);
719 void BLI_rcti_rctf_copy_floor(rcti *dst, const rctf *src)
721 dst->xmin = floorf(src->xmin);
722 dst->xmax = floorf(src->xmax);
723 dst->ymin = floorf(src->ymin);
724 dst->ymax = floorf(src->ymax);
727 void BLI_rcti_rctf_copy_round(rcti *dst, const rctf *src)
729 dst->xmin = floorf(src->xmin + 0.5f);
730 dst->xmax = floorf(src->xmax + 0.5f);
731 dst->ymin = floorf(src->ymin + 0.5f);
732 dst->ymax = floorf(src->ymax + 0.5f);
735 void BLI_rctf_rcti_copy(rctf *dst, const rcti *src)
737 dst->xmin = src->xmin;
738 dst->xmax = src->xmax;
739 dst->ymin = src->ymin;
740 dst->ymax = src->ymax;
743 void print_rctf(const char *str, const rctf *rect)
745 printf("%s: xmin %.8f, xmax %.8f, ymin %.8f, ymax %.8f (%.12fx%.12f)\n", str,
746 rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_rctf_size_x(rect), BLI_rctf_size_y(rect));
749 void print_rcti(const char *str, const rcti *rect)
751 printf("%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n", str,
752 rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
756 /* -------------------------------------------------------------------- */
757 /* Comprehensive math (float only) */
759 /** \name Rect math functions
762 #define ROTATE_SINCOS(r_vec, mat2, vec) { \
763 (r_vec)[0] = (mat2)[1] * (vec)[0] + (+(mat2)[0]) * (vec)[1]; \
764 (r_vec)[1] = (mat2)[0] * (vec)[0] + (-(mat2)[1]) * (vec)[1]; \
768 * Expand the rectangle to fit a rotated \a src.
770 void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, const float angle)
772 const float mat2[2] = {sinf(angle), cosf(angle)};
773 const float cent[2] = {BLI_rctf_cent_x(src), BLI_rctf_cent_y(src)};
774 float corner[2], corner_rot[2], corder_max[2];
776 /* x is same for both corners */
777 corner[0] = src->xmax - cent[0];
778 corner[1] = src->ymax - cent[1];
779 ROTATE_SINCOS(corner_rot, mat2, corner);
780 corder_max[0] = fabsf(corner_rot[0]);
781 corder_max[1] = fabsf(corner_rot[1]);
784 ROTATE_SINCOS(corner_rot, mat2, corner);
785 corder_max[0] = MAX2(corder_max[0], fabsf(corner_rot[0]));
786 corder_max[1] = MAX2(corder_max[1], fabsf(corner_rot[1]));
788 dst->xmin = cent[0] - corder_max[0];
789 dst->xmax = cent[0] + corder_max[0];
790 dst->ymin = cent[1] - corder_max[1];
791 dst->ymax = cent[1] + corder_max[1];
798 static void unit_m4(float m[4][4])
800 m[0][0] = m[1][1] = m[2][2] = m[3][3] = 1.0f;
801 m[0][1] = m[0][2] = m[0][3] = 0.0f;
802 m[1][0] = m[1][2] = m[1][3] = 0.0f;
803 m[2][0] = m[2][1] = m[2][3] = 0.0f;
804 m[3][0] = m[3][1] = m[3][2] = 0.0f;