109 if (
y > rect->
ymax) {
120 if (
x > rect->
xmax) {
126 if (
y > rect->
ymax) {
152 return rect->
xmin -
x;
154 if (
x > rect->
xmax) {
155 return x - rect->
xmax;
163 return rect->
ymin -
y;
165 if (
y > rect->
ymax) {
166 return y - rect->
ymax;
174 return rect->
xmin -
x;
176 if (
x > rect->
xmax) {
177 return x - rect->
xmax;
185 return rect->
ymin -
y;
187 if (
y > rect->
ymax) {
188 return y - rect->
ymax;
208 const double div = double((
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]));
213 const double lambda = double((v1[1] - v3[1]) * (v4[0] - v3[0]) -
214 (v1[0] - v3[0]) * (v4[1] - v3[1])) /
216 const double mu = double((v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) /
218 return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
225 const double div = double((
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]));
230 const double lambda = double((v1[1] - v3[1]) * (v4[0] - v3[0]) -
231 (v1[0] - v3[0]) * (v4[1] - v3[1])) /
233 const double mu = double((v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) /
235 return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
241 if (s1[0] < rect->
xmin && s2[0] < rect->
xmin) {
244 if (s1[0] > rect->
xmax && s2[0] > rect->
xmax) {
247 if (s1[1] < rect->
ymin && s2[1] < rect->
ymin) {
250 if (s1[1] > rect->
ymax && s2[1] > rect->
ymax) {
263 tvec1[0] = rect->
xmin;
264 tvec1[1] = rect->
ymin;
265 tvec2[0] = rect->
xmax;
266 tvec2[1] = rect->
ymax;
272 tvec1[0] = rect->
xmin;
273 tvec1[1] = rect->
ymax;
274 tvec2[0] = rect->
xmax;
275 tvec2[1] = rect->
ymin;
287 if (s1[0] < rect->
xmin && s2[0] < rect->
xmin) {
290 if (s1[0] > rect->
xmax && s2[0] > rect->
xmax) {
293 if (s1[1] < rect->
ymin && s2[1] < rect->
ymin) {
296 if (s1[1] > rect->
ymax && s2[1] > rect->
ymax) {
309 tvec1[0] = rect->
xmin;
310 tvec1[1] = rect->
ymin;
311 tvec2[0] = rect->
xmax;
312 tvec2[1] = rect->
ymax;
318 tvec1[0] = rect->
xmin;
319 tvec1[1] = rect->
ymax;
320 tvec2[0] = rect->
xmax;
321 tvec2[1] = rect->
ymin;
348 return dx * dx + dy * dy <= radius * radius;
369 return dx * dx + dy * dy <= radius * radius;
529 const float xy_src[2])
531 xy_dst[0] = ((xy_src[0] - src->
xmin) / (src->
xmax - src->
xmin));
532 xy_dst[0] = dst->
xmin + ((dst->
xmax - dst->
xmin) * xy_dst[0]);
534 xy_dst[1] = ((xy_src[1] - src->
ymin) / (src->
ymax - src->
ymin));
535 xy_dst[1] = dst->
ymin + ((dst->
ymax - dst->
ymin) * xy_dst[1]);
547 matrix[3][
x] = (src->
xmin - dst->
xmin) * matrix[
x][
x];
548 matrix[3][
y] = (src->
ymin - dst->
ymin) * matrix[
y][
y];
562 matrix[2][0] = (src->
xmin - dst->
xmin) * matrix[0][0];
563 matrix[2][1] = (src->
ymin - dst->
ymin) * matrix[1][1];
583 rect->
xmin *= factor;
584 rect->
ymin *= factor;
585 rect->
xmax *= factor;
586 rect->
ymax *= factor;
590 rect->
xmin *= factor;
591 rect->
ymin *= factor;
592 rect->
xmax *= factor;
593 rect->
ymax *= factor;
671 rect->
xmin = cent_x - size_x_half;
672 rect->
ymin = cent_y - size_y_half;
673 rect->
xmax = cent_x + size_x_half;
674 rect->
ymax = cent_y + size_y_half;
683 rect->
xmin = cent_x - size_x_half;
684 rect->
ymin = cent_y - size_y_half;
685 rect->
xmax = cent_x + size_x_half;
686 rect->
ymax = cent_y + size_y_half;
690 const float boundary_size,
698 float total_pad = pad_max + pad_min;
699 if (total_pad == 0.0f) {
723 float local_pad = local_view_size / (boundary_size - total_pad);
725 rect->
ymax += local_pad * pad_max;
726 rect->
ymin -= local_pad * pad_min;
731 const float ifac = 1.0f - fac;
732 rect->
xmin = (rect_a->
xmin * ifac) + (rect_b->
xmin * fac);
733 rect->
xmax = (rect_a->
xmax * ifac) + (rect_b->
xmax * fac);
734 rect->
ymin = (rect_a->
ymin * ifac) + (rect_b->
ymin * fac);
735 rect->
ymax = (rect_a->
ymax * ifac) + (rect_b->
ymax * fac);
742 bool changed =
false;
764 bool changed =
false;
786 bool changed =
false;
791 if (rect->
xmax > rect_bounds->
xmax) {
792 float ofs = rect_bounds->
xmax - rect->
xmax;
799 if (rect->
xmin < rect_bounds->
xmin) {
800 float ofs = rect_bounds->
xmin - rect->
xmin;
807 if (rect->
ymin < rect_bounds->
ymin) {
808 float ofs = rect_bounds->
ymin - rect->
ymin;
815 if (rect->
ymax > rect_bounds->
ymax) {
816 float ofs = rect_bounds->
ymax - rect->
ymax;
828 bool changed =
false;
833 if (rect->
xmax > rect_bounds->
xmax) {
834 int ofs = rect_bounds->
xmax - rect->
xmax;
841 if (rect->
xmin < rect_bounds->
xmin) {
842 int ofs = rect_bounds->
xmin - rect->
xmin;
849 if (rect->
ymin < rect_bounds->
ymin) {
850 int ofs = rect_bounds->
ymin - rect->
ymin;
857 if (rect->
ymax > rect_bounds->
ymax) {
858 int ofs = rect_bounds->
ymax - rect->
ymax;
908 if (xmax >= xmin && ymax >= ymin) {
937 if (xmax >= xmin && ymax >= ymin) {
958 const float xmin = (src1->
xmin) > (src2->
xmin) ? (src1->
xmin) : (src2->
xmin);
959 const float xmax = (src1->
xmax) < (src2->
xmax) ? (src1->
xmax) : (src2->
xmax);
978 const float ymin = (src1->
ymin) > (src2->
ymin) ? (src1->
ymin) : (src2->
ymin);
979 const float ymax = (src1->
ymax) < (src2->
ymax) ? (src1->
ymax) : (src2->
ymax);
1018 const int ymin = (src1->
ymin) > (src2->
ymin) ? (src1->
ymin) : (src2->
ymin);
1019 const int ymax = (src1->
ymax) < (src2->
ymax) ? (src1->
ymax) : (src2->
ymax);
1070 printf(
"%s: xmin %.8f, xmax %.8f, ymin %.8f, ymax %.8f (%.12fx%.12f)\n",
1082 printf(
"%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n",
1098#define ROTATE_SINCOS(r_vec, mat2, vec) \
1100 (r_vec)[0] = (mat2)[1] * (vec)[0] + (+(mat2)[0]) * (vec)[1]; \
1101 (r_vec)[1] = (mat2)[0] * (vec)[0] + (-(mat2)[1]) * (vec)[1]; \
1109 float corner[2], corner_rot[2], corder_max[2];
1112 corner[0] = src->
xmax - cent[0];
1113 corner[1] = src->
ymax - cent[1];
1115 corder_max[0] =
fabsf(corner_rot[0]);
1116 corder_max[1] =
fabsf(corner_rot[1]);
1120 corder_max[0] = std::max(corder_max[0],
fabsf(corner_rot[0]));
1121 corder_max[1] = std::max(corder_max[1],
fabsf(corner_rot[1]));
1123 dst->
xmin = cent[0] - corder_max[0];
1124 dst->
xmax = cent[0] + corder_max[0];
1125 dst->
ymin = cent[1] - corder_max[1];
1126 dst->
ymax = cent[1] + corder_max[1];
1137 if (p1_inside && p2_inside) {
1141 const std::array<float2, 2> top_line = {
float2{rect->
xmin, rect->
ymax},
1143 const std::array<float2, 2> bottom_line = {
float2{rect->
xmin, rect->
ymin},
1145 const std::array<float2, 2> left_line = {
float2{rect->
xmin, rect->
ymin},
1147 const std::array<float2, 2> right_line = {
float2{rect->
xmax, rect->
ymin},
1149 const std::array<std::array<float2, 2>, 4> lines = {
1150 top_line, bottom_line, left_line, right_line};
1152 if (p1_inside && !p2_inside) {
1153 for (
const std::array<float2, 2> &line : lines) {
1161 if (!p1_inside && p2_inside) {
1162 for (
const std::array<float2, 2> &line : lines) {
1171 for (
const std::array<float2, 2> &line : lines) {
1180 for (
const std::array<float2, 2> &line : lines) {
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
int isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2])
void unit_m3(float m[3][3])
void unit_m4(float m[4][4])
MINLINE void copy_v2_v2(float r[2], const float a[2])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
#define ROTATE_SINCOS(r_vec, mat2, vec)
bool BLI_rcti_compare(const rcti *rect_a, const rcti *rect_b)
void BLI_rctf_init(rctf *rect, float xmin, float xmax, float ymin, float ymax)
bool BLI_rcti_isect_circle(const rcti *rect, const float xy[2], const float radius)
void BLI_rctf_rcti_copy(rctf *dst, const rcti *src)
void BLI_rcti_init(rcti *rect, int xmin, int xmax, int ymin, int ymax)
void BLI_rctf_init_pt_radius(rctf *rect, const float xy[2], float size)
void BLI_rcti_rctf_copy(rcti *dst, const rctf *src)
bool BLI_rctf_isect_x(const rctf *rect, const float x)
bool BLI_rcti_isect_y(const rcti *rect, const int y)
void BLI_rctf_transform_calc_m3_pivot_min(const rctf *dst, const rctf *src, float matrix[3][3])
bool BLI_rctf_isect_y(const rctf *rect, const float y)
bool BLI_rcti_is_empty(const rcti *rect)
bool BLI_rctf_is_valid(const rctf *rect)
bool BLI_rcti_is_valid(const rcti *rect)
void BLI_rctf_resize(rctf *rect, float x, float y)
void BLI_rcti_do_minmax_v(rcti *rect, const int xy[2])
bool BLI_rcti_isect_rect_y(const rcti *src1, const rcti *src2, int range_y[2])
void BLI_rctf_mul(rctf *rect, const float factor)
bool BLI_rctf_is_empty(const rctf *rect)
void print_rctf(const char *str, const rctf *rect)
void BLI_rctf_interp(rctf *rect, const rctf *rect_a, const rctf *rect_b, const float fac)
void BLI_rctf_transform_pt_v(const rctf *dst, const rctf *src, float xy_dst[2], const float xy_src[2])
void BLI_rcti_recenter(rcti *rect, int x, int y)
float BLI_rctf_length_y(const rctf *rect, const float y)
void BLI_rcti_init_minmax(rcti *rect)
void BLI_rcti_init_pt_radius(rcti *rect, const int xy[2], int size)
void BLI_rcti_do_minmax_rcti(rcti *rect, const rcti *other)
bool BLI_rctf_compare(const rctf *rect_a, const rctf *rect_b, const float limit)
void BLI_rcti_mul(rcti *rect, const int factor)
void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, const float angle)
bool BLI_rctf_clamp_pt_v(const rctf *rect, float xy[2])
bool BLI_rctf_isect_rect_x(const rctf *src1, const rctf *src2, float range_x[2])
bool BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
void BLI_rcti_rctf_copy_floor(rcti *dst, const rctf *src)
int BLI_rcti_length_x(const rcti *rect, const int x)
bool BLI_rctf_isect_rect_y(const rctf *src1, const rctf *src2, float range_y[2])
void BLI_rcti_union(rcti *rct_a, const rcti *rct_b)
bool BLI_rcti_clamp(rcti *rect, const rcti *rect_bounds, int r_xy[2])
void BLI_rcti_resize_x(rcti *rect, int x)
void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4])
bool BLI_rctf_clamp_segment(const rctf *rect, float s1[2], float s2[2])
void BLI_rctf_init_minmax(rctf *rect)
int BLI_rcti_length_y(const rcti *rect, const int y)
bool BLI_rcti_isect_x(const rcti *rect, const int x)
void BLI_rctf_transform_calc_m4_pivot_min_ex(const rctf *dst, const rctf *src, float matrix[4][4], uint x, uint y)
void BLI_rctf_union(rctf *rct_a, const rctf *rct_b)
void BLI_rcti_scale(rcti *rect, const float scale)
static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
void BLI_rctf_pad(rctf *rect, float pad_x, float pad_y)
void BLI_rctf_do_minmax_v(rctf *rect, const float xy[2])
bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[2])
bool BLI_rcti_isect_rect_x(const rcti *src1, const rcti *src2, int range_x[2])
void BLI_rctf_pad_y(rctf *rect, const float boundary_size, const float pad_min, const float pad_max)
void BLI_rctf_recenter(rctf *rect, float x, float y)
void BLI_rcti_resize_y(rcti *rect, int y)
void BLI_rctf_translate(rctf *rect, float x, float y)
float BLI_rctf_length_x(const rctf *rect, const float x)
bool BLI_rcti_clamp_pt_v(const rcti *rect, int xy[2])
void BLI_rctf_resize_x(rctf *rect, float x)
bool BLI_rctf_clamp(rctf *rect, const rctf *rect_bounds, float r_xy[2])
bool BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
void BLI_rctf_scale(rctf *rect, const float scale)
void BLI_rctf_sanitize(rctf *rect)
bool BLI_rcti_isect_pt_v(const rcti *rect, const int xy[2])
void BLI_rcti_pad(rcti *rect, int pad_x, int pad_y)
void BLI_rcti_rctf_copy_round(rcti *dst, const rctf *src)
bool BLI_rcti_isect_pt(const rcti *rect, const int x, const int y)
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
void print_rcti(const char *str, const rcti *rect)
void BLI_rctf_resize_y(rctf *rect, float y)
static int isect_segments_fl(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b)
bool BLI_rctf_isect_circle(const rctf *rect, const float xy[2], const float radius)
void BLI_rcti_resize(rcti *rect, int x, int y)
bool BLI_rctf_isect_pt(const rctf *rect, const float x, const float y)
void BLI_rcti_translate(rcti *rect, int x, int y)
bool BLI_rctf_isect_pt_v(const rctf *rect, const float xy[2])
bool BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest)
void BLI_rcti_sanitize(rcti *rect)