Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiika Hamalainen <blender@miikah.org>2011-05-24 11:08:58 +0400
committerMiika Hamalainen <blender@miikah.org>2011-05-24 11:08:58 +0400
commit3b41ab432badf2d4598b798e0d0c6c9ece51172b (patch)
tree8b646a88ae5dbc8441b0434fc925f7e3f09c7bb5 /source/blender/blenlib/intern/math_geom.c
parent25e276d3570d292f7e0a1306a864419024465d3b (diff)
Applied Dynamic Paint 1.18f patch as a codebase for GSoC.
Diffstat (limited to 'source/blender/blenlib/intern/math_geom.c')
-rw-r--r--source/blender/blenlib/intern/math_geom.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 5979a24c807..fb9d609b116 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -211,6 +211,21 @@ float dist_to_line_segment_v2(const float v1[2], const float v2[2], const float
return sqrtf(rc[0]*rc[0]+ rc[1]*rc[1]);
}
+/* point closest to v1 on line v2-v3 in 2D */
+void closest_to_line_segment_v2(float *closest, float p[2], float l1[2], float l2[2])
+{
+ float lambda, cp[2];
+
+ lambda= closest_to_line_v2(cp,p, l1, l2);
+
+ if(lambda <= 0.0f)
+ copy_v2_v2(closest, l1);
+ else if(lambda >= 1.0f)
+ copy_v2_v2(closest, l2);
+ else
+ copy_v2_v2(closest, cp);
+}
+
/* point closest to v1 on line v2-v3 in 3D */
void closest_to_line_segment_v3(float closest[3], const float v1[3], const float v2[3], const float v3[3])
{