Revision: 48940
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48940
Author: campbellbarton
Date: 2012-07-15 11:35:13 +0000 (Sun, 15 Jul 2012)
Log Message:
-----------
math function to get the intersection point between 2 lines (not 2 segments
which we already have).
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_math_geom.h
trunk/blender/source/blender/blenlib/intern/math_geom.c
Modified: trunk/blender/source/blender/blenlib/BLI_math_geom.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_geom.h 2012-07-15
11:33:13 UTC (rev 48939)
+++ trunk/blender/source/blender/blenlib/BLI_math_geom.h 2012-07-15
11:35:13 UTC (rev 48940)
@@ -87,6 +87,7 @@
#define ISECT_LINE_LINE_EXACT 1
#define ISECT_LINE_LINE_CROSS 2
+int isect_line_line_v2_point(const float v1[2], const float v2[2], const float
v3[2], const float v4[2], float vi[2]);
int isect_line_line_v2(const float a1[2], const float a2[2], const float
b1[2], const float b2[2]);
int isect_line_line_v2_int(const int a1[2], const int a2[2], const int b1[2],
const int b2[2]);
int isect_line_sphere_v3(const float l1[3], const float l2[3], const float
sp[3], const float r, float r_p1[3], float r_p2[3]);
Modified: trunk/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_geom.c 2012-07-15
11:33:13 UTC (rev 48939)
+++ trunk/blender/source/blender/blenlib/intern/math_geom.c 2012-07-15
11:35:13 UTC (rev 48940)
@@ -317,6 +317,21 @@
return ISECT_LINE_LINE_NONE;
}
+/* intersect Line-Line, floats - gives intersection point */
+int isect_line_line_v2_point(const float v1[2], const float v2[2], const float
v3[2], const float v4[2], float vi[2])
+{
+ float div;
+
+ div = (v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] -
v3[0]);
+ if (div == 0.0f) return ISECT_LINE_LINE_COLINEAR;
+
+ vi[0] = ((v3[0] - v4[0]) * (v1[0] * v2[1] - v1[1] * v2[0]) - (v1[0] -
v2[0]) * (v3[0] * v4[1] - v3[1] * v4[0])) / div;
+ vi[1] = ((v3[1] - v4[1]) * (v1[0] * v2[1] - v1[1] * v2[0]) - (v1[1] -
v2[1]) * (v3[0] * v4[1] - v3[1] * v4[0])) / div;
+
+ return ISECT_LINE_LINE_CROSS;
+}
+
+
/* intersect Line-Line, floats */
int isect_line_line_v2(const float v1[2], const float v2[2], const float
v3[2], const float v4[2])
{
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs