From 2ace77ea3f148e6fb2e6d365b7a1eb7a372cd780 Mon Sep 17 00:00:00 2001 From: tomvanmele Date: Thu, 2 Oct 2025 15:56:24 +0200 Subject: [PATCH 1/2] fix bug in planar surface --- CHANGELOG.md | 1 + src/compas/geometry/surfaces/planar.py | 3 +- tasks.py | 3 +- tests/compas/geometry/test_surfaces_plane.py | 60 ++++++++++++++++++++ 4 files changed, 63 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9e5db937c41..a6d67a1331f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Updated minimum library version to `2.14.1` in Rhino8 GH components. * Changed name of YAK package from `bluejay` to `compas`. +* Fixed bug in `compas.geometry.PlanarSurface`. ### Removed diff --git a/src/compas/geometry/surfaces/planar.py b/src/compas/geometry/surfaces/planar.py index 6e9e25f2fcad..4b6797444f0b 100644 --- a/src/compas/geometry/surfaces/planar.py +++ b/src/compas/geometry/surfaces/planar.py @@ -167,11 +167,10 @@ def point_at(self, u, v, world=True): A point on the sphere. """ - point = Point(u, v, 0) + point = Point(u * self.xsize, v * self.ysize, 0) if world: point.transform(self.transformation) return point - # return self.frame.point + self.frame.xaxis * u + self.frame.yaxis * v def normal_at(self, u=None, v=None, world=True): """Construct the normal at a point on the planar surface. diff --git a/tasks.py b/tasks.py index 5a9835ef6274..548230ace870 100644 --- a/tasks.py +++ b/tasks.py @@ -7,7 +7,7 @@ from compas_invocations2 import style from compas_invocations2 import tests from compas_invocations2 import grasshopper -from invoke import Collection +from invoke.collection import Collection ns = Collection( docs.help, @@ -26,7 +26,6 @@ build.build_cpython_ghuser_components, grasshopper.yakerize, grasshopper.publish_yak, - grasshopper.update_gh_header, ) ns.configure( { diff --git a/tests/compas/geometry/test_surfaces_plane.py b/tests/compas/geometry/test_surfaces_plane.py index d219bec4288e..1c852dd1d3c4 100644 --- a/tests/compas/geometry/test_surfaces_plane.py +++ b/tests/compas/geometry/test_surfaces_plane.py @@ -39,6 +39,32 @@ def test_plane(xsize, ysize): assert plane.frame == other.frame +@pytest.mark.parametrize( + "xsize,ysize", + [ + (0, 0), + (1, 0), + (0, 1), + (1, 1), + (10, 1), + (1, 10), + (2, 3), + (3, 2), + (random(), random()), + ], +) +def test_plane_size(xsize, ysize): + plane = PlanarSurface(xsize=xsize, ysize=ysize) + + assert plane.point_at(1, 0) == Point(xsize, 0, 0) + assert plane.point_at(0, 1) == Point(0, ysize, 0) + assert plane.point_at(1, 1) == Point(xsize, ysize, 0) + + assert plane.point_at(0.5, 0) == Point(0.5 * xsize, 0, 0) + assert plane.point_at(0, 0.5) == Point(0, 0.5 * ysize, 0) + assert plane.point_at(0.5, 0.5) == Point(0.5 * xsize, 0.5 * ysize, 0) + + @pytest.mark.parametrize( "frame", [ @@ -107,3 +133,37 @@ def test_plane_data(): # ============================================================================= # Other Methods # ============================================================================= + +# ============================================================================= +# Conversions +# ============================================================================= + + +@pytest.mark.parametrize( + "xsize,ysize", + [ + (0, 0), + (1, 0), + (0, 1), + (1, 1), + (10, 1), + (1, 10), + (2, 3), + (3, 2), + (random(), random()), + ], +) +def test_plane_conversion_to_mesh(xsize, ysize): + plane = PlanarSurface(xsize=xsize, ysize=ysize) + + area = plane.xsize * plane.ysize + + mesh = plane.to_mesh(1, 1) + assert mesh.number_of_vertices() == 4 + assert mesh.number_of_faces() == 1 + assert TOL.is_close(mesh.area(), area) + + mesh = plane.to_mesh(10, 10) + assert mesh.number_of_vertices() == 121 + assert mesh.number_of_faces() == 100 + assert TOL.is_close(mesh.area(), area) From 8e3d0440283a97ea69fbb6cac72137e49e90d22d Mon Sep 17 00:00:00 2001 From: tomvanmele Date: Sun, 19 Oct 2025 22:10:27 +0200 Subject: [PATCH 2/2] add deleted task --- tasks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks.py b/tasks.py index 548230ace870..7286febdb086 100644 --- a/tasks.py +++ b/tasks.py @@ -26,6 +26,7 @@ build.build_cpython_ghuser_components, grasshopper.yakerize, grasshopper.publish_yak, + grasshopper.update_gh_header, ) ns.configure( {