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,889 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
from __future__ import division
|
|
3
|
+
from __future__ import print_function
|
|
4
|
+
|
|
5
|
+
from compas.geometry import Geometry
|
|
6
|
+
from compas.geometry import angle_vectors
|
|
7
|
+
from compas.geometry import angle_vectors_signed
|
|
8
|
+
from compas.geometry import angles_vectors
|
|
9
|
+
from compas.geometry import cross_vectors
|
|
10
|
+
from compas.geometry import dot_vectors
|
|
11
|
+
from compas.geometry import length_vector
|
|
12
|
+
from compas.geometry import subtract_vectors
|
|
13
|
+
from compas.geometry import transform_vectors
|
|
14
|
+
from compas.tolerance import TOL
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Vector(Geometry):
|
|
18
|
+
"""A vector is defined by XYZ components and a homogenisation factor.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
x : float
|
|
23
|
+
The X component of the vector.
|
|
24
|
+
y : float
|
|
25
|
+
The Y component of the vector.
|
|
26
|
+
z : float
|
|
27
|
+
The Z component of the vector.
|
|
28
|
+
name : str, optional
|
|
29
|
+
The name of the vector.
|
|
30
|
+
|
|
31
|
+
Attributes
|
|
32
|
+
----------
|
|
33
|
+
x : float
|
|
34
|
+
The X coordinate of the point.
|
|
35
|
+
y : float
|
|
36
|
+
The Y coordinate of the point.
|
|
37
|
+
z : float
|
|
38
|
+
The Z coordinate of the point.
|
|
39
|
+
length : float, read-only
|
|
40
|
+
The length of this vector.
|
|
41
|
+
|
|
42
|
+
Examples
|
|
43
|
+
--------
|
|
44
|
+
>>> u = Vector(1, 0, 0)
|
|
45
|
+
>>> v = Vector(0, 1, 0)
|
|
46
|
+
>>> u
|
|
47
|
+
Vector(1.000, 0.000, 0.000)
|
|
48
|
+
>>> v
|
|
49
|
+
Vector(0.000, 1.000, 0.000)
|
|
50
|
+
>>> u.x
|
|
51
|
+
1.0
|
|
52
|
+
>>> u[0]
|
|
53
|
+
1.0
|
|
54
|
+
>>> u.length
|
|
55
|
+
1.0
|
|
56
|
+
>>> u + v
|
|
57
|
+
Vector(1.000, 1.000, 0.000)
|
|
58
|
+
>>> u + [0.0, 1.0, 0.0]
|
|
59
|
+
Vector(1.000, 1.000, 0.000)
|
|
60
|
+
>>> u * 2
|
|
61
|
+
Vector(2.000, 0.000, 0.000)
|
|
62
|
+
>>> u.dot(v)
|
|
63
|
+
0.0
|
|
64
|
+
>>> u.cross(v)
|
|
65
|
+
Vector(0.000, 0.000, 1.000)
|
|
66
|
+
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
DATASCHEMA = {
|
|
70
|
+
"type": "array",
|
|
71
|
+
"minItems": 3,
|
|
72
|
+
"maxItems": 3,
|
|
73
|
+
"items": {"type": "number"},
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def __data__(self):
|
|
78
|
+
return list(self)
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
def __from_data__(cls, data):
|
|
82
|
+
return cls(*data)
|
|
83
|
+
|
|
84
|
+
def __init__(self, x, y, z=0.0, name=None):
|
|
85
|
+
super(Vector, self).__init__(name=name)
|
|
86
|
+
self._x = 0.0
|
|
87
|
+
self._y = 0.0
|
|
88
|
+
self._z = 0.0
|
|
89
|
+
self._direction = None
|
|
90
|
+
self._magnitude = None
|
|
91
|
+
self.x = x
|
|
92
|
+
self.y = y
|
|
93
|
+
self.z = z
|
|
94
|
+
|
|
95
|
+
def __repr__(self):
|
|
96
|
+
return "{0}(x={1}, y={2}, z={3})".format(
|
|
97
|
+
type(self).__name__,
|
|
98
|
+
self.x,
|
|
99
|
+
self.y,
|
|
100
|
+
self.z,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
def __str__(self):
|
|
104
|
+
return "{0}(x={1}, y={2}, z={3})".format(
|
|
105
|
+
type(self).__name__,
|
|
106
|
+
TOL.format_number(self.x),
|
|
107
|
+
TOL.format_number(self.y),
|
|
108
|
+
TOL.format_number(self.z),
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
def __len__(self):
|
|
112
|
+
return 3
|
|
113
|
+
|
|
114
|
+
def __getitem__(self, key):
|
|
115
|
+
if isinstance(key, slice):
|
|
116
|
+
return [self[i] for i in range(*key.indices(len(self)))]
|
|
117
|
+
i = key % 3
|
|
118
|
+
if i == 0:
|
|
119
|
+
return self.x
|
|
120
|
+
if i == 1:
|
|
121
|
+
return self.y
|
|
122
|
+
if i == 2:
|
|
123
|
+
return self.z
|
|
124
|
+
raise KeyError
|
|
125
|
+
|
|
126
|
+
def __setitem__(self, key, value):
|
|
127
|
+
i = key % 3
|
|
128
|
+
if i == 0:
|
|
129
|
+
self.x = value
|
|
130
|
+
return
|
|
131
|
+
if i == 1:
|
|
132
|
+
self.y = value
|
|
133
|
+
return
|
|
134
|
+
if i == 2:
|
|
135
|
+
self.z = value
|
|
136
|
+
return
|
|
137
|
+
raise KeyError
|
|
138
|
+
|
|
139
|
+
def __iter__(self):
|
|
140
|
+
return iter([self.x, self.y, self.z])
|
|
141
|
+
|
|
142
|
+
def __eq__(self, other):
|
|
143
|
+
return self.x == other[0] and self.y == other[1] and self.z == other[2]
|
|
144
|
+
|
|
145
|
+
def __add__(self, other):
|
|
146
|
+
return Vector(self.x + other[0], self.y + other[1], self.z + other[2])
|
|
147
|
+
|
|
148
|
+
def __sub__(self, other):
|
|
149
|
+
return Vector(self.x - other[0], self.y - other[1], self.z - other[2])
|
|
150
|
+
|
|
151
|
+
def __mul__(self, n):
|
|
152
|
+
return Vector(self.x * n, self.y * n, self.z * n)
|
|
153
|
+
|
|
154
|
+
def __truediv__(self, n):
|
|
155
|
+
return Vector(self.x / n, self.y / n, self.z / n)
|
|
156
|
+
|
|
157
|
+
def __pow__(self, n):
|
|
158
|
+
return Vector(self.x**n, self.y**n, self.z**n)
|
|
159
|
+
|
|
160
|
+
def __neg__(self):
|
|
161
|
+
return self.scaled(-1.0)
|
|
162
|
+
|
|
163
|
+
def __iadd__(self, other):
|
|
164
|
+
self.x += other[0]
|
|
165
|
+
self.y += other[1]
|
|
166
|
+
self.z += other[2]
|
|
167
|
+
return self
|
|
168
|
+
|
|
169
|
+
def __isub__(self, other):
|
|
170
|
+
self.x -= other[0]
|
|
171
|
+
self.y -= other[1]
|
|
172
|
+
self.z -= other[2]
|
|
173
|
+
return self
|
|
174
|
+
|
|
175
|
+
def __imul__(self, n):
|
|
176
|
+
self.x *= n
|
|
177
|
+
self.y *= n
|
|
178
|
+
self.z *= n
|
|
179
|
+
return self
|
|
180
|
+
|
|
181
|
+
def __itruediv__(self, n):
|
|
182
|
+
self.x /= n
|
|
183
|
+
self.y /= n
|
|
184
|
+
self.z /= n
|
|
185
|
+
return self
|
|
186
|
+
|
|
187
|
+
def __ipow__(self, n):
|
|
188
|
+
self.x **= n
|
|
189
|
+
self.y **= n
|
|
190
|
+
self.z **= n
|
|
191
|
+
return self
|
|
192
|
+
|
|
193
|
+
# ==========================================================================
|
|
194
|
+
# Properties
|
|
195
|
+
# ==========================================================================
|
|
196
|
+
|
|
197
|
+
@property
|
|
198
|
+
def x(self):
|
|
199
|
+
return self._x
|
|
200
|
+
|
|
201
|
+
@x.setter
|
|
202
|
+
def x(self, x):
|
|
203
|
+
self._x = float(x)
|
|
204
|
+
self._direction = None
|
|
205
|
+
self._magnitude = None
|
|
206
|
+
|
|
207
|
+
@property
|
|
208
|
+
def y(self):
|
|
209
|
+
return self._y
|
|
210
|
+
|
|
211
|
+
@y.setter
|
|
212
|
+
def y(self, y):
|
|
213
|
+
self._y = float(y)
|
|
214
|
+
self._direction = None
|
|
215
|
+
self._magnitude = None
|
|
216
|
+
|
|
217
|
+
@property
|
|
218
|
+
def z(self):
|
|
219
|
+
return self._z
|
|
220
|
+
|
|
221
|
+
@z.setter
|
|
222
|
+
def z(self, z):
|
|
223
|
+
self._z = float(z)
|
|
224
|
+
self._direction = None
|
|
225
|
+
self._magnitude = None
|
|
226
|
+
|
|
227
|
+
@property
|
|
228
|
+
def magnitude(self):
|
|
229
|
+
if self._magnitude is None:
|
|
230
|
+
self._magnitude = length_vector(self)
|
|
231
|
+
return self._magnitude
|
|
232
|
+
|
|
233
|
+
@property
|
|
234
|
+
def length(self):
|
|
235
|
+
return self.magnitude
|
|
236
|
+
|
|
237
|
+
@property
|
|
238
|
+
def direction(self):
|
|
239
|
+
if not self._direction:
|
|
240
|
+
self._direction = self.unitized()
|
|
241
|
+
return self._direction
|
|
242
|
+
|
|
243
|
+
# ==========================================================================
|
|
244
|
+
# Constructors
|
|
245
|
+
# ==========================================================================
|
|
246
|
+
|
|
247
|
+
@classmethod
|
|
248
|
+
def Xaxis(cls):
|
|
249
|
+
"""Construct a unit vector along the X axis.
|
|
250
|
+
|
|
251
|
+
Returns
|
|
252
|
+
-------
|
|
253
|
+
:class:`compas.geometry.Vector`
|
|
254
|
+
A vector with components ``x = 1.0, y = 0.0, z = 0.0``.
|
|
255
|
+
|
|
256
|
+
Examples
|
|
257
|
+
--------
|
|
258
|
+
>>> Vector.Xaxis()
|
|
259
|
+
Vector(1.000, 0.000, 0.000)
|
|
260
|
+
|
|
261
|
+
"""
|
|
262
|
+
return cls(1.0, 0.0, 0.0)
|
|
263
|
+
|
|
264
|
+
@classmethod
|
|
265
|
+
def Yaxis(cls):
|
|
266
|
+
"""Construct a unit vector along the Y axis.
|
|
267
|
+
|
|
268
|
+
Returns
|
|
269
|
+
-------
|
|
270
|
+
:class:`compas.geometry.Vector`
|
|
271
|
+
A vector with components ``x = 0.0, y = 1.0, z = 0.0``.
|
|
272
|
+
|
|
273
|
+
Examples
|
|
274
|
+
--------
|
|
275
|
+
>>> Vector.Yaxis()
|
|
276
|
+
Vector(0.000, 1.000, 0.000)
|
|
277
|
+
|
|
278
|
+
"""
|
|
279
|
+
return cls(0.0, 1.0, 0.0)
|
|
280
|
+
|
|
281
|
+
@classmethod
|
|
282
|
+
def Zaxis(cls):
|
|
283
|
+
"""Construct a unit vector along the Z axis.
|
|
284
|
+
|
|
285
|
+
Returns
|
|
286
|
+
-------
|
|
287
|
+
:class:`compas.geometry.Vector`
|
|
288
|
+
A vector with components ``x = 0.0, y = 0.0, z = 1.0``.
|
|
289
|
+
|
|
290
|
+
Examples
|
|
291
|
+
--------
|
|
292
|
+
>>> Vector.Zaxis()
|
|
293
|
+
Vector(0.000, 0.000, 1.000)
|
|
294
|
+
|
|
295
|
+
"""
|
|
296
|
+
return cls(0.0, 0.0, 1.0)
|
|
297
|
+
|
|
298
|
+
@classmethod
|
|
299
|
+
def from_start_end(cls, start, end):
|
|
300
|
+
"""Construct a vector from start and end points.
|
|
301
|
+
|
|
302
|
+
Parameters
|
|
303
|
+
----------
|
|
304
|
+
start : [float, float, float] | :class:`compas.geometry.Point`
|
|
305
|
+
The start point.
|
|
306
|
+
end : [float, float, float] | :class:`compas.geometry.Point`
|
|
307
|
+
The end point.
|
|
308
|
+
|
|
309
|
+
Returns
|
|
310
|
+
-------
|
|
311
|
+
:class:`compas.geometry.Vector`
|
|
312
|
+
The vector from start to end.
|
|
313
|
+
|
|
314
|
+
Examples
|
|
315
|
+
--------
|
|
316
|
+
>>> Vector.from_start_end([1.0, 0.0, 0.0], [1.0, 1.0, 0.0])
|
|
317
|
+
Vector(0.000, 1.000, 0.000)
|
|
318
|
+
|
|
319
|
+
"""
|
|
320
|
+
v = subtract_vectors(end, start)
|
|
321
|
+
return cls(*v)
|
|
322
|
+
|
|
323
|
+
# ==========================================================================
|
|
324
|
+
# Static
|
|
325
|
+
# ==========================================================================
|
|
326
|
+
|
|
327
|
+
@staticmethod
|
|
328
|
+
def transform_collection(collection, X):
|
|
329
|
+
"""Transform a collection of vector objects.
|
|
330
|
+
|
|
331
|
+
Parameters
|
|
332
|
+
----------
|
|
333
|
+
collection : list[[float, float, float] | :class:`compas.geometry.Vector`]
|
|
334
|
+
The collection of vectors.
|
|
335
|
+
|
|
336
|
+
Returns
|
|
337
|
+
-------
|
|
338
|
+
None
|
|
339
|
+
|
|
340
|
+
Examples
|
|
341
|
+
--------
|
|
342
|
+
>>> from compas.geometry import Rotation
|
|
343
|
+
>>> R = Rotation.from_axis_and_angle(Vector.Zaxis(), math.radians(90))
|
|
344
|
+
>>> u = Vector(1.0, 0.0, 0.0)
|
|
345
|
+
>>> vectors = [u]
|
|
346
|
+
>>> Vector.transform_collection(vectors, R)
|
|
347
|
+
>>> v = vectors[0]
|
|
348
|
+
>>> v
|
|
349
|
+
Vector(0.000, 1.000, 0.000)
|
|
350
|
+
>>> u is v
|
|
351
|
+
True
|
|
352
|
+
|
|
353
|
+
"""
|
|
354
|
+
data = transform_vectors(collection, X)
|
|
355
|
+
for vector, xyz in zip(collection, data):
|
|
356
|
+
vector.x = xyz[0]
|
|
357
|
+
vector.y = xyz[1]
|
|
358
|
+
vector.z = xyz[2]
|
|
359
|
+
|
|
360
|
+
@staticmethod
|
|
361
|
+
def transformed_collection(collection, X):
|
|
362
|
+
"""Create a collection of transformed vectors.
|
|
363
|
+
|
|
364
|
+
Parameters
|
|
365
|
+
----------
|
|
366
|
+
collection : list[[float, float, float] | :class:`compas.geometry.Vector`]
|
|
367
|
+
The collection of vectors.
|
|
368
|
+
|
|
369
|
+
Returns
|
|
370
|
+
-------
|
|
371
|
+
list[:class:`compas.geometry.Vector`]
|
|
372
|
+
The transformed vectors.
|
|
373
|
+
|
|
374
|
+
Examples
|
|
375
|
+
--------
|
|
376
|
+
>>> from compas.geometry import Rotation
|
|
377
|
+
>>> R = Rotation.from_axis_and_angle(Vector.Zaxis(), math.radians(90))
|
|
378
|
+
>>> u = Vector(1.0, 0.0, 0.0)
|
|
379
|
+
>>> vectors = [u]
|
|
380
|
+
>>> vectors = Vector.transformed_collection(vectors, R)
|
|
381
|
+
>>> v = vectors[0]
|
|
382
|
+
>>> v
|
|
383
|
+
Vector(0.000, 1.000, 0.000)
|
|
384
|
+
>>> u is v
|
|
385
|
+
False
|
|
386
|
+
|
|
387
|
+
"""
|
|
388
|
+
vectors = [vector.copy() for vector in collection]
|
|
389
|
+
Vector.transform_collection(vectors, X)
|
|
390
|
+
return vectors
|
|
391
|
+
|
|
392
|
+
@staticmethod
|
|
393
|
+
def length_vectors(vectors):
|
|
394
|
+
"""Compute the length of multiple vectors.
|
|
395
|
+
|
|
396
|
+
Parameters
|
|
397
|
+
----------
|
|
398
|
+
vectors : list[[float, float, float] | :class:`compas.geometry.Vector`]
|
|
399
|
+
A list of vectors.
|
|
400
|
+
|
|
401
|
+
Returns
|
|
402
|
+
-------
|
|
403
|
+
list[float]
|
|
404
|
+
A list of lengths.
|
|
405
|
+
|
|
406
|
+
Examples
|
|
407
|
+
--------
|
|
408
|
+
>>> Vector.length_vectors([[1.0, 0.0, 0.0], [2.0, 0.0, 0.0]])
|
|
409
|
+
[1.0, 2.0]
|
|
410
|
+
|
|
411
|
+
"""
|
|
412
|
+
return [length_vector(vector) for vector in vectors]
|
|
413
|
+
|
|
414
|
+
@staticmethod
|
|
415
|
+
def sum_vectors(vectors):
|
|
416
|
+
"""Compute the sum of multiple vectors.
|
|
417
|
+
|
|
418
|
+
Parameters
|
|
419
|
+
----------
|
|
420
|
+
vectors : list[[float, float, float] | :class:`compas.geometry.Vector`]
|
|
421
|
+
A list of vectors.
|
|
422
|
+
|
|
423
|
+
Returns
|
|
424
|
+
-------
|
|
425
|
+
:class:`compas.geometry.Vector`
|
|
426
|
+
A vector that is the sum of the vectors.
|
|
427
|
+
|
|
428
|
+
Examples
|
|
429
|
+
--------
|
|
430
|
+
>>> Vector.sum_vectors([[1.0, 0.0, 0.0], [2.0, 0.0, 0.0]])
|
|
431
|
+
Vector(3.000, 0.000, 0.000)
|
|
432
|
+
|
|
433
|
+
"""
|
|
434
|
+
return Vector(*[sum(axis) for axis in zip(*vectors)])
|
|
435
|
+
|
|
436
|
+
@staticmethod
|
|
437
|
+
def dot_vectors(left, right):
|
|
438
|
+
"""Compute the dot product of two lists of vectors.
|
|
439
|
+
|
|
440
|
+
Parameters
|
|
441
|
+
----------
|
|
442
|
+
left : list[[float, float, float] | :class:`compas.geometry.Vector`]
|
|
443
|
+
A list of vectors.
|
|
444
|
+
right : list[[float, float, float] | :class:`compas.geometry.Vector`]
|
|
445
|
+
A list of vectors.
|
|
446
|
+
|
|
447
|
+
Returns
|
|
448
|
+
-------
|
|
449
|
+
list[float]
|
|
450
|
+
A list of dot products.
|
|
451
|
+
|
|
452
|
+
Examples
|
|
453
|
+
--------
|
|
454
|
+
>>> Vector.dot_vectors([[1.0, 0.0, 0.0], [2.0, 0.0, 0.0]], [[1.0, 0.0, 0.0], [2.0, 0.0, 0.0]])
|
|
455
|
+
[1.0, 4.0]
|
|
456
|
+
|
|
457
|
+
"""
|
|
458
|
+
return [Vector.dot(u, v) for u, v in zip(left, right)]
|
|
459
|
+
|
|
460
|
+
@staticmethod
|
|
461
|
+
def cross_vectors(left, right):
|
|
462
|
+
"""Compute the cross product of two lists of vectors.
|
|
463
|
+
|
|
464
|
+
Parameters
|
|
465
|
+
----------
|
|
466
|
+
left : list[[float, float, float] | :class:`compas.geometry.Vector`]
|
|
467
|
+
A list of vectors.
|
|
468
|
+
right : list[[float, float, float] | :class:`compas.geometry.Vector`]
|
|
469
|
+
A list of vectors.
|
|
470
|
+
|
|
471
|
+
Returns
|
|
472
|
+
-------
|
|
473
|
+
list[:class:`compas.geometry.Vector`]
|
|
474
|
+
A list of cross products.
|
|
475
|
+
|
|
476
|
+
Examples
|
|
477
|
+
--------
|
|
478
|
+
>>> Vector.cross_vectors([[1.0, 0.0, 0.0], [2.0, 0.0, 0.0]], [[0.0, 1.0, 0.0], [0.0, 0.0, 2.0]])
|
|
479
|
+
[Vector(0.000, 0.000, 1.000), Vector(0.000, -4.000, 0.000)]
|
|
480
|
+
|
|
481
|
+
"""
|
|
482
|
+
# cross_vectors(u,v) from src\compas\geometry\_core\_algebra.py
|
|
483
|
+
return [Vector(*cross_vectors(u, v)) for u, v in zip(left, right)]
|
|
484
|
+
|
|
485
|
+
@staticmethod
|
|
486
|
+
def angles_vectors(left, right):
|
|
487
|
+
"""Compute both angles between corresponding pairs of two lists of vectors.
|
|
488
|
+
|
|
489
|
+
Parameters
|
|
490
|
+
----------
|
|
491
|
+
left : list[[float, float, float] | :class:`compas.geometry.Vector`]
|
|
492
|
+
A list of vectors.
|
|
493
|
+
right : list[[float, float, float] | :class:`compas.geometry.Vector`]
|
|
494
|
+
A list of vectors.
|
|
495
|
+
|
|
496
|
+
Returns
|
|
497
|
+
-------
|
|
498
|
+
list[float]
|
|
499
|
+
A list of angle pairs.
|
|
500
|
+
|
|
501
|
+
Examples
|
|
502
|
+
--------
|
|
503
|
+
>>> Vector.angles_vectors([[1.0, 0.0, 0.0], [2.0, 0.0, 0.0]], [[0.0, 1.0, 0.0], [0.0, 0.0, 2.0]])
|
|
504
|
+
[(1.5707963267948966, 4.71238898038469), (1.5707963267948966, 4.71238898038469)]
|
|
505
|
+
|
|
506
|
+
"""
|
|
507
|
+
return [angles_vectors(u, v) for u, v in zip(left, right)]
|
|
508
|
+
|
|
509
|
+
@staticmethod
|
|
510
|
+
def angle_vectors(left, right):
|
|
511
|
+
"""Compute the smallest angle between corresponding pairs of two lists of vectors.
|
|
512
|
+
|
|
513
|
+
Parameters
|
|
514
|
+
----------
|
|
515
|
+
left : list[[float, float, float] | :class:`compas.geometry.Vector`]
|
|
516
|
+
A list of vectors.
|
|
517
|
+
right : list[[float, float, float] | :class:`compas.geometry.Vector`]
|
|
518
|
+
A list of vectors.
|
|
519
|
+
|
|
520
|
+
Returns
|
|
521
|
+
-------
|
|
522
|
+
list[float]
|
|
523
|
+
A list of angles.
|
|
524
|
+
|
|
525
|
+
Examples
|
|
526
|
+
--------
|
|
527
|
+
>>> Vector.angle_vectors([[1.0, 0.0, 0.0], [2.0, 0.0, 0.0]], [[0.0, 1.0, 0.0], [0.0, 0.0, 2.0]])
|
|
528
|
+
[1.5707963267948966, 1.5707963267948966]
|
|
529
|
+
|
|
530
|
+
"""
|
|
531
|
+
return [angle_vectors(u, v) for u, v in zip(left, right)]
|
|
532
|
+
|
|
533
|
+
# ==========================================================================
|
|
534
|
+
# Helpers
|
|
535
|
+
# ==========================================================================
|
|
536
|
+
|
|
537
|
+
def copy(self):
|
|
538
|
+
"""Make a copy of this vector.
|
|
539
|
+
|
|
540
|
+
Returns
|
|
541
|
+
-------
|
|
542
|
+
:class:`compas.geometry.Vector`
|
|
543
|
+
The copy.
|
|
544
|
+
|
|
545
|
+
Examples
|
|
546
|
+
--------
|
|
547
|
+
>>> u = Vector(0.0, 0.0, 0.0)
|
|
548
|
+
>>> v = u.copy()
|
|
549
|
+
>>> u == v
|
|
550
|
+
True
|
|
551
|
+
>>> u is v
|
|
552
|
+
False
|
|
553
|
+
|
|
554
|
+
"""
|
|
555
|
+
cls = type(self)
|
|
556
|
+
return cls(self.x, self.y, self.z)
|
|
557
|
+
|
|
558
|
+
# ==========================================================================
|
|
559
|
+
# Methods
|
|
560
|
+
# ==========================================================================
|
|
561
|
+
|
|
562
|
+
def unitize(self):
|
|
563
|
+
"""Scale this vector to unit length.
|
|
564
|
+
|
|
565
|
+
Returns
|
|
566
|
+
-------
|
|
567
|
+
None
|
|
568
|
+
|
|
569
|
+
Examples
|
|
570
|
+
--------
|
|
571
|
+
>>> u = Vector(1.0, 2.0, 3.0)
|
|
572
|
+
>>> u.unitize()
|
|
573
|
+
>>> u.length
|
|
574
|
+
1.0
|
|
575
|
+
|
|
576
|
+
"""
|
|
577
|
+
length = self.length
|
|
578
|
+
self.x = self.x / length
|
|
579
|
+
self.y = self.y / length
|
|
580
|
+
self.z = self.z / length
|
|
581
|
+
|
|
582
|
+
def unitized(self):
|
|
583
|
+
"""Returns a unitized copy of this vector.
|
|
584
|
+
|
|
585
|
+
Returns
|
|
586
|
+
-------
|
|
587
|
+
:class:`compas.geometry.Vector`
|
|
588
|
+
A unitized copy of the vector.
|
|
589
|
+
|
|
590
|
+
Examples
|
|
591
|
+
--------
|
|
592
|
+
>>> u = Vector(1.0, 2.0, 3.0)
|
|
593
|
+
>>> v = u.unitized()
|
|
594
|
+
>>> u.length == 1.0
|
|
595
|
+
False
|
|
596
|
+
>>> v.length == 1.0
|
|
597
|
+
True
|
|
598
|
+
|
|
599
|
+
"""
|
|
600
|
+
v = self.copy()
|
|
601
|
+
v.unitize()
|
|
602
|
+
return v
|
|
603
|
+
|
|
604
|
+
def invert(self):
|
|
605
|
+
"""Invert the direction of this vector
|
|
606
|
+
|
|
607
|
+
Returns
|
|
608
|
+
-------
|
|
609
|
+
None
|
|
610
|
+
|
|
611
|
+
Notes
|
|
612
|
+
-----
|
|
613
|
+
a negation of a vector is similar to inverting a vector
|
|
614
|
+
|
|
615
|
+
Examples
|
|
616
|
+
--------
|
|
617
|
+
>>> u = Vector(1.0, 0.0, 0.0)
|
|
618
|
+
>>> v = u.copy()
|
|
619
|
+
>>> u.invert()
|
|
620
|
+
>>> u == v
|
|
621
|
+
False
|
|
622
|
+
>>> u.invert()
|
|
623
|
+
>>> u == v
|
|
624
|
+
True
|
|
625
|
+
>>> v == --v
|
|
626
|
+
True
|
|
627
|
+
|
|
628
|
+
"""
|
|
629
|
+
self.scale(-1.0)
|
|
630
|
+
|
|
631
|
+
def inverted(self):
|
|
632
|
+
"""Returns a inverted copy of this vector
|
|
633
|
+
|
|
634
|
+
Returns
|
|
635
|
+
-------
|
|
636
|
+
:class:`compas.geometry.Vector`
|
|
637
|
+
|
|
638
|
+
Examples
|
|
639
|
+
--------
|
|
640
|
+
>>> u = Vector(1.0, 0.0, 0.0)
|
|
641
|
+
>>> v = u.inverted()
|
|
642
|
+
>>> w = u + v
|
|
643
|
+
>>> w.length
|
|
644
|
+
0.0
|
|
645
|
+
|
|
646
|
+
"""
|
|
647
|
+
return self.scaled(-1.0)
|
|
648
|
+
|
|
649
|
+
def scale(self, n):
|
|
650
|
+
"""Scale this vector by a factor n.
|
|
651
|
+
|
|
652
|
+
Parameters
|
|
653
|
+
----------
|
|
654
|
+
n : float
|
|
655
|
+
The scaling factor.
|
|
656
|
+
|
|
657
|
+
Returns
|
|
658
|
+
-------
|
|
659
|
+
None
|
|
660
|
+
|
|
661
|
+
Examples
|
|
662
|
+
--------
|
|
663
|
+
>>> u = Vector(1.0, 0.0, 0.0)
|
|
664
|
+
>>> u.scale(3.0)
|
|
665
|
+
>>> u.length
|
|
666
|
+
3.0
|
|
667
|
+
|
|
668
|
+
"""
|
|
669
|
+
self.x *= n
|
|
670
|
+
self.y *= n
|
|
671
|
+
self.z *= n
|
|
672
|
+
|
|
673
|
+
def scaled(self, n):
|
|
674
|
+
"""Returns a scaled copy of this vector.
|
|
675
|
+
|
|
676
|
+
Parameters
|
|
677
|
+
----------
|
|
678
|
+
n : float
|
|
679
|
+
The scaling factor.
|
|
680
|
+
|
|
681
|
+
Returns
|
|
682
|
+
-------
|
|
683
|
+
:class:`compas.geometry.Vector`
|
|
684
|
+
A scaled copy of the vector.
|
|
685
|
+
|
|
686
|
+
Examples
|
|
687
|
+
--------
|
|
688
|
+
>>> u = Vector(1.0, 0.0, 0.0)
|
|
689
|
+
>>> v = u.scaled(3.0)
|
|
690
|
+
>>> u.length
|
|
691
|
+
1.0
|
|
692
|
+
>>> v.length
|
|
693
|
+
3.0
|
|
694
|
+
|
|
695
|
+
"""
|
|
696
|
+
v = self.copy()
|
|
697
|
+
v.scale(n)
|
|
698
|
+
return v
|
|
699
|
+
|
|
700
|
+
def dot(self, other):
|
|
701
|
+
"""The dot product of this vector and another vector.
|
|
702
|
+
|
|
703
|
+
Parameters
|
|
704
|
+
----------
|
|
705
|
+
other : [float, float, float] | :class:`compas.geometry.Vector`
|
|
706
|
+
The other vector.
|
|
707
|
+
|
|
708
|
+
Returns
|
|
709
|
+
-------
|
|
710
|
+
float
|
|
711
|
+
The dot product.
|
|
712
|
+
|
|
713
|
+
Examples
|
|
714
|
+
--------
|
|
715
|
+
>>> u = Vector(1.0, 0.0, 0.0)
|
|
716
|
+
>>> v = Vector(0.0, 1.0, 0.0)
|
|
717
|
+
>>> u.dot(v)
|
|
718
|
+
0.0
|
|
719
|
+
|
|
720
|
+
"""
|
|
721
|
+
return dot_vectors(self, other)
|
|
722
|
+
|
|
723
|
+
def cross(self, other):
|
|
724
|
+
"""The cross product of this vector and another vector.
|
|
725
|
+
|
|
726
|
+
Parameters
|
|
727
|
+
----------
|
|
728
|
+
other : [float, float, float] | :class:`compas.geometry.Vector`
|
|
729
|
+
The other vector.
|
|
730
|
+
|
|
731
|
+
Returns
|
|
732
|
+
-------
|
|
733
|
+
:class:`compas.geometry.Vector`
|
|
734
|
+
The cross product.
|
|
735
|
+
|
|
736
|
+
Examples
|
|
737
|
+
--------
|
|
738
|
+
>>> u = Vector(1.0, 0.0, 0.0)
|
|
739
|
+
>>> v = Vector(0.0, 1.0, 0.0)
|
|
740
|
+
>>> u.cross(v)
|
|
741
|
+
Vector(0.000, 0.000, 1.000)
|
|
742
|
+
|
|
743
|
+
"""
|
|
744
|
+
return Vector(*cross_vectors(self, other))
|
|
745
|
+
|
|
746
|
+
def angle(self, other, degrees=False):
|
|
747
|
+
"""Compute the smallest angle between this vector and another vector.
|
|
748
|
+
|
|
749
|
+
Parameters
|
|
750
|
+
----------
|
|
751
|
+
other : [float, float, float] | :class:`compas.geometry.Vector`
|
|
752
|
+
The other vector.
|
|
753
|
+
|
|
754
|
+
Returns
|
|
755
|
+
-------
|
|
756
|
+
float
|
|
757
|
+
The smallest angle between the two vectors.
|
|
758
|
+
|
|
759
|
+
Examples
|
|
760
|
+
--------
|
|
761
|
+
>>> u = Vector(1.0, 0.0, 0.0)
|
|
762
|
+
>>> v = Vector(0.0, 1.0, 0.0)
|
|
763
|
+
>>> u.angle(v) == 0.5 * math.pi
|
|
764
|
+
True
|
|
765
|
+
|
|
766
|
+
"""
|
|
767
|
+
return angle_vectors(self, other, deg=degrees)
|
|
768
|
+
|
|
769
|
+
def angle_signed(self, other, normal):
|
|
770
|
+
"""Compute the signed angle between this vector and another vector.
|
|
771
|
+
|
|
772
|
+
Parameters
|
|
773
|
+
----------
|
|
774
|
+
other : [float, float, float] | :class:`compas.geometry.Vector`
|
|
775
|
+
The other vector.
|
|
776
|
+
normal : [float, float, float] | :class:`compas.geometry.Vector`
|
|
777
|
+
The plane's normal spanned by this and the other vector.
|
|
778
|
+
|
|
779
|
+
Returns
|
|
780
|
+
-------
|
|
781
|
+
float
|
|
782
|
+
The signed angle between the two vectors.
|
|
783
|
+
|
|
784
|
+
Examples
|
|
785
|
+
--------
|
|
786
|
+
>>> u = Vector(1.0, 0.0, 0.0)
|
|
787
|
+
>>> v = Vector(0.0, 1.0, 0.0)
|
|
788
|
+
>>> u.angle_signed(v, Vector(0.0, 0.0, 1.0)) == 0.5 * math.pi
|
|
789
|
+
True
|
|
790
|
+
>>> u.angle_signed(v, Vector(0.0, 0.0, -1.0)) == -0.5 * math.pi
|
|
791
|
+
True
|
|
792
|
+
|
|
793
|
+
"""
|
|
794
|
+
return angle_vectors_signed(self, other, normal)
|
|
795
|
+
|
|
796
|
+
def angles(self, other):
|
|
797
|
+
"""Compute both angles between this vector and another vector.
|
|
798
|
+
|
|
799
|
+
Parameters
|
|
800
|
+
----------
|
|
801
|
+
other : [float, float, float] | :class:`compas.geometry.Vector`
|
|
802
|
+
The other vector.
|
|
803
|
+
|
|
804
|
+
Returns
|
|
805
|
+
-------
|
|
806
|
+
tuple[float, float]
|
|
807
|
+
The angles between the two vectors, with the smallest angle first.
|
|
808
|
+
|
|
809
|
+
Examples
|
|
810
|
+
--------
|
|
811
|
+
>>> u = Vector(1.0, 0.0, 0.0)
|
|
812
|
+
>>> v = Vector(0.0, 1.0, 0.0)
|
|
813
|
+
>>> u.angles(v)[0] == 0.5 * math.pi
|
|
814
|
+
True
|
|
815
|
+
|
|
816
|
+
"""
|
|
817
|
+
return angles_vectors(self, other)
|
|
818
|
+
|
|
819
|
+
def component(self, other):
|
|
820
|
+
"""Compute the component of this vector in the direction of another vector.
|
|
821
|
+
|
|
822
|
+
Parameters
|
|
823
|
+
----------
|
|
824
|
+
other : [float, float, float] | :class:`compas.geometry.Vector`
|
|
825
|
+
|
|
826
|
+
Returns
|
|
827
|
+
-------
|
|
828
|
+
:class:`compas.geometry.Vector`
|
|
829
|
+
|
|
830
|
+
"""
|
|
831
|
+
cosa = self.dot(other)
|
|
832
|
+
component = Vector(other[0], other[1], other[2])
|
|
833
|
+
L = component.length
|
|
834
|
+
component.scale(cosa / L)
|
|
835
|
+
return component
|
|
836
|
+
|
|
837
|
+
def transform(self, T):
|
|
838
|
+
"""Transform this vector.
|
|
839
|
+
|
|
840
|
+
Parameters
|
|
841
|
+
----------
|
|
842
|
+
T : :class:`compas.geometry.Transformation` | list[list[float]]
|
|
843
|
+
The transformation.
|
|
844
|
+
|
|
845
|
+
Returns
|
|
846
|
+
-------
|
|
847
|
+
None
|
|
848
|
+
|
|
849
|
+
Examples
|
|
850
|
+
--------
|
|
851
|
+
>>> from compas.geometry import Rotation
|
|
852
|
+
>>> u = Vector(1.0, 0.0, 0.0)
|
|
853
|
+
>>> R = Rotation.from_axis_and_angle([0.0, 0.0, 1.0], math.radians(90))
|
|
854
|
+
>>> u.transform(R)
|
|
855
|
+
>>> u
|
|
856
|
+
Vector(0.000, 1.000, 0.000)
|
|
857
|
+
|
|
858
|
+
"""
|
|
859
|
+
point = transform_vectors([self], T)[0]
|
|
860
|
+
self.x = point[0]
|
|
861
|
+
self.y = point[1]
|
|
862
|
+
self.z = point[2]
|
|
863
|
+
|
|
864
|
+
def transformed(self, T):
|
|
865
|
+
"""Return a transformed copy of this vector.
|
|
866
|
+
|
|
867
|
+
Parameters
|
|
868
|
+
----------
|
|
869
|
+
T : :class:`compas.geometry.Transformation` | list[list[float]]
|
|
870
|
+
The transformation.
|
|
871
|
+
|
|
872
|
+
Returns
|
|
873
|
+
-------
|
|
874
|
+
:class:`compas.geometry.Vector`
|
|
875
|
+
The transformed copy.
|
|
876
|
+
|
|
877
|
+
Examples
|
|
878
|
+
--------
|
|
879
|
+
>>> from compas.geometry import Rotation
|
|
880
|
+
>>> u = Vector(1.0, 0.0, 0.0)
|
|
881
|
+
>>> R = Rotation.from_axis_and_angle([0.0, 0.0, 1.0], math.radians(90))
|
|
882
|
+
>>> v = u.transformed(R)
|
|
883
|
+
>>> v
|
|
884
|
+
Vector(0.000, 1.000, 0.000)
|
|
885
|
+
|
|
886
|
+
"""
|
|
887
|
+
vector = self.copy()
|
|
888
|
+
vector.transform(T)
|
|
889
|
+
return vector
|