diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2019-08-29 03:33:24 +0300 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2019-08-29 03:33:24 +0300 |
commit | 749567e0b2c264c2c27a85feab611bee976f1527 (patch) | |
tree | 95a4fde76467e12da29c2601fdf7e431b5cb3f22 /source/blender/blenlib/intern/delaunay_2d.c | |
parent | 07b1a5e05c289f37abcfab1b6378b1035c1d4406 (diff) |
Move math and vector double routines into blenlib from delaunay code
Diffstat (limited to 'source/blender/blenlib/intern/delaunay_2d.c')
-rw-r--r-- | source/blender/blenlib/intern/delaunay_2d.c | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/source/blender/blenlib/intern/delaunay_2d.c b/source/blender/blenlib/intern/delaunay_2d.c index 23f560c5463..102ea8eb234 100644 --- a/source/blender/blenlib/intern/delaunay_2d.c +++ b/source/blender/blenlib/intern/delaunay_2d.c @@ -115,99 +115,6 @@ static void validate_face_centroid(SymEdge *se); static void validate_cdt(CDT_state *cdt, bool check_all_tris); #endif -/* TODO: move these to BLI_vector... and BLI_math... */ -static double max_dd(const double a, const double b) -{ - return (a > b) ? a : b; -} - -static double len_v2v2_db(const double a[2], const double b[2]) -{ - return sqrt((b[0] - a[0]) * (b[0] - a[0]) + (b[1] - a[1]) * (b[1] - a[1])); -} - -static double len_squared_v2v2_db(const double a[2], const double b[2]) -{ - return (b[0] - a[0]) * (b[0] - a[0]) + (b[1] - a[1]) * (b[1] - a[1]); -} - -static void add_v2_v2_db(double a[2], const double b[2]) -{ - a[0] += b[0]; - a[1] += b[1]; -} - -static void sub_v2_v2v2_db(double *a, const double *b, const double *c) -{ - a[0] = b[0] - c[0]; - a[1] = b[1] - c[1]; -} - -static double dot_v2v2_db(const double *a, const double *b) -{ - return a[0] * b[0] + a[1] * b[1]; -} - -static double closest_to_line_v2_db(double r_close[2], - const double p[2], - const double l1[2], - const double l2[2]) -{ - double h[2], u[2], lambda, denom; - sub_v2_v2v2_db(u, l2, l1); - sub_v2_v2v2_db(h, p, l1); - denom = dot_v2v2_db(u, u); - if (denom < DBL_EPSILON) { - r_close[0] = l1[0]; - r_close[1] = l1[1]; - return 0.0; - } - lambda = dot_v2v2_db(u, h) / dot_v2v2_db(u, u); - r_close[0] = l1[0] + u[0] * lambda; - r_close[1] = l1[1] + u[1] * lambda; - return lambda; -} - -/** - * If intersection == ISECT_LINE_LINE_CROSS or ISECT_LINE_LINE_NONE: - * <pre> - * pt = v1 + lamba * (v2 - v1) = v3 + mu * (v4 - v3) - * </pre> - */ -static int isect_seg_seg_v2_lambda_mu_db(const double v1[2], - const double v2[2], - const double v3[2], - const double v4[2], - double *r_lambda, - double *r_mu) -{ - double div, lambda, mu; - - div = (v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]); - if (fabs(div) < DBL_EPSILON) { - return ISECT_LINE_LINE_COLINEAR; - } - - lambda = ((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div; - - mu = ((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div; - - if (r_lambda) { - *r_lambda = lambda; - } - if (r_mu) { - *r_mu = mu; - } - - if (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0) { - if (lambda == 0.0 || lambda == 1.0 || mu == 0.0 || mu == 1.0) { - return ISECT_LINE_LINE_EXACT; - } - return ISECT_LINE_LINE_CROSS; - } - return ISECT_LINE_LINE_NONE; -} - /** return 1 if a,b,c forms CCW angle, -1 if a CW angle, 0 if straight */ static int CCW_test(const double a[2], const double b[2], const double c[2]) { |