diff options
Diffstat (limited to 'source/blender/blenlib/intern/math_geom.c')
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 12 |
1 files changed, 12 insertions, 0 deletions
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]) { |