COMPAS 2.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- compas/__init__.py +274 -0
- compas/__main__.py +31 -0
- compas/_iotools.py +80 -0
- compas/_os.py +746 -0
- compas/colors/__init__.py +14 -0
- compas/colors/cmcrameri/acton.txt +256 -0
- compas/colors/cmcrameri/actonS.txt +100 -0
- compas/colors/cmcrameri/bam.txt +256 -0
- compas/colors/cmcrameri/bamO.txt +256 -0
- compas/colors/cmcrameri/bamako.txt +256 -0
- compas/colors/cmcrameri/bamakoS.txt +100 -0
- compas/colors/cmcrameri/batlow.txt +256 -0
- compas/colors/cmcrameri/batlowK.txt +256 -0
- compas/colors/cmcrameri/batlowS.txt +100 -0
- compas/colors/cmcrameri/batlowW.txt +256 -0
- compas/colors/cmcrameri/berlin.txt +256 -0
- compas/colors/cmcrameri/bilbao.txt +256 -0
- compas/colors/cmcrameri/bilbaoS.txt +100 -0
- compas/colors/cmcrameri/broc.txt +256 -0
- compas/colors/cmcrameri/brocO.txt +256 -0
- compas/colors/cmcrameri/buda.txt +256 -0
- compas/colors/cmcrameri/budaS.txt +100 -0
- compas/colors/cmcrameri/bukavu.txt +256 -0
- compas/colors/cmcrameri/cork.txt +256 -0
- compas/colors/cmcrameri/corkO.txt +256 -0
- compas/colors/cmcrameri/davos.txt +256 -0
- compas/colors/cmcrameri/davosS.txt +100 -0
- compas/colors/cmcrameri/devon.txt +256 -0
- compas/colors/cmcrameri/devonS.txt +100 -0
- compas/colors/cmcrameri/fes.txt +256 -0
- compas/colors/cmcrameri/grayC.txt +256 -0
- compas/colors/cmcrameri/grayCS.txt +100 -0
- compas/colors/cmcrameri/hawaii.txt +256 -0
- compas/colors/cmcrameri/hawaiiS.txt +100 -0
- compas/colors/cmcrameri/imola.txt +256 -0
- compas/colors/cmcrameri/imolaS.txt +100 -0
- compas/colors/cmcrameri/lajolla.txt +256 -0
- compas/colors/cmcrameri/lajollaS.txt +100 -0
- compas/colors/cmcrameri/lapaz.txt +256 -0
- compas/colors/cmcrameri/lapazS.txt +100 -0
- compas/colors/cmcrameri/lisbon.txt +256 -0
- compas/colors/cmcrameri/nuuk.txt +256 -0
- compas/colors/cmcrameri/nuukS.txt +100 -0
- compas/colors/cmcrameri/oleron.txt +256 -0
- compas/colors/cmcrameri/oslo.txt +256 -0
- compas/colors/cmcrameri/osloS.txt +100 -0
- compas/colors/cmcrameri/roma.txt +256 -0
- compas/colors/cmcrameri/romaO.txt +256 -0
- compas/colors/cmcrameri/tofino.txt +256 -0
- compas/colors/cmcrameri/tokyo.txt +256 -0
- compas/colors/cmcrameri/tokyoS.txt +100 -0
- compas/colors/cmcrameri/turku.txt +256 -0
- compas/colors/cmcrameri/turkuS.txt +100 -0
- compas/colors/cmcrameri/vanimo.txt +256 -0
- compas/colors/cmcrameri/vik.txt +256 -0
- compas/colors/cmcrameri/vikO.txt +256 -0
- compas/colors/color.py +1118 -0
- compas/colors/colordict.py +103 -0
- compas/colors/colormap.py +306 -0
- compas/colors/html_colors.py +149 -0
- compas/colors/mpl_colormap.py +1064 -0
- compas/data/__init__.py +31 -0
- compas/data/coercion.py +71 -0
- compas/data/conftest.py +10 -0
- compas/data/data.py +342 -0
- compas/data/encoders.py +240 -0
- compas/data/exceptions.py +2 -0
- compas/data/json.py +240 -0
- compas/data/samples/boxes.obj +250 -0
- compas/data/samples/butt_model.obj +2829 -0
- compas/data/samples/cone.stl +0 -0
- compas/data/samples/cube.off +16 -0
- compas/data/samples/cube_ascii.stl +56114 -0
- compas/data/samples/cube_binary.stl +0 -0
- compas/data/samples/cube_binary_2.stl +0 -0
- compas/data/samples/doosabin.json +1 -0
- compas/data/samples/faces.obj +63 -0
- compas/data/samples/faces_big.obj +9663 -0
- compas/data/samples/faces_reversed.obj +63 -0
- compas/data/samples/fink.obj +135 -0
- compas/data/samples/grid_irregular.obj +303 -0
- compas/data/samples/hypar.obj +148 -0
- compas/data/samples/lines.json +1 -0
- compas/data/samples/lines.obj +282 -0
- compas/data/samples/lines_big.obj +40322 -0
- compas/data/samples/lines_bigger.obj +161282 -0
- compas/data/samples/lines_noleaves.obj +422 -0
- compas/data/samples/mesh.obj +874 -0
- compas/data/samples/mesh_100_faces.json +1893 -0
- compas/data/samples/mesh_110_faces.json +2081 -0
- compas/data/samples/open_edges.obj +424 -0
- compas/data/samples/point.json +1 -0
- compas/data/samples/quadmesh.obj +183 -0
- compas/data/samples/quadmesh_planar.obj +181 -0
- compas/data/samples/saddle.obj +314 -0
- compas/data/samples/spline.obj +72 -0
- compas/data/samples/tubemesh.json +1 -0
- compas/data/samples/tubemesh.obj +378 -0
- compas/data/samples/tubemesh.off +374 -0
- compas/data/samples/tubemesh.ply +551 -0
- compas/data/schema.py +137 -0
- compas/data/validators.py +243 -0
- compas/datastructures/__init__.py +75 -0
- compas/datastructures/_mutablemapping.py +148 -0
- compas/datastructures/assembly/__init__.py +0 -0
- compas/datastructures/assembly/assembly.py +234 -0
- compas/datastructures/assembly/exceptions.py +6 -0
- compas/datastructures/assembly/part.py +228 -0
- compas/datastructures/attributes.py +85 -0
- compas/datastructures/cell_network/__init__.py +0 -0
- compas/datastructures/cell_network/cell_network.py +4190 -0
- compas/datastructures/datastructure.py +309 -0
- compas/datastructures/graph/__init__.py +0 -0
- compas/datastructures/graph/duality.py +197 -0
- compas/datastructures/graph/graph.py +2478 -0
- compas/datastructures/graph/operations/__init__.py +0 -0
- compas/datastructures/graph/operations/join.py +124 -0
- compas/datastructures/graph/operations/split.py +63 -0
- compas/datastructures/graph/planarity.py +292 -0
- compas/datastructures/graph/smoothing.py +59 -0
- compas/datastructures/mesh/__init__.py +0 -0
- compas/datastructures/mesh/conway.py +553 -0
- compas/datastructures/mesh/duality.py +104 -0
- compas/datastructures/mesh/mesh.py +5103 -0
- compas/datastructures/mesh/operations/__init__.py +0 -0
- compas/datastructures/mesh/operations/collapse.py +350 -0
- compas/datastructures/mesh/operations/extrude.py +0 -0
- compas/datastructures/mesh/operations/insert.py +120 -0
- compas/datastructures/mesh/operations/merge.py +83 -0
- compas/datastructures/mesh/operations/split.py +263 -0
- compas/datastructures/mesh/operations/substitute.py +37 -0
- compas/datastructures/mesh/operations/swap.py +62 -0
- compas/datastructures/mesh/operations/weld.py +107 -0
- compas/datastructures/mesh/remesh.py +234 -0
- compas/datastructures/mesh/slice.py +170 -0
- compas/datastructures/mesh/smoothing.py +187 -0
- compas/datastructures/mesh/subdivision.py +754 -0
- compas/datastructures/tree/__init__.py +0 -0
- compas/datastructures/tree/tree.py +504 -0
- compas/datastructures/volmesh/__init__.py +0 -0
- compas/datastructures/volmesh/volmesh.py +4203 -0
- compas/files/__init__.py +27 -0
- compas/files/_xml/__init__.py +0 -0
- compas/files/_xml/xml_cli.py +213 -0
- compas/files/_xml/xml_cpython.py +32 -0
- compas/files/_xml/xml_pre_38.py +58 -0
- compas/files/_xml/xml_shared.py +40 -0
- compas/files/gltf/__init__.py +0 -0
- compas/files/gltf/constants.py +59 -0
- compas/files/gltf/data_classes.py +657 -0
- compas/files/gltf/extensions.py +317 -0
- compas/files/gltf/gltf.py +92 -0
- compas/files/gltf/gltf_children.py +64 -0
- compas/files/gltf/gltf_content.py +615 -0
- compas/files/gltf/gltf_exporter.py +465 -0
- compas/files/gltf/gltf_mesh.py +273 -0
- compas/files/gltf/gltf_node.py +348 -0
- compas/files/gltf/gltf_parser.py +115 -0
- compas/files/gltf/gltf_reader.py +310 -0
- compas/files/gltf/gltf_scene.py +125 -0
- compas/files/gltf/helpers.py +59 -0
- compas/files/obj.py +680 -0
- compas/files/off.py +296 -0
- compas/files/ply.py +697 -0
- compas/files/stl.py +436 -0
- compas/files/xml.py +328 -0
- compas/geometry/__init__.py +772 -0
- compas/geometry/_core/__init__.py +0 -0
- compas/geometry/_core/_algebra.py +2826 -0
- compas/geometry/_core/angles.py +408 -0
- compas/geometry/_core/centroids.py +573 -0
- compas/geometry/_core/distance.py +895 -0
- compas/geometry/_core/normals.py +149 -0
- compas/geometry/_core/nurbs.py +367 -0
- compas/geometry/_core/predicates_2.py +582 -0
- compas/geometry/_core/predicates_3.py +1111 -0
- compas/geometry/_core/quaternions.py +196 -0
- compas/geometry/_core/size.py +204 -0
- compas/geometry/_core/tangent.py +56 -0
- compas/geometry/_core/transformations.py +1121 -0
- compas/geometry/_core/transformations_numpy.py +279 -0
- compas/geometry/bbox.py +145 -0
- compas/geometry/bbox_numpy.py +306 -0
- compas/geometry/bestfit.py +77 -0
- compas/geometry/bestfit_numpy.py +259 -0
- compas/geometry/booleans.py +297 -0
- compas/geometry/booleans_shapely.py +147 -0
- compas/geometry/brep/__init__.py +112 -0
- compas/geometry/brep/brep.py +1131 -0
- compas/geometry/brep/edge.py +302 -0
- compas/geometry/brep/errors.py +22 -0
- compas/geometry/brep/face.py +329 -0
- compas/geometry/brep/loop.py +87 -0
- compas/geometry/brep/trim.py +46 -0
- compas/geometry/brep/vertex.py +46 -0
- compas/geometry/contours.py +32 -0
- compas/geometry/curves/__init__.py +0 -0
- compas/geometry/curves/arc.py +429 -0
- compas/geometry/curves/bezier.py +345 -0
- compas/geometry/curves/circle.py +500 -0
- compas/geometry/curves/conic.py +16 -0
- compas/geometry/curves/curve.py +614 -0
- compas/geometry/curves/ellipse.py +408 -0
- compas/geometry/curves/hyperbola.py +336 -0
- compas/geometry/curves/line.py +431 -0
- compas/geometry/curves/nurbs.py +412 -0
- compas/geometry/curves/parabola.py +256 -0
- compas/geometry/curves/polyline.py +724 -0
- compas/geometry/frame.py +769 -0
- compas/geometry/geometry.py +296 -0
- compas/geometry/hull.py +146 -0
- compas/geometry/hull_numpy.py +82 -0
- compas/geometry/icp_numpy.py +104 -0
- compas/geometry/interpolation_barycentric.py +38 -0
- compas/geometry/interpolation_coons.py +102 -0
- compas/geometry/interpolation_tweening.py +87 -0
- compas/geometry/intersection.py +121 -0
- compas/geometry/intersections.py +1105 -0
- compas/geometry/kdtree.py +153 -0
- compas/geometry/offset.py +208 -0
- compas/geometry/pca_numpy.py +87 -0
- compas/geometry/plane.py +657 -0
- compas/geometry/point.py +664 -0
- compas/geometry/pointcloud.py +409 -0
- compas/geometry/polygon.py +473 -0
- compas/geometry/polyhedron.py +650 -0
- compas/geometry/projection.py +155 -0
- compas/geometry/quadmesh_planarize.py +30 -0
- compas/geometry/quadmesh_planarize_none.py +114 -0
- compas/geometry/quaternion.py +544 -0
- compas/geometry/reflection.py +102 -0
- compas/geometry/rotation.py +354 -0
- compas/geometry/scale.py +100 -0
- compas/geometry/shapes/__init__.py +0 -0
- compas/geometry/shapes/box.py +747 -0
- compas/geometry/shapes/capsule.py +472 -0
- compas/geometry/shapes/cone.py +309 -0
- compas/geometry/shapes/cylinder.py +355 -0
- compas/geometry/shapes/shape.py +300 -0
- compas/geometry/shapes/sphere.py +362 -0
- compas/geometry/shapes/torus.py +294 -0
- compas/geometry/shear.py +115 -0
- compas/geometry/surfaces/__init__.py +0 -0
- compas/geometry/surfaces/conical.py +166 -0
- compas/geometry/surfaces/cylindrical.py +251 -0
- compas/geometry/surfaces/extrusion.py +0 -0
- compas/geometry/surfaces/nurbs.py +380 -0
- compas/geometry/surfaces/planar.py +223 -0
- compas/geometry/surfaces/revolution.py +0 -0
- compas/geometry/surfaces/spherical.py +259 -0
- compas/geometry/surfaces/surface.py +689 -0
- compas/geometry/surfaces/toroidal.py +198 -0
- compas/geometry/transformation.py +554 -0
- compas/geometry/translation.py +104 -0
- compas/geometry/triangulation_delaunay.py +102 -0
- compas/geometry/triangulation_earclip.py +300 -0
- compas/geometry/trimesh_curvature.py +113 -0
- compas/geometry/trimesh_descent_numpy.py +26 -0
- compas/geometry/trimesh_geodistance.py +35 -0
- compas/geometry/trimesh_gradient_numpy.py +74 -0
- compas/geometry/trimesh_isolines.py +41 -0
- compas/geometry/trimesh_matrices.py +31 -0
- compas/geometry/trimesh_matrices_numpy.py +191 -0
- compas/geometry/trimesh_parametrisation.py +55 -0
- compas/geometry/trimesh_pull_points_numpy.py +216 -0
- compas/geometry/trimesh_remeshing.py +97 -0
- compas/geometry/trimesh_samplepoints_numpy.py +108 -0
- compas/geometry/trimesh_slicing.py +28 -0
- compas/geometry/trimesh_smoothing_numpy.py +34 -0
- compas/geometry/vector.py +889 -0
- compas/itertools.py +441 -0
- compas/linalg.py +634 -0
- compas/matrices.py +314 -0
- compas/plugins.py +488 -0
- compas/rpc/__init__.py +20 -0
- compas/rpc/__main__.py +77 -0
- compas/rpc/dispatcher.py +181 -0
- compas/rpc/errors.py +11 -0
- compas/rpc/proxy.py +437 -0
- compas/rpc/server.py +79 -0
- compas/rpc/services/__init__.py +0 -0
- compas/rpc/services/default.py +87 -0
- compas/rpc/services/watcher.py +43 -0
- compas/scene/__init__.py +56 -0
- compas/scene/assemblyobject.py +3 -0
- compas/scene/context.py +154 -0
- compas/scene/descriptors/__init__.py +0 -0
- compas/scene/descriptors/attribute.py +30 -0
- compas/scene/descriptors/color.py +91 -0
- compas/scene/descriptors/colordict.py +101 -0
- compas/scene/descriptors/protocol.py +12 -0
- compas/scene/exceptions.py +7 -0
- compas/scene/geometryobject.py +58 -0
- compas/scene/graphobject.py +173 -0
- compas/scene/meshobject.py +238 -0
- compas/scene/scene.py +144 -0
- compas/scene/sceneobject.py +253 -0
- compas/scene/volmeshobject.py +252 -0
- compas/tolerance.py +879 -0
- compas/topology/__init__.py +45 -0
- compas/topology/combinatorics.py +108 -0
- compas/topology/connectivity.py +129 -0
- compas/topology/orientation.py +204 -0
- compas/topology/traversal.py +567 -0
- compas/utilities/__init__.py +25 -0
- compas/utilities/azync.py +155 -0
- compas/utilities/datetime.py +40 -0
- compas/utilities/decorators.py +136 -0
- compas/utilities/remote.py +54 -0
- compas/utilities/ssh.py +169 -0
- compas-2.1.1.dist-info/AUTHORS.md +42 -0
- compas-2.1.1.dist-info/LICENSE +21 -0
- compas-2.1.1.dist-info/METADATA +132 -0
- compas-2.1.1.dist-info/RECORD +468 -0
- compas-2.1.1.dist-info/WHEEL +5 -0
- compas-2.1.1.dist-info/entry_points.txt +2 -0
- compas-2.1.1.dist-info/top_level.txt +4 -0
- compas_blender/__init__.py +250 -0
- compas_blender/collections.py +130 -0
- compas_blender/conversions/__init__.py +48 -0
- compas_blender/conversions/breps.py +0 -0
- compas_blender/conversions/colors.py +23 -0
- compas_blender/conversions/curves.py +125 -0
- compas_blender/conversions/geometry.py +161 -0
- compas_blender/conversions/meshes.py +148 -0
- compas_blender/conversions/surfaces.py +48 -0
- compas_blender/conversions/transformations.py +46 -0
- compas_blender/data.py +30 -0
- compas_blender/geometry/__init__.py +14 -0
- compas_blender/geometry/booleans.py +100 -0
- compas_blender/install.py +338 -0
- compas_blender/objects.py +326 -0
- compas_blender/print_python_path.py +18 -0
- compas_blender/scene/__init__.py +116 -0
- compas_blender/scene/boxobject.py +64 -0
- compas_blender/scene/capsuleobject.py +73 -0
- compas_blender/scene/circleobject.py +53 -0
- compas_blender/scene/coneobject.py +70 -0
- compas_blender/scene/curveobject.py +58 -0
- compas_blender/scene/cylinderobject.py +70 -0
- compas_blender/scene/frameobject.py +105 -0
- compas_blender/scene/graphobject.py +257 -0
- compas_blender/scene/lineobject.py +60 -0
- compas_blender/scene/meshobject.py +508 -0
- compas_blender/scene/planeobject.py +81 -0
- compas_blender/scene/pointcloudobject.py +67 -0
- compas_blender/scene/pointobject.py +71 -0
- compas_blender/scene/polygonobject.py +57 -0
- compas_blender/scene/polyhedronobject.py +57 -0
- compas_blender/scene/polylineobject.py +54 -0
- compas_blender/scene/sceneobject.py +249 -0
- compas_blender/scene/sphereobject.py +72 -0
- compas_blender/scene/surfaceobject.py +54 -0
- compas_blender/scene/torusobject.py +73 -0
- compas_blender/scene/vectorobject.py +69 -0
- compas_blender/scene/volmeshobject.py +475 -0
- compas_blender/utilities/__init__.py +38 -0
- compas_blender/utilities/drawing.py +768 -0
- compas_ghpython/__init__.py +124 -0
- compas_ghpython/components/Compas_FromJson/code.py +18 -0
- compas_ghpython/components/Compas_Info/code.py +15 -0
- compas_ghpython/components/Compas_RpcCall/code.py +31 -0
- compas_ghpython/components/Compas_ToJson/code.py +19 -0
- compas_ghpython/components/Compas_ToRhinoGeometry/code.py +15 -0
- compas_ghpython/components/__init__.py +99 -0
- compas_ghpython/install.py +29 -0
- compas_ghpython/scene/__init__.py +115 -0
- compas_ghpython/scene/boxobject.py +40 -0
- compas_ghpython/scene/brepobject.py +40 -0
- compas_ghpython/scene/capsuleobject.py +41 -0
- compas_ghpython/scene/circleobject.py +40 -0
- compas_ghpython/scene/coneobject.py +40 -0
- compas_ghpython/scene/curveobject.py +42 -0
- compas_ghpython/scene/cylinderobject.py +38 -0
- compas_ghpython/scene/ellipseobject.py +40 -0
- compas_ghpython/scene/frameobject.py +67 -0
- compas_ghpython/scene/graphobject.py +77 -0
- compas_ghpython/scene/lineobject.py +39 -0
- compas_ghpython/scene/meshobject.py +137 -0
- compas_ghpython/scene/planeobject.py +61 -0
- compas_ghpython/scene/pointobject.py +38 -0
- compas_ghpython/scene/polygonobject.py +48 -0
- compas_ghpython/scene/polyhedronobject.py +48 -0
- compas_ghpython/scene/polylineobject.py +39 -0
- compas_ghpython/scene/sceneobject.py +12 -0
- compas_ghpython/scene/sphereobject.py +39 -0
- compas_ghpython/scene/surfaceobject.py +42 -0
- compas_ghpython/scene/torusobject.py +39 -0
- compas_ghpython/scene/vectorobject.py +51 -0
- compas_ghpython/scene/volmeshobject.py +154 -0
- compas_ghpython/sets.py +83 -0
- compas_ghpython/timer.py +36 -0
- compas_ghpython/uninstall.py +31 -0
- compas_ghpython/utilities/__init__.py +33 -0
- compas_ghpython/utilities/drawing.py +457 -0
- compas_rhino/__init__.py +607 -0
- compas_rhino/conduits/__init__.py +16 -0
- compas_rhino/conduits/base.py +121 -0
- compas_rhino/conduits/faces.py +91 -0
- compas_rhino/conduits/labels.py +102 -0
- compas_rhino/conduits/lines.py +109 -0
- compas_rhino/conduits/points.py +111 -0
- compas_rhino/conversions/__init__.py +168 -0
- compas_rhino/conversions/breps.py +122 -0
- compas_rhino/conversions/curves.py +453 -0
- compas_rhino/conversions/docobjects.py +0 -0
- compas_rhino/conversions/exceptions.py +7 -0
- compas_rhino/conversions/extrusions.py +80 -0
- compas_rhino/conversions/geometry.py +187 -0
- compas_rhino/conversions/meshes.py +281 -0
- compas_rhino/conversions/shapes.py +291 -0
- compas_rhino/conversions/surfaces.py +355 -0
- compas_rhino/conversions/transformations.py +45 -0
- compas_rhino/geometry/__init__.py +44 -0
- compas_rhino/geometry/booleans.py +118 -0
- compas_rhino/geometry/brep/__init__.py +40 -0
- compas_rhino/geometry/brep/brep.py +554 -0
- compas_rhino/geometry/brep/builder.py +184 -0
- compas_rhino/geometry/brep/edge.py +202 -0
- compas_rhino/geometry/brep/face.py +285 -0
- compas_rhino/geometry/brep/loop.py +129 -0
- compas_rhino/geometry/brep/trim.py +99 -0
- compas_rhino/geometry/brep/vertex.py +76 -0
- compas_rhino/geometry/curves/__init__.py +43 -0
- compas_rhino/geometry/curves/curve.py +382 -0
- compas_rhino/geometry/curves/nurbs.py +298 -0
- compas_rhino/geometry/surfaces/__init__.py +50 -0
- compas_rhino/geometry/surfaces/nurbs.py +370 -0
- compas_rhino/geometry/surfaces/surface.py +407 -0
- compas_rhino/geometry/trimesh_curvature.py +344 -0
- compas_rhino/geometry/trimesh_slicing.py +65 -0
- compas_rhino/install.py +382 -0
- compas_rhino/install_plugin.py +169 -0
- compas_rhino/install_with_pip.py +20 -0
- compas_rhino/layers.py +347 -0
- compas_rhino/objects.py +1141 -0
- compas_rhino/print_python_path.py +18 -0
- compas_rhino/scene/__init__.py +123 -0
- compas_rhino/scene/boxobject.py +44 -0
- compas_rhino/scene/brepobject.py +41 -0
- compas_rhino/scene/capsuleobject.py +45 -0
- compas_rhino/scene/circleobject.py +43 -0
- compas_rhino/scene/coneobject.py +43 -0
- compas_rhino/scene/curveobject.py +43 -0
- compas_rhino/scene/cylinderobject.py +43 -0
- compas_rhino/scene/ellipseobject.py +44 -0
- compas_rhino/scene/frameobject.py +99 -0
- compas_rhino/scene/graphobject.py +364 -0
- compas_rhino/scene/helpers.py +33 -0
- compas_rhino/scene/lineobject.py +43 -0
- compas_rhino/scene/meshobject.py +673 -0
- compas_rhino/scene/planeobject.py +71 -0
- compas_rhino/scene/pointobject.py +43 -0
- compas_rhino/scene/polygonobject.py +45 -0
- compas_rhino/scene/polyhedronobject.py +45 -0
- compas_rhino/scene/polylineobject.py +43 -0
- compas_rhino/scene/sceneobject.py +123 -0
- compas_rhino/scene/sphereobject.py +43 -0
- compas_rhino/scene/surfaceobject.py +42 -0
- compas_rhino/scene/torusobject.py +43 -0
- compas_rhino/scene/vectorobject.py +49 -0
- compas_rhino/scene/volmeshobject.py +518 -0
- compas_rhino/ui.py +114 -0
- compas_rhino/uninstall.py +243 -0
- compas_rhino/uninstall_plugin.py +91 -0
- compas_rhino/utilities/__init__.py +37 -0
- compas_rhino/utilities/constructors.py +71 -0
- compas_rhino/utilities/drawing.py +1081 -0
|
@@ -0,0 +1,1111 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
from __future__ import division
|
|
3
|
+
from __future__ import print_function
|
|
4
|
+
|
|
5
|
+
from compas.geometry import area_triangle
|
|
6
|
+
from compas.geometry import centroid_points
|
|
7
|
+
from compas.geometry import closest_point_on_segment
|
|
8
|
+
from compas.geometry import cross_vectors
|
|
9
|
+
from compas.geometry import distance_point_line
|
|
10
|
+
from compas.geometry import distance_point_plane
|
|
11
|
+
from compas.geometry import distance_point_point
|
|
12
|
+
from compas.geometry import dot_vectors
|
|
13
|
+
from compas.geometry import length_vector
|
|
14
|
+
from compas.geometry import normal_polygon
|
|
15
|
+
from compas.geometry import subtract_vectors
|
|
16
|
+
from compas.itertools import window
|
|
17
|
+
from compas.tolerance import TOL
|
|
18
|
+
|
|
19
|
+
# =============================================================================
|
|
20
|
+
# =============================================================================
|
|
21
|
+
# =============================================================================
|
|
22
|
+
# =============================================================================
|
|
23
|
+
# =============================================================================
|
|
24
|
+
# =============================================================================
|
|
25
|
+
# =============================================================================
|
|
26
|
+
# Colinear, Coplanar
|
|
27
|
+
# =============================================================================
|
|
28
|
+
# =============================================================================
|
|
29
|
+
# =============================================================================
|
|
30
|
+
# =============================================================================
|
|
31
|
+
# =============================================================================
|
|
32
|
+
# =============================================================================
|
|
33
|
+
# =============================================================================
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def is_colinear(a, b, c, tol=None):
|
|
37
|
+
"""Determine if three points are colinear.
|
|
38
|
+
|
|
39
|
+
Parameters
|
|
40
|
+
----------
|
|
41
|
+
a : [float, float, float] | :class:`compas.geometry.Point`
|
|
42
|
+
Point 1.
|
|
43
|
+
b : [float, float, float] | :class:`compas.geometry.Point`
|
|
44
|
+
Point 2.
|
|
45
|
+
c : [float, float, float] | :class:`compas.geometry.Point`
|
|
46
|
+
Point 3.
|
|
47
|
+
tol : float, optional
|
|
48
|
+
Tolerance for comparing the area of the triangle formed by the three points to zero.
|
|
49
|
+
Default is :attr:`TOL.absolute`.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
bool
|
|
54
|
+
True if the points are colinear.
|
|
55
|
+
False otherwise.
|
|
56
|
+
|
|
57
|
+
See Also
|
|
58
|
+
--------
|
|
59
|
+
is_colinear_line_line
|
|
60
|
+
is_coplanar
|
|
61
|
+
|
|
62
|
+
"""
|
|
63
|
+
return TOL.is_zero(area_triangle([a, b, c]), tol)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def is_colinear_line_line(line1, line2, tol=None):
|
|
67
|
+
"""Determine if two lines are colinear.
|
|
68
|
+
|
|
69
|
+
Parameters
|
|
70
|
+
----------
|
|
71
|
+
line1 : [point, point] | :class:`compas.geometry.Line`
|
|
72
|
+
Line 1.
|
|
73
|
+
line2 : [point, point] | :class:`compas.geometry.Line`
|
|
74
|
+
Line 2.
|
|
75
|
+
tol : float, optional
|
|
76
|
+
Tolerance for colinearity verification.
|
|
77
|
+
Default is :attr:`TOL.absolute`.
|
|
78
|
+
|
|
79
|
+
Returns
|
|
80
|
+
-------
|
|
81
|
+
bool
|
|
82
|
+
True if the lines are colinear.
|
|
83
|
+
False otherwise.
|
|
84
|
+
|
|
85
|
+
See Also
|
|
86
|
+
--------
|
|
87
|
+
is_colinear
|
|
88
|
+
is_coplanar
|
|
89
|
+
|
|
90
|
+
"""
|
|
91
|
+
a, b = line1
|
|
92
|
+
c, d = line2
|
|
93
|
+
return is_colinear(a, b, c, tol) and is_colinear(a, b, d, tol)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def is_coplanar(points, tol=None):
|
|
97
|
+
"""Determine if the points are coplanar.
|
|
98
|
+
|
|
99
|
+
Parameters
|
|
100
|
+
----------
|
|
101
|
+
points : sequence[point]
|
|
102
|
+
A sequence of point locations.
|
|
103
|
+
tol : float, optional
|
|
104
|
+
A tolerance for planarity validation.
|
|
105
|
+
|
|
106
|
+
Returns
|
|
107
|
+
-------
|
|
108
|
+
bool
|
|
109
|
+
True if the points are coplanar.
|
|
110
|
+
False otherwise.
|
|
111
|
+
|
|
112
|
+
See Also
|
|
113
|
+
--------
|
|
114
|
+
is_colinear
|
|
115
|
+
is_colinear_line_line
|
|
116
|
+
|
|
117
|
+
Notes
|
|
118
|
+
-----
|
|
119
|
+
Compute the normal vector (cross product) of the vectors formed by the first three points.
|
|
120
|
+
Taking the first point as base point, include one more vector at a time and check if that vector is perpendicular to the normal vector.
|
|
121
|
+
If all vectors are perpendicular, the points are coplanar.
|
|
122
|
+
|
|
123
|
+
"""
|
|
124
|
+
if len(points) < 4:
|
|
125
|
+
return True
|
|
126
|
+
|
|
127
|
+
temp = points[:]
|
|
128
|
+
|
|
129
|
+
while len(temp) >= 3:
|
|
130
|
+
a = temp.pop(0)
|
|
131
|
+
b = temp.pop(0)
|
|
132
|
+
c = temp.pop(0)
|
|
133
|
+
if not is_colinear(a, b, c, tol):
|
|
134
|
+
break
|
|
135
|
+
if not temp:
|
|
136
|
+
return True
|
|
137
|
+
|
|
138
|
+
n = cross_vectors(subtract_vectors(b, a), subtract_vectors(c, a))
|
|
139
|
+
|
|
140
|
+
return all(is_perpendicular_vector_vector(n, subtract_vectors(d, a), tol) for d in temp)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
# =============================================================================
|
|
144
|
+
# =============================================================================
|
|
145
|
+
# =============================================================================
|
|
146
|
+
# =============================================================================
|
|
147
|
+
# =============================================================================
|
|
148
|
+
# =============================================================================
|
|
149
|
+
# =============================================================================
|
|
150
|
+
# Parallel, Perpendicular
|
|
151
|
+
# =============================================================================
|
|
152
|
+
# =============================================================================
|
|
153
|
+
# =============================================================================
|
|
154
|
+
# =============================================================================
|
|
155
|
+
# =============================================================================
|
|
156
|
+
# =============================================================================
|
|
157
|
+
# =============================================================================
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def is_parallel_vector_vector(u, v, tol=None):
|
|
161
|
+
"""Determine if two vectors are parallel.
|
|
162
|
+
|
|
163
|
+
Parameters
|
|
164
|
+
----------
|
|
165
|
+
u : [float, float, float] | :class:`~compas.geometry.Vector`
|
|
166
|
+
Vector 1.
|
|
167
|
+
v : [float, float, float] | :class:`~compas.geometry.Vector`
|
|
168
|
+
Vector 2.
|
|
169
|
+
tol : float, optional
|
|
170
|
+
Tolerance for comparing the length of the cross product of the two vectors to zero.
|
|
171
|
+
Default is :attr:`TOL.absolute`.
|
|
172
|
+
|
|
173
|
+
Returns
|
|
174
|
+
-------
|
|
175
|
+
bool
|
|
176
|
+
True if the vectors are parallel.
|
|
177
|
+
False otherwise.
|
|
178
|
+
|
|
179
|
+
See Also
|
|
180
|
+
--------
|
|
181
|
+
is_parallel_line_line
|
|
182
|
+
is_parallel_plane_plane
|
|
183
|
+
|
|
184
|
+
Notes
|
|
185
|
+
-----
|
|
186
|
+
The length of the cross product of two vectors is equal to the area of the parallelogram formed by the two vectors.
|
|
187
|
+
If the vectors are parallel, the area of the parallelogram is zero.
|
|
188
|
+
|
|
189
|
+
Therefore, this predicate is based on the comparison of the length of the cross product of the two vectors to zero,
|
|
190
|
+
and not on the comparison to zero of the actual angle between the two vectors.
|
|
191
|
+
|
|
192
|
+
"""
|
|
193
|
+
# Lv = length_vector(v)
|
|
194
|
+
# V = scale_vector(v, 1 / Lv)
|
|
195
|
+
# sinus = length_vector(scale_vector(subtract_vectors(scale_vector(V, dot_vectors(u, V)), u), Lv))
|
|
196
|
+
# # for small angles, the sinus is equal to the angle in radians
|
|
197
|
+
# # for larger angles, it doesn't matter :)
|
|
198
|
+
# return TOL.is_angle_zero(sinus, tol)
|
|
199
|
+
return TOL.is_zero(length_vector(cross_vectors(u, v)), tol)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def is_parallel_line_line(line1, line2, tol=None):
|
|
203
|
+
"""Determine if two lines are parallel.
|
|
204
|
+
|
|
205
|
+
Parameters
|
|
206
|
+
----------
|
|
207
|
+
line1 : [point, point] | :class:`compas.geometry.Line`
|
|
208
|
+
Line 1.
|
|
209
|
+
line2 : [point, point] | :class:`compas.geometry.Line`
|
|
210
|
+
Line 2.
|
|
211
|
+
tol : float, optional
|
|
212
|
+
Tolerance for comparing the length of the cross product of the direction vectors of the two lines to zero.
|
|
213
|
+
Default is :attr:`TOL.absolute`.
|
|
214
|
+
|
|
215
|
+
Returns
|
|
216
|
+
-------
|
|
217
|
+
bool
|
|
218
|
+
True if the lines are colinear.
|
|
219
|
+
False otherwise.
|
|
220
|
+
|
|
221
|
+
See Also
|
|
222
|
+
--------
|
|
223
|
+
is_parallel_vector_vector
|
|
224
|
+
is_parallel_plane_plane
|
|
225
|
+
is_perpendicular_line_line
|
|
226
|
+
|
|
227
|
+
"""
|
|
228
|
+
a, b = line1
|
|
229
|
+
c, d = line2
|
|
230
|
+
ab = subtract_vectors(b, a)
|
|
231
|
+
cd = subtract_vectors(d, c)
|
|
232
|
+
return is_parallel_vector_vector(ab, cd, tol)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def is_parallel_plane_plane(plane1, plane2, tol=None):
|
|
236
|
+
"""Determine if two planes are parallel.
|
|
237
|
+
|
|
238
|
+
Parameters
|
|
239
|
+
----------
|
|
240
|
+
plane1 : [point, vector]
|
|
241
|
+
Plane 1.
|
|
242
|
+
plane2 : [point, vector]
|
|
243
|
+
Plane 2.
|
|
244
|
+
tol : float, optional
|
|
245
|
+
A tolerance for verifying parallelity of the plane normals.
|
|
246
|
+
|
|
247
|
+
Returns
|
|
248
|
+
-------
|
|
249
|
+
bool
|
|
250
|
+
True if the planes are parallel.
|
|
251
|
+
False otherwise.
|
|
252
|
+
|
|
253
|
+
See Also
|
|
254
|
+
--------
|
|
255
|
+
is_parallel_vector_vector
|
|
256
|
+
is_parallel_line_line
|
|
257
|
+
is_perpendicular_plane_plane
|
|
258
|
+
|
|
259
|
+
"""
|
|
260
|
+
return is_parallel_vector_vector(plane1[1], plane2[1], tol)
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def is_perpendicular_vector_vector(u, v, tol=None):
|
|
264
|
+
"""Determine if two vectors are perpendicular.
|
|
265
|
+
|
|
266
|
+
Parameters
|
|
267
|
+
----------
|
|
268
|
+
u : [float, float, float] | :class:`~compas.geometry.Vector`
|
|
269
|
+
Vector 1.
|
|
270
|
+
v : [float, float, float] | :class:`~compas.geometry.Vector`
|
|
271
|
+
Vector 2.
|
|
272
|
+
tol : float, optional
|
|
273
|
+
Tolerance for comparing the dot product of the two vectors to zero.
|
|
274
|
+
Default is :attr:`TOL.absolute`.
|
|
275
|
+
|
|
276
|
+
Returns
|
|
277
|
+
-------
|
|
278
|
+
bool
|
|
279
|
+
True if the vectors are perpendicular.
|
|
280
|
+
False otherwise.
|
|
281
|
+
|
|
282
|
+
See Also
|
|
283
|
+
--------
|
|
284
|
+
is_perpendicular_line_line
|
|
285
|
+
is_perpendicular_plane_plane
|
|
286
|
+
|
|
287
|
+
Notes
|
|
288
|
+
-----
|
|
289
|
+
The dot product of two vectors is equal to the product of the lengths of the two vectors and the cosine of the angle between the two vectors.
|
|
290
|
+
If the vectors are perpendicular, the cosine of the angle between the two vectors is zero.
|
|
291
|
+
|
|
292
|
+
Therefore, this predicate is based on the comparison of the dot product of the two vectors to zero,
|
|
293
|
+
and not on the comparison to zero of the actual angle between the two vectors.
|
|
294
|
+
|
|
295
|
+
"""
|
|
296
|
+
return TOL.is_zero(dot_vectors(u, v), tol)
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def is_perpendicular_line_line(line1, line2, tol=None):
|
|
300
|
+
"""Determine if two lines are perpendicular.
|
|
301
|
+
|
|
302
|
+
Parameters
|
|
303
|
+
----------
|
|
304
|
+
line1 : [point, point] | :class:`~compas.geometry.Line`
|
|
305
|
+
Line 1.
|
|
306
|
+
line2 : [point, point] | :class:`~compas.geometry.Line`
|
|
307
|
+
Line 2.
|
|
308
|
+
tol : float, optional
|
|
309
|
+
Tolerance for verifying the perpendicularity of the direction vectors of the two lines.
|
|
310
|
+
Default is :attr:`TOL.absolute`.
|
|
311
|
+
|
|
312
|
+
Returns
|
|
313
|
+
-------
|
|
314
|
+
bool
|
|
315
|
+
True if the lines are perpendicular.
|
|
316
|
+
False otherwise.
|
|
317
|
+
|
|
318
|
+
See Also
|
|
319
|
+
--------
|
|
320
|
+
is_perpendicular_vector_vector
|
|
321
|
+
is_perpendicular_plane_plane
|
|
322
|
+
|
|
323
|
+
"""
|
|
324
|
+
a, b = line1
|
|
325
|
+
c, d = line2
|
|
326
|
+
ab = subtract_vectors(b, a)
|
|
327
|
+
cd = subtract_vectors(d, c)
|
|
328
|
+
return is_perpendicular_vector_vector(ab, cd, tol)
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def is_perpendicular_plane_plane(plane1, plane2, tol=None):
|
|
332
|
+
"""Determine if two planes are perpendicular.
|
|
333
|
+
|
|
334
|
+
Parameters
|
|
335
|
+
----------
|
|
336
|
+
plane1 : [point, vector]
|
|
337
|
+
Plane 1.
|
|
338
|
+
plane2 : [point, vector]
|
|
339
|
+
Plane 2.
|
|
340
|
+
tol : float, optional
|
|
341
|
+
A tolerance for verifying perpendicularity of the plane normals.
|
|
342
|
+
|
|
343
|
+
Returns
|
|
344
|
+
-------
|
|
345
|
+
bool
|
|
346
|
+
True if the planes are perpendicular.
|
|
347
|
+
False otherwise.
|
|
348
|
+
|
|
349
|
+
See Also
|
|
350
|
+
--------
|
|
351
|
+
is_perpendicular_vector_vector
|
|
352
|
+
is_perpendicular_line_line
|
|
353
|
+
is_parallel_plane_plane
|
|
354
|
+
|
|
355
|
+
"""
|
|
356
|
+
return is_perpendicular_vector_vector(plane1[1], plane2[1], tol)
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
# =============================================================================
|
|
360
|
+
# =============================================================================
|
|
361
|
+
# =============================================================================
|
|
362
|
+
# =============================================================================
|
|
363
|
+
# =============================================================================
|
|
364
|
+
# =============================================================================
|
|
365
|
+
# =============================================================================
|
|
366
|
+
# Convexity
|
|
367
|
+
# =============================================================================
|
|
368
|
+
# =============================================================================
|
|
369
|
+
# =============================================================================
|
|
370
|
+
# =============================================================================
|
|
371
|
+
# =============================================================================
|
|
372
|
+
# =============================================================================
|
|
373
|
+
# =============================================================================
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
def is_polygon_convex(polygon):
|
|
377
|
+
"""Determine if a polygon is convex.
|
|
378
|
+
|
|
379
|
+
Parameters
|
|
380
|
+
----------
|
|
381
|
+
polygon : sequence[point] | :class:`compas.geometry.Polygon`
|
|
382
|
+
A polygon.
|
|
383
|
+
|
|
384
|
+
Returns
|
|
385
|
+
-------
|
|
386
|
+
bool
|
|
387
|
+
True if the polygon is convex.
|
|
388
|
+
False otherwise.
|
|
389
|
+
|
|
390
|
+
See Also
|
|
391
|
+
--------
|
|
392
|
+
is_polyhedron_convex
|
|
393
|
+
|
|
394
|
+
Notes
|
|
395
|
+
-----
|
|
396
|
+
Use this function for *spatial* polygons.
|
|
397
|
+
If the polygon is in a horizontal plane, use :func:`is_polygon_convex_xy` instead.
|
|
398
|
+
|
|
399
|
+
Examples
|
|
400
|
+
--------
|
|
401
|
+
>>> polygon = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.4, 0.4, 0.0], [0.0, 1.0, 0.0]]
|
|
402
|
+
>>> is_polygon_convex(polygon)
|
|
403
|
+
False
|
|
404
|
+
|
|
405
|
+
"""
|
|
406
|
+
a = polygon[0]
|
|
407
|
+
o = polygon[1]
|
|
408
|
+
b = polygon[2]
|
|
409
|
+
oa = subtract_vectors(a, o)
|
|
410
|
+
ob = subtract_vectors(b, o)
|
|
411
|
+
n0 = cross_vectors(oa, ob)
|
|
412
|
+
for a, o, b in window(polygon + polygon[:2], 3):
|
|
413
|
+
oa = subtract_vectors(a, o)
|
|
414
|
+
ob = subtract_vectors(b, o)
|
|
415
|
+
n = cross_vectors(oa, ob)
|
|
416
|
+
if dot_vectors(n, n0) >= 0:
|
|
417
|
+
continue
|
|
418
|
+
else:
|
|
419
|
+
return False
|
|
420
|
+
return True
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
def is_polyhedron_convex(polyhedron):
|
|
424
|
+
"""Determine if a polyhedron is convex.
|
|
425
|
+
|
|
426
|
+
Parameters
|
|
427
|
+
----------
|
|
428
|
+
polyhedron : [sequence[point], sequence[sequence[int]]]
|
|
429
|
+
A polyhedron defined by a sequence of points
|
|
430
|
+
and a sequence of faces, with each face defined as a sequence of indices into the sequence of points.
|
|
431
|
+
|
|
432
|
+
Returns
|
|
433
|
+
-------
|
|
434
|
+
bool
|
|
435
|
+
True if the polyhedron is convex.
|
|
436
|
+
False otherwise.
|
|
437
|
+
|
|
438
|
+
See Also
|
|
439
|
+
--------
|
|
440
|
+
is_polygon_convex
|
|
441
|
+
|
|
442
|
+
"""
|
|
443
|
+
vertices, faces = polyhedron
|
|
444
|
+
for face in faces:
|
|
445
|
+
base = vertices[face[0]]
|
|
446
|
+
normal = normal_polygon([vertices[index] for index in face])
|
|
447
|
+
direction = None
|
|
448
|
+
for i in range(len(vertices)):
|
|
449
|
+
if i not in face:
|
|
450
|
+
point = vertices[i]
|
|
451
|
+
if direction is None:
|
|
452
|
+
direction = dot_vectors(subtract_vectors(point, base), normal) >= 0
|
|
453
|
+
else:
|
|
454
|
+
if dot_vectors(subtract_vectors(point, base), normal) >= 0 != direction:
|
|
455
|
+
return False
|
|
456
|
+
return True
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
# =============================================================================
|
|
460
|
+
# =============================================================================
|
|
461
|
+
# =============================================================================
|
|
462
|
+
# =============================================================================
|
|
463
|
+
# =============================================================================
|
|
464
|
+
# =============================================================================
|
|
465
|
+
# =============================================================================
|
|
466
|
+
# Containment (Plane)
|
|
467
|
+
# =============================================================================
|
|
468
|
+
# =============================================================================
|
|
469
|
+
# =============================================================================
|
|
470
|
+
# =============================================================================
|
|
471
|
+
# =============================================================================
|
|
472
|
+
# =============================================================================
|
|
473
|
+
# =============================================================================
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
def is_point_on_plane(point, plane, tol=None):
|
|
477
|
+
"""Determine if a point lies on a plane.
|
|
478
|
+
|
|
479
|
+
Parameters
|
|
480
|
+
----------
|
|
481
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
482
|
+
A point.
|
|
483
|
+
plane : [point, vector]
|
|
484
|
+
A plane.
|
|
485
|
+
tol : float, optional
|
|
486
|
+
Tolerance for comparing the distance between the point and the plane to zero.
|
|
487
|
+
Default is :attr:`TOL.absolute`.
|
|
488
|
+
|
|
489
|
+
Returns
|
|
490
|
+
-------
|
|
491
|
+
bool
|
|
492
|
+
True if the point is in on the plane.
|
|
493
|
+
False otherwise.
|
|
494
|
+
|
|
495
|
+
"""
|
|
496
|
+
return TOL.is_zero(distance_point_plane(point, plane), tol)
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
# =============================================================================
|
|
500
|
+
# =============================================================================
|
|
501
|
+
# =============================================================================
|
|
502
|
+
# =============================================================================
|
|
503
|
+
# =============================================================================
|
|
504
|
+
# =============================================================================
|
|
505
|
+
# =============================================================================
|
|
506
|
+
# Containment (Curves)
|
|
507
|
+
# =============================================================================
|
|
508
|
+
# =============================================================================
|
|
509
|
+
# =============================================================================
|
|
510
|
+
# =============================================================================
|
|
511
|
+
# =============================================================================
|
|
512
|
+
# =============================================================================
|
|
513
|
+
# =============================================================================
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
def is_point_on_line(point, line, tol=None):
|
|
517
|
+
"""Determine if a point lies on a line.
|
|
518
|
+
|
|
519
|
+
Parameters
|
|
520
|
+
----------
|
|
521
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
522
|
+
A point.
|
|
523
|
+
line : [point, point] | :class:`compas.geometry.Line`
|
|
524
|
+
A line.
|
|
525
|
+
tol : float, optional
|
|
526
|
+
Tolerance for comparing the distance between the point and the line to zero.
|
|
527
|
+
Default is :attr:`TOL.absolute`.
|
|
528
|
+
|
|
529
|
+
Returns
|
|
530
|
+
-------
|
|
531
|
+
bool
|
|
532
|
+
True if the point is in on the line.
|
|
533
|
+
False otherwise.
|
|
534
|
+
|
|
535
|
+
"""
|
|
536
|
+
return TOL.is_zero(distance_point_line(point, line), tol)
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
def is_point_on_segment(point, segment, tol=None):
|
|
540
|
+
"""Determine if a point lies on a given line segment.
|
|
541
|
+
|
|
542
|
+
Parameters
|
|
543
|
+
----------
|
|
544
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
545
|
+
A point.
|
|
546
|
+
segment : [point, point] | :class:`compas.geometry.Line`
|
|
547
|
+
A line segment.
|
|
548
|
+
tol : float, optional
|
|
549
|
+
Tolerance for comparing the distance between the point and the line segment to zero.
|
|
550
|
+
Default is :attr:`TOL.absolute`.
|
|
551
|
+
|
|
552
|
+
Returns
|
|
553
|
+
-------
|
|
554
|
+
bool
|
|
555
|
+
True if the point is on the line segment.
|
|
556
|
+
False otherwise.
|
|
557
|
+
|
|
558
|
+
"""
|
|
559
|
+
a, b = segment
|
|
560
|
+
|
|
561
|
+
d_ab = distance_point_point(a, b)
|
|
562
|
+
if d_ab == 0:
|
|
563
|
+
return False
|
|
564
|
+
|
|
565
|
+
if not is_point_on_line(point, (a, b), tol=tol):
|
|
566
|
+
return False
|
|
567
|
+
|
|
568
|
+
d_pa = distance_point_point(a, point)
|
|
569
|
+
d_pb = distance_point_point(b, point)
|
|
570
|
+
|
|
571
|
+
if TOL.is_close(d_pa + d_pb, d_ab, rtol=0, atol=tol):
|
|
572
|
+
return True
|
|
573
|
+
return False
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
def is_point_on_polyline(point, polyline, tol=None):
|
|
577
|
+
"""Determine if a point is on a polyline.
|
|
578
|
+
|
|
579
|
+
Parameters
|
|
580
|
+
----------
|
|
581
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
582
|
+
A point.
|
|
583
|
+
polyline : sequence[point] | :class:`compas.geometry.Polyline`
|
|
584
|
+
A polyline.
|
|
585
|
+
tol : float, optional
|
|
586
|
+
Tolerance for comparing the distance between the point and the polyline to zero.
|
|
587
|
+
Default is :attr:`TOL.absolute`.
|
|
588
|
+
|
|
589
|
+
Returns
|
|
590
|
+
-------
|
|
591
|
+
bool
|
|
592
|
+
True if the point is on the polyline.
|
|
593
|
+
False otherwise.
|
|
594
|
+
|
|
595
|
+
"""
|
|
596
|
+
for i in range(len(polyline) - 1):
|
|
597
|
+
a = polyline[i]
|
|
598
|
+
b = polyline[i + 1]
|
|
599
|
+
c = closest_point_on_segment(point, (a, b))
|
|
600
|
+
|
|
601
|
+
if TOL.is_zero(distance_point_point(point, c), tol):
|
|
602
|
+
return True
|
|
603
|
+
|
|
604
|
+
return False
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
def is_point_on_circle(point, circle, tol=None):
|
|
608
|
+
"""Determine if a point lies on a circle.
|
|
609
|
+
|
|
610
|
+
Parameters
|
|
611
|
+
----------
|
|
612
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
613
|
+
A point.
|
|
614
|
+
circle : [plane, float]
|
|
615
|
+
A circle.
|
|
616
|
+
tol : float, optional
|
|
617
|
+
A tolerance for membership verification.
|
|
618
|
+
|
|
619
|
+
Returns
|
|
620
|
+
-------
|
|
621
|
+
bool
|
|
622
|
+
True if the point lies on the circle.
|
|
623
|
+
False otherwise.
|
|
624
|
+
|
|
625
|
+
"""
|
|
626
|
+
plane, radius = circle
|
|
627
|
+
if is_point_on_plane(point, plane):
|
|
628
|
+
return TOL.is_zero(distance_point_point(point, plane[0]) - radius, tol)
|
|
629
|
+
return False
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
# =============================================================================
|
|
633
|
+
# =============================================================================
|
|
634
|
+
# =============================================================================
|
|
635
|
+
# =============================================================================
|
|
636
|
+
# =============================================================================
|
|
637
|
+
# =============================================================================
|
|
638
|
+
# =============================================================================
|
|
639
|
+
# Containment (Surfaces)
|
|
640
|
+
# =============================================================================
|
|
641
|
+
# =============================================================================
|
|
642
|
+
# =============================================================================
|
|
643
|
+
# =============================================================================
|
|
644
|
+
# =============================================================================
|
|
645
|
+
# =============================================================================
|
|
646
|
+
# =============================================================================
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
# =============================================================================
|
|
650
|
+
# =============================================================================
|
|
651
|
+
# =============================================================================
|
|
652
|
+
# =============================================================================
|
|
653
|
+
# =============================================================================
|
|
654
|
+
# =============================================================================
|
|
655
|
+
# =============================================================================
|
|
656
|
+
# Containment (Shapes)
|
|
657
|
+
# =============================================================================
|
|
658
|
+
# =============================================================================
|
|
659
|
+
# =============================================================================
|
|
660
|
+
# =============================================================================
|
|
661
|
+
# =============================================================================
|
|
662
|
+
# =============================================================================
|
|
663
|
+
# =============================================================================
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
def is_point_in_circle(point, circle, tol=None):
|
|
667
|
+
"""Determine if a point lies in a circle.
|
|
668
|
+
|
|
669
|
+
Parameters
|
|
670
|
+
----------
|
|
671
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
672
|
+
A point.
|
|
673
|
+
circle : [plane, float]
|
|
674
|
+
A circle.
|
|
675
|
+
|
|
676
|
+
Returns
|
|
677
|
+
-------
|
|
678
|
+
bool
|
|
679
|
+
True if the point lies in the circle.
|
|
680
|
+
False otherwise.
|
|
681
|
+
|
|
682
|
+
"""
|
|
683
|
+
plane, radius = circle
|
|
684
|
+
if is_point_on_plane(point, plane, tol=tol):
|
|
685
|
+
return TOL.is_positive(radius - distance_point_point(point, plane[0]), tol)
|
|
686
|
+
return False
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
def is_point_in_triangle(point, triangle, tol=None):
|
|
690
|
+
"""Determine if a point is in the interior of a triangle.
|
|
691
|
+
|
|
692
|
+
Parameters
|
|
693
|
+
----------
|
|
694
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
695
|
+
A point.
|
|
696
|
+
triangle : [point, point, point]
|
|
697
|
+
A triangle.
|
|
698
|
+
|
|
699
|
+
Returns
|
|
700
|
+
-------
|
|
701
|
+
bool
|
|
702
|
+
True if the point is in inside the triangle.
|
|
703
|
+
False otherwise.
|
|
704
|
+
|
|
705
|
+
See Also
|
|
706
|
+
--------
|
|
707
|
+
compas.geometry.is_point_in_triangle_xy
|
|
708
|
+
|
|
709
|
+
"""
|
|
710
|
+
|
|
711
|
+
def is_on_same_side(p1, p2, segment):
|
|
712
|
+
a, b = segment
|
|
713
|
+
v = subtract_vectors(b, a)
|
|
714
|
+
c1 = cross_vectors(v, subtract_vectors(p1, a))
|
|
715
|
+
c2 = cross_vectors(v, subtract_vectors(p2, a))
|
|
716
|
+
if dot_vectors(c1, c2) >= 0:
|
|
717
|
+
return True
|
|
718
|
+
return False
|
|
719
|
+
|
|
720
|
+
a, b, c = triangle
|
|
721
|
+
|
|
722
|
+
if is_point_on_plane(point, (a, normal_polygon(triangle)), tol=tol):
|
|
723
|
+
if is_on_same_side(point, a, (b, c)) and is_on_same_side(point, b, (a, c)) and is_on_same_side(point, c, (a, b)):
|
|
724
|
+
return True
|
|
725
|
+
|
|
726
|
+
return False
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
def is_point_in_polygon(point, polygon, tol=None):
|
|
730
|
+
"""Determine if a point is in the interior of a polygon.
|
|
731
|
+
|
|
732
|
+
Parameters
|
|
733
|
+
----------
|
|
734
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
735
|
+
A point.
|
|
736
|
+
polygon : sequence[point] | :class:`compas.geometry.Polygon`
|
|
737
|
+
A polygon.
|
|
738
|
+
|
|
739
|
+
Returns
|
|
740
|
+
-------
|
|
741
|
+
bool
|
|
742
|
+
True if the point is in inside the polygon.
|
|
743
|
+
False otherwise.
|
|
744
|
+
|
|
745
|
+
"""
|
|
746
|
+
raise NotImplementedError
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
# =============================================================================
|
|
750
|
+
# =============================================================================
|
|
751
|
+
# =============================================================================
|
|
752
|
+
# =============================================================================
|
|
753
|
+
# =============================================================================
|
|
754
|
+
# =============================================================================
|
|
755
|
+
# =============================================================================
|
|
756
|
+
# Containment (Solids)
|
|
757
|
+
# =============================================================================
|
|
758
|
+
# =============================================================================
|
|
759
|
+
# =============================================================================
|
|
760
|
+
# =============================================================================
|
|
761
|
+
# =============================================================================
|
|
762
|
+
# =============================================================================
|
|
763
|
+
# =============================================================================
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
def is_point_in_sphere(point, sphere, tol=None):
|
|
767
|
+
"""Determine if a point lies in a sphere.
|
|
768
|
+
|
|
769
|
+
Parameters
|
|
770
|
+
----------
|
|
771
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
772
|
+
A point.
|
|
773
|
+
sphere : [point, float]
|
|
774
|
+
A sphere.
|
|
775
|
+
|
|
776
|
+
Returns
|
|
777
|
+
-------
|
|
778
|
+
bool
|
|
779
|
+
True if the point lies in the sphere.
|
|
780
|
+
False otherwise.
|
|
781
|
+
|
|
782
|
+
"""
|
|
783
|
+
center, radius = sphere
|
|
784
|
+
return TOL.is_positive(radius - distance_point_point(point, center), tol)
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
def is_point_in_aab(point, box, tol=None):
|
|
788
|
+
"""Determine if a point lies in an axis-aligned box.
|
|
789
|
+
|
|
790
|
+
Parameters
|
|
791
|
+
----------
|
|
792
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
793
|
+
A point.
|
|
794
|
+
box : [[float, float, float], [float, float, float]] | [:class:`compas.geometry.Point`, :class:`compas.geometry.Point``]
|
|
795
|
+
An axis-aligned box defined by the min/max corners.
|
|
796
|
+
|
|
797
|
+
Returns
|
|
798
|
+
-------
|
|
799
|
+
bool
|
|
800
|
+
True if the point lies in the box.
|
|
801
|
+
False otherwise.
|
|
802
|
+
|
|
803
|
+
"""
|
|
804
|
+
a, b = box
|
|
805
|
+
return all(TOL.is_between(point[i], minval=a[i], maxval=b[i], atol=tol) for i in range(3))
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
def is_point_in_polyhedron(point, polyhedron, tol=None):
|
|
809
|
+
"""Determine if the point lies inside the given polyhedron.
|
|
810
|
+
|
|
811
|
+
Parameters
|
|
812
|
+
----------
|
|
813
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
814
|
+
The test point.
|
|
815
|
+
polyhedron : [sequence[point], sequence[sequence[int]]]
|
|
816
|
+
The polyhedron defined by a sequence of points
|
|
817
|
+
and a sequence of faces, with each face defined as a sequence of indices into the sequence of points.
|
|
818
|
+
|
|
819
|
+
Returns
|
|
820
|
+
-------
|
|
821
|
+
bool
|
|
822
|
+
True, if the point lies in the polyhedron.
|
|
823
|
+
False, otherwise.
|
|
824
|
+
|
|
825
|
+
"""
|
|
826
|
+
vertices, faces = polyhedron
|
|
827
|
+
polygons = [[vertices[index] for index in face] for face in faces]
|
|
828
|
+
planes = [[centroid_points(polygon), normal_polygon(polygon)] for polygon in polygons]
|
|
829
|
+
return all(is_point_behind_plane(point, plane, tol=tol) for plane in planes)
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
def is_point_infrontof_plane(point, plane, tol=None):
|
|
833
|
+
"""Determine if a point lies in front of a plane.
|
|
834
|
+
|
|
835
|
+
Parameters
|
|
836
|
+
----------
|
|
837
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
838
|
+
A point.
|
|
839
|
+
plane : [point, vector]
|
|
840
|
+
A plane.
|
|
841
|
+
tol : float, optional
|
|
842
|
+
A tolerance for membership verification.
|
|
843
|
+
|
|
844
|
+
Returns
|
|
845
|
+
-------
|
|
846
|
+
bool
|
|
847
|
+
True if the point is in front of the plane.
|
|
848
|
+
False otherwise.
|
|
849
|
+
|
|
850
|
+
"""
|
|
851
|
+
return TOL.is_positive(dot_vectors(subtract_vectors(point, plane[0]), plane[1]), tol)
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
def is_point_behind_plane(point, plane, tol=None):
|
|
855
|
+
"""Determine if a point lies behind a plane.
|
|
856
|
+
|
|
857
|
+
Parameters
|
|
858
|
+
----------
|
|
859
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
860
|
+
A point.
|
|
861
|
+
plane : [point, normal]
|
|
862
|
+
A plane.
|
|
863
|
+
tol : float, optional
|
|
864
|
+
A tolerance for membership verification.
|
|
865
|
+
|
|
866
|
+
Returns
|
|
867
|
+
-------
|
|
868
|
+
bool
|
|
869
|
+
True if the point is in front of the plane.
|
|
870
|
+
False otherwise.
|
|
871
|
+
|
|
872
|
+
"""
|
|
873
|
+
return TOL.is_negative(dot_vectors(subtract_vectors(point, plane[0]), plane[1]), tol)
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
# =============================================================================
|
|
877
|
+
# =============================================================================
|
|
878
|
+
# =============================================================================
|
|
879
|
+
# =============================================================================
|
|
880
|
+
# =============================================================================
|
|
881
|
+
# =============================================================================
|
|
882
|
+
# =============================================================================
|
|
883
|
+
# Deprecated
|
|
884
|
+
# =============================================================================
|
|
885
|
+
# =============================================================================
|
|
886
|
+
# =============================================================================
|
|
887
|
+
# =============================================================================
|
|
888
|
+
# =============================================================================
|
|
889
|
+
# =============================================================================
|
|
890
|
+
# =============================================================================
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
# def is_intersection_line_line(l1, l2, tol=None):
|
|
894
|
+
# """Verifies if two lines intersect.
|
|
895
|
+
|
|
896
|
+
# Parameters
|
|
897
|
+
# ----------
|
|
898
|
+
# l1 : [point, point] | :class:`compas.geometry.Line`
|
|
899
|
+
# A line.
|
|
900
|
+
# l2 : [point, point] | :class:`compas.geometry.Line`
|
|
901
|
+
# A line.
|
|
902
|
+
# tol : float, optional
|
|
903
|
+
# A tolerance for intersection verification.
|
|
904
|
+
|
|
905
|
+
# Returns
|
|
906
|
+
# -------
|
|
907
|
+
# bool
|
|
908
|
+
# True if the lines intersect in one point.
|
|
909
|
+
# False if the lines are skew, parallel or lie on top of each other.
|
|
910
|
+
|
|
911
|
+
# """
|
|
912
|
+
# a, b = l1
|
|
913
|
+
# c, d = l2
|
|
914
|
+
|
|
915
|
+
# e1 = normalize_vector(subtract_vectors(b, a))
|
|
916
|
+
# e2 = normalize_vector(subtract_vectors(d, c))
|
|
917
|
+
|
|
918
|
+
# # check for parallel lines
|
|
919
|
+
# if abs(dot_vectors(e1, e2)) > 1.0 - tol:
|
|
920
|
+
# return False
|
|
921
|
+
|
|
922
|
+
# # check for intersection
|
|
923
|
+
# if abs(dot_vectors(cross_vectors(e1, e2), subtract_vectors(c, a))) < tol:
|
|
924
|
+
# return True
|
|
925
|
+
# return False
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
# def is_intersection_segment_segment(s1, s2, tol=None):
|
|
929
|
+
# """Verifies if two segments intersect.
|
|
930
|
+
|
|
931
|
+
# Parameters
|
|
932
|
+
# ----------
|
|
933
|
+
# s1 : [point, point] | :class:`compas.geometry.Line`
|
|
934
|
+
# A line segment.
|
|
935
|
+
# s2 : [point, point] | :class:`compas.geometry.Line`
|
|
936
|
+
# A line segment.
|
|
937
|
+
# tol : float, optional
|
|
938
|
+
# A tolerance for intersection verification.
|
|
939
|
+
|
|
940
|
+
# Returns
|
|
941
|
+
# -------
|
|
942
|
+
# bool
|
|
943
|
+
# True if the segments intersect in one point.
|
|
944
|
+
# False if the segments are skew, parallel or lie on top of each other.
|
|
945
|
+
|
|
946
|
+
# """
|
|
947
|
+
# raise NotImplementedError
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
# def is_intersection_line_triangle(line, triangle, tol=None):
|
|
951
|
+
# """Verifies if a line (ray) intersects with a triangle.
|
|
952
|
+
|
|
953
|
+
# Parameters
|
|
954
|
+
# ----------
|
|
955
|
+
# line : [point, point] | :class:`compas.geometry.Line`
|
|
956
|
+
# A line.
|
|
957
|
+
# triangle : [point, point, point]
|
|
958
|
+
# A triangle.
|
|
959
|
+
# tol : float, optional
|
|
960
|
+
# A tolerance for intersection verification.
|
|
961
|
+
|
|
962
|
+
# Returns
|
|
963
|
+
# -------
|
|
964
|
+
# bool
|
|
965
|
+
# True if the line (ray) intersects with the triangle.
|
|
966
|
+
# False otherwise.
|
|
967
|
+
|
|
968
|
+
# Notes
|
|
969
|
+
# -----
|
|
970
|
+
# Based on the Moeller Trumbore intersection algorithm.
|
|
971
|
+
# The line is treated as continues, directed ray and not as line segment with a start and end point
|
|
972
|
+
|
|
973
|
+
# Examples
|
|
974
|
+
# --------
|
|
975
|
+
# >>>
|
|
976
|
+
|
|
977
|
+
# """
|
|
978
|
+
# a, b, c = triangle
|
|
979
|
+
# # direction vector and base point of line
|
|
980
|
+
# v1 = subtract_vectors(line[1], line[0])
|
|
981
|
+
# p1 = line[0]
|
|
982
|
+
# # Find vectors for two edges sharing triangle vertex 1
|
|
983
|
+
# e1 = subtract_vectors(b, a)
|
|
984
|
+
# e2 = subtract_vectors(c, a)
|
|
985
|
+
# # Begin calculating determinant - also used to calculate u parameter
|
|
986
|
+
# p = cross_vectors(v1, e2)
|
|
987
|
+
# # if determinant is near zero, ray lies in plane of triangle
|
|
988
|
+
# det = dot_vectors(e1, p)
|
|
989
|
+
|
|
990
|
+
# # NOT CULLING
|
|
991
|
+
# if det > -tol and det < tol:
|
|
992
|
+
# return False
|
|
993
|
+
|
|
994
|
+
# inv_det = 1.0 / det
|
|
995
|
+
# # calculate distance from V1 to ray origin
|
|
996
|
+
# t = subtract_vectors(p1, a)
|
|
997
|
+
# # Calculate u parameter and make_blocks bound
|
|
998
|
+
# u = dot_vectors(t, p) * inv_det
|
|
999
|
+
|
|
1000
|
+
# # The intersection lies outside of the triangle
|
|
1001
|
+
# if u < 0.0 or u > 1.0:
|
|
1002
|
+
# return False
|
|
1003
|
+
|
|
1004
|
+
# # Prepare to make_blocks v parameter
|
|
1005
|
+
# q = cross_vectors(t, e1)
|
|
1006
|
+
# # Calculate V parameter and make_blocks bound
|
|
1007
|
+
# v = dot_vectors(v1, q) * inv_det
|
|
1008
|
+
|
|
1009
|
+
# # The intersection lies outside of the triangle
|
|
1010
|
+
# if v < 0.0 or u + v > 1.0:
|
|
1011
|
+
# return False
|
|
1012
|
+
|
|
1013
|
+
# t = dot_vectors(e2, q) * inv_det
|
|
1014
|
+
|
|
1015
|
+
# if t > tol:
|
|
1016
|
+
# return True
|
|
1017
|
+
# # No hit
|
|
1018
|
+
# return False
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
# def is_intersection_line_plane(line, plane, tol=None):
|
|
1022
|
+
# """Determine if a line (ray) intersects with a plane.
|
|
1023
|
+
|
|
1024
|
+
# Parameters
|
|
1025
|
+
# ----------
|
|
1026
|
+
# line : [point, point] | :class:`compas.geometry.Line`
|
|
1027
|
+
# A line.
|
|
1028
|
+
# plane : [point, vector]
|
|
1029
|
+
# A plane.
|
|
1030
|
+
# tol : float, optional
|
|
1031
|
+
# A tolerance for intersection verification.
|
|
1032
|
+
|
|
1033
|
+
# Returns
|
|
1034
|
+
# -------
|
|
1035
|
+
# bool
|
|
1036
|
+
# True if the line intersects with the plane.
|
|
1037
|
+
# False otherwise.
|
|
1038
|
+
|
|
1039
|
+
# """
|
|
1040
|
+
# pt1 = line[0]
|
|
1041
|
+
# pt2 = line[1]
|
|
1042
|
+
# p_norm = plane[1]
|
|
1043
|
+
|
|
1044
|
+
# v1 = subtract_vectors(pt2, pt1)
|
|
1045
|
+
# dot = dot_vectors(p_norm, v1)
|
|
1046
|
+
|
|
1047
|
+
# if fabs(dot) > tol:
|
|
1048
|
+
# return True
|
|
1049
|
+
# return False
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
# def is_intersection_segment_plane(segment, plane, tol=None):
|
|
1053
|
+
# """Determine if a line segment intersects with a plane.
|
|
1054
|
+
|
|
1055
|
+
# Parameters
|
|
1056
|
+
# ----------
|
|
1057
|
+
# segment : [point, point] | :class:`compas.geometry.Line`
|
|
1058
|
+
# A line segment.
|
|
1059
|
+
# plane : [point, vector]
|
|
1060
|
+
# A plane.
|
|
1061
|
+
# tol : float, optional
|
|
1062
|
+
# A tolerance for intersection verification.
|
|
1063
|
+
|
|
1064
|
+
# Returns
|
|
1065
|
+
# -------
|
|
1066
|
+
# bool
|
|
1067
|
+
# True if the segment intersects with the plane.
|
|
1068
|
+
# False otherwise.
|
|
1069
|
+
|
|
1070
|
+
# """
|
|
1071
|
+
# pt1 = segment[0]
|
|
1072
|
+
# pt2 = segment[1]
|
|
1073
|
+
# p_cent = plane[0]
|
|
1074
|
+
# p_norm = plane[1]
|
|
1075
|
+
|
|
1076
|
+
# v1 = subtract_vectors(pt2, pt1)
|
|
1077
|
+
# dot = dot_vectors(p_norm, v1)
|
|
1078
|
+
|
|
1079
|
+
# if fabs(dot) > tol:
|
|
1080
|
+
# v2 = subtract_vectors(pt1, p_cent)
|
|
1081
|
+
# fac = -dot_vectors(p_norm, v2) / dot
|
|
1082
|
+
# if fac > 0.0 and fac < 1.0:
|
|
1083
|
+
# return True
|
|
1084
|
+
# return False
|
|
1085
|
+
# else:
|
|
1086
|
+
# return False
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
# def is_intersection_plane_plane(plane1, plane2, tol=None):
|
|
1090
|
+
# """Verifies if two planes intersect.
|
|
1091
|
+
|
|
1092
|
+
# Parameters
|
|
1093
|
+
# ----------
|
|
1094
|
+
# plane1 : [point, vector]
|
|
1095
|
+
# A plane.
|
|
1096
|
+
# plane2 : [point, vector]
|
|
1097
|
+
# A plane.
|
|
1098
|
+
# tol : float, optional
|
|
1099
|
+
# A tolerance for intersection verification.
|
|
1100
|
+
|
|
1101
|
+
# Returns
|
|
1102
|
+
# -------
|
|
1103
|
+
# bool
|
|
1104
|
+
# True if plane1 intersects with plane2.
|
|
1105
|
+
# False otherwise.
|
|
1106
|
+
|
|
1107
|
+
# """
|
|
1108
|
+
# # check for parallelity of planes
|
|
1109
|
+
# if abs(dot_vectors(plane1[1], plane2[1])) > 1 - tol:
|
|
1110
|
+
# return False
|
|
1111
|
+
# return True
|