From 4ce149568c21f27396298de7aa63fd6ba72a2bc7 Mon Sep 17 00:00:00 2001 From: lee <205592689+jkhahe72-sh3@users.noreply.github.com> Date: Mon, 9 Mar 2026 19:56:51 +0100 Subject: [PATCH 1/2] Fix parameter naming and formatting --- geometry/point_to_plane_distance.py | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 geometry/point_to_plane_distance.py diff --git a/geometry/point_to_plane_distance.py b/geometry/point_to_plane_distance.py new file mode 100644 index 000000000000..6969803033d6 --- /dev/null +++ b/geometry/point_to_plane_distance.py @@ -0,0 +1,37 @@ +from math import sqrt + + +def point_to_plane_distance( + point_x: float, + point_y: float, + point_z: float, + normal_x: float, + normal_y: float, + normal_z: float, + plane_constant: float +) -> float: + """ + Return the distance between a point (x, y, z) and the plane + ax + by + cz + d = 0 using the Hesse normal form. + + Reference: + https://en.wikipedia.org/wiki/Hesse_normal_form + + >>> point_to_plane_distance(1, 2, 3, 1, 0, 0, -1) + 0.0 + >>> point_to_plane_distance(3, 2, 1, 1, 0, 0, -1) + 2.0 + >>> point_to_plane_distance(1, 2, 3, 0, 0, 0, 4) + Traceback (most recent call last): + ... + ValueError: Normal vector cannot be zero. + """ + if normal_x == 0 and normal_y == 0 and normal_z == 0: + raise ValueError("Normal vector cannot be zero.") + + return abs( + normal_x * point_x + + normal_y * point_y + + normal_z * point_z + + plane_constant + ) / sqrt(normal_x**2 + normal_y**2 + normal_z**2) From dfbde05ae16e0973c9350fb83a0a92c0e1d88ed4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Mar 2026 19:09:09 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- geometry/point_to_plane_distance.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/geometry/point_to_plane_distance.py b/geometry/point_to_plane_distance.py index 6969803033d6..a2dbe8120dbf 100644 --- a/geometry/point_to_plane_distance.py +++ b/geometry/point_to_plane_distance.py @@ -8,7 +8,7 @@ def point_to_plane_distance( normal_x: float, normal_y: float, normal_z: float, - plane_constant: float + plane_constant: float, ) -> float: """ Return the distance between a point (x, y, z) and the plane @@ -30,8 +30,5 @@ def point_to_plane_distance( raise ValueError("Normal vector cannot be zero.") return abs( - normal_x * point_x - + normal_y * point_y - + normal_z * point_z - + plane_constant + normal_x * point_x + normal_y * point_y + normal_z * point_z + plane_constant ) / sqrt(normal_x**2 + normal_y**2 + normal_z**2)