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:
authorCampbell Barton <ideasman42@gmail.com>2011-11-12 14:06:56 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-12 14:06:56 +0400
commit817b6cb9a8990483a2bfce7a11e690c829e75ddc (patch)
tree0ae158c6e2b6302851e19dd269d7b749d7af38c0 /source/blender/blenlib
parente2c06d5fc91f4f1125cf79280cb585400f6e056c (diff)
mathutils.geometry.distance_point_to_plane(pt, plane_co, plane_no) - utility function, BLI math version too.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_geom.h1
-rw-r--r--source/blender/blenlib/intern/math_geom.c12
2 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 8a42414ea9f..99687ae8bb4 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -60,6 +60,7 @@ float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2]);
float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2]);
void closest_to_line_segment_v2(float closest[2], const float p[2], const float l1[2], const float l2[2]);
+float dist_to_plane_v3(const float p[2], const float plane_co[3], const float plane_no[2]);
float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]);
float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]);
float closest_to_line_v2(float r[2], const float p[2], const float l1[2], const float l2[2]);
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 99ead8e9d6a..a135cb43882 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -237,6 +237,18 @@ void closest_to_line_segment_v3(float closest[3], const float v1[3], const float
copy_v3_v3(closest, cp);
}
+/* signed distance from the point to the plane in 3D */
+float dist_to_plane_v3(const float p[2], const float plane_co[3], const float plane_no[2])
+{
+ float plane_no_unit[3];
+ float plane_co_other[3];
+
+ normalize_v3_v3(plane_no_unit, plane_no);
+ add_v3_v3v3(plane_co_other, plane_co, plane_no_unit);
+
+ return -line_point_factor_v3(p, plane_co, plane_co_other);
+}
+
/* distance v1 to line-piece v2-v3 in 3D */
float dist_to_line_segment_v3(const float v1[3], const float v2[3], const float v3[3])
{