snappy 3.0.3__cp38-cp38-macosx_11_0_arm64.whl → 3.2__cp38-cp38-macosx_11_0_arm64.whl
Sign up to get free protection for your applications and to get access to all the features.
- snappy/CyOpenGL.cpython-38-darwin.so +0 -0
- snappy/SnapPy.cpython-38-darwin.so +0 -0
- snappy/SnapPyHP.cpython-38-darwin.so +0 -0
- snappy/__init__.py +373 -426
- snappy/app.py +240 -75
- snappy/app_menus.py +93 -78
- snappy/browser.py +87 -63
- snappy/cache.py +5 -8
- snappy/canonical.py +249 -0
- snappy/{verify/cusp_shapes.py → cusps/__init__.py} +11 -19
- snappy/cusps/cusp_area_matrix.py +101 -0
- snappy/{verify/cusp_areas.py → cusps/cusp_areas_from_matrix.py} +39 -54
- snappy/cusps/maximal_cusp_area_matrix.py +136 -0
- snappy/cusps/test.py +21 -0
- snappy/cusps/trig_cusp_area_matrix.py +63 -0
- snappy/database.py +40 -31
- snappy/db_utilities.py +13 -14
- snappy/decorated_isosig.py +377 -133
- snappy/dev/extended_ptolemy/complexVolumesClosed.py +42 -9
- snappy/dev/extended_ptolemy/extended.py +32 -25
- snappy/dev/extended_ptolemy/giac_rur.py +23 -8
- snappy/dev/extended_ptolemy/phc_wrapper.py +10 -10
- snappy/dev/vericlosed/computeApproxHyperbolicStructureOrb.py +2 -1
- snappy/dev/vericlosed/gimbalLoopFinder.py +5 -5
- snappy/dev/vericlosed/hyperbolicStructure.py +3 -3
- snappy/dev/vericlosed/oneVertexTruncatedComplex.py +2 -2
- snappy/dev/vericlosed/truncatedComplex.py +3 -2
- snappy/dev/vericlosed/verifyHyperbolicStructureEngine.py +4 -3
- snappy/doc/_images/geodesics.jpg +0 -0
- snappy/doc/_images/m004_paper_plane_on_systole.jpg +0 -0
- snappy/doc/_images/m125_paper_plane.jpg +0 -0
- snappy/doc/_images/o9_00000_systole_paper_plane.jpg +0 -0
- snappy/doc/_images/o9_00000_systole_paper_plane_closer.jpg +0 -0
- snappy/doc/_sources/additional_classes.rst.txt +1 -0
- snappy/doc/_sources/credits.rst.txt +6 -1
- snappy/doc/_sources/development.rst.txt +69 -50
- snappy/doc/_sources/index.rst.txt +101 -66
- snappy/doc/_sources/installing.rst.txt +148 -165
- snappy/doc/_sources/news.rst.txt +136 -32
- snappy/doc/_sources/ptolemy.rst.txt +1 -1
- snappy/doc/_sources/ptolemy_examples1.rst.txt +9 -8
- snappy/doc/_sources/ptolemy_examples2.rst.txt +3 -3
- snappy/doc/_sources/ptolemy_examples3.rst.txt +14 -14
- snappy/doc/_sources/ptolemy_prelim.rst.txt +1 -1
- snappy/doc/_sources/snap.rst.txt +2 -2
- snappy/doc/_sources/snappy.rst.txt +1 -1
- snappy/doc/_sources/triangulation.rst.txt +3 -2
- snappy/doc/_sources/verify.rst.txt +89 -29
- snappy/doc/_sources/verify_internals.rst.txt +5 -16
- snappy/doc/_static/SnapPy-horizontal-128.png +0 -0
- snappy/doc/_static/SnapPy.ico +0 -0
- snappy/doc/_static/_sphinx_javascript_frameworks_compat.js +123 -0
- snappy/doc/_static/basic.css +47 -27
- snappy/doc/_static/css/badge_only.css +1 -0
- snappy/doc/_static/css/fonts/Roboto-Slab-Bold.woff +0 -0
- snappy/doc/_static/css/fonts/Roboto-Slab-Bold.woff2 +0 -0
- snappy/doc/_static/css/fonts/Roboto-Slab-Regular.woff +0 -0
- snappy/doc/_static/css/fonts/Roboto-Slab-Regular.woff2 +0 -0
- snappy/doc/_static/css/fonts/fontawesome-webfont.eot +0 -0
- snappy/doc/_static/css/fonts/fontawesome-webfont.svg +2671 -0
- snappy/doc/_static/css/fonts/fontawesome-webfont.ttf +0 -0
- snappy/doc/_static/css/fonts/fontawesome-webfont.woff +0 -0
- snappy/doc/_static/css/fonts/fontawesome-webfont.woff2 +0 -0
- snappy/doc/_static/css/fonts/lato-bold-italic.woff +0 -0
- snappy/doc/_static/css/fonts/lato-bold-italic.woff2 +0 -0
- snappy/doc/_static/css/fonts/lato-bold.woff +0 -0
- snappy/doc/_static/css/fonts/lato-bold.woff2 +0 -0
- snappy/doc/_static/css/fonts/lato-normal-italic.woff +0 -0
- snappy/doc/_static/css/fonts/lato-normal-italic.woff2 +0 -0
- snappy/doc/_static/css/fonts/lato-normal.woff +0 -0
- snappy/doc/_static/css/fonts/lato-normal.woff2 +0 -0
- snappy/doc/_static/css/theme.css +4 -0
- snappy/doc/_static/doctools.js +107 -274
- snappy/doc/_static/documentation_options.js +6 -5
- snappy/doc/_static/fonts/Lato/lato-bold.eot +0 -0
- snappy/doc/_static/fonts/Lato/lato-bold.ttf +0 -0
- snappy/doc/_static/fonts/Lato/lato-bold.woff +0 -0
- snappy/doc/_static/fonts/Lato/lato-bold.woff2 +0 -0
- snappy/doc/_static/fonts/Lato/lato-bolditalic.eot +0 -0
- snappy/doc/_static/fonts/Lato/lato-bolditalic.ttf +0 -0
- snappy/doc/_static/fonts/Lato/lato-bolditalic.woff +0 -0
- snappy/doc/_static/fonts/Lato/lato-bolditalic.woff2 +0 -0
- snappy/doc/_static/fonts/Lato/lato-italic.eot +0 -0
- snappy/doc/_static/fonts/Lato/lato-italic.ttf +0 -0
- snappy/doc/_static/fonts/Lato/lato-italic.woff +0 -0
- snappy/doc/_static/fonts/Lato/lato-italic.woff2 +0 -0
- snappy/doc/_static/fonts/Lato/lato-regular.eot +0 -0
- snappy/doc/_static/fonts/Lato/lato-regular.ttf +0 -0
- snappy/doc/_static/fonts/Lato/lato-regular.woff +0 -0
- snappy/doc/_static/fonts/Lato/lato-regular.woff2 +0 -0
- snappy/doc/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot +0 -0
- snappy/doc/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf +0 -0
- snappy/doc/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff +0 -0
- snappy/doc/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2 +0 -0
- snappy/doc/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot +0 -0
- snappy/doc/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf +0 -0
- snappy/doc/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff +0 -0
- snappy/doc/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2 +0 -0
- snappy/doc/_static/jquery.js +2 -2
- snappy/doc/_static/js/badge_only.js +1 -0
- snappy/doc/_static/js/theme.js +1 -0
- snappy/doc/_static/js/versions.js +228 -0
- snappy/doc/_static/language_data.js +3 -101
- snappy/doc/_static/pygments.css +1 -0
- snappy/doc/_static/searchtools.js +489 -398
- snappy/doc/_static/snappy_furo.css +33 -0
- snappy/doc/_static/snappy_sphinx_rtd_theme.css +42 -0
- snappy/doc/_static/sphinx_highlight.js +154 -0
- snappy/doc/additional_classes.html +688 -263
- snappy/doc/bugs.html +107 -94
- snappy/doc/censuses.html +155 -127
- snappy/doc/credits.html +115 -104
- snappy/doc/development.html +184 -146
- snappy/doc/genindex.html +287 -204
- snappy/doc/index.html +189 -150
- snappy/doc/installing.html +259 -266
- snappy/doc/manifold.html +1626 -592
- snappy/doc/manifoldhp.html +119 -105
- snappy/doc/news.html +198 -104
- snappy/doc/objects.inv +0 -0
- snappy/doc/other.html +117 -105
- snappy/doc/platonic_census.html +161 -114
- snappy/doc/plink.html +113 -105
- snappy/doc/ptolemy.html +131 -108
- snappy/doc/ptolemy_classes.html +242 -223
- snappy/doc/ptolemy_examples1.html +144 -130
- snappy/doc/ptolemy_examples2.html +141 -129
- snappy/doc/ptolemy_examples3.html +148 -132
- snappy/doc/ptolemy_examples4.html +131 -111
- snappy/doc/ptolemy_prelim.html +162 -138
- snappy/doc/py-modindex.html +104 -69
- snappy/doc/screenshots.html +117 -108
- snappy/doc/search.html +115 -84
- snappy/doc/searchindex.js +1 -1
- snappy/doc/snap.html +109 -96
- snappy/doc/snappy.html +134 -97
- snappy/doc/spherogram.html +259 -187
- snappy/doc/todo.html +107 -94
- snappy/doc/triangulation.html +1380 -111
- snappy/doc/tutorial.html +107 -94
- snappy/doc/verify.html +194 -125
- snappy/doc/verify_internals.html +248 -686
- snappy/drilling/__init__.py +456 -0
- snappy/drilling/barycentric.py +103 -0
- snappy/drilling/constants.py +5 -0
- snappy/drilling/crush.py +270 -0
- snappy/drilling/cusps.py +125 -0
- snappy/drilling/debug.py +242 -0
- snappy/drilling/epsilons.py +6 -0
- snappy/drilling/exceptions.py +55 -0
- snappy/drilling/moves.py +620 -0
- snappy/drilling/peripheral_curves.py +210 -0
- snappy/drilling/perturb.py +188 -0
- snappy/drilling/shorten.py +36 -0
- snappy/drilling/subdivide.py +274 -0
- snappy/drilling/test.py +23 -0
- snappy/drilling/test_cases.py +126 -0
- snappy/drilling/tracing.py +351 -0
- snappy/exceptions.py +23 -3
- snappy/export_stl.py +20 -14
- snappy/exterior_to_link/__init__.py +2 -0
- snappy/exterior_to_link/barycentric_geometry.py +463 -0
- snappy/exterior_to_link/exceptions.py +6 -0
- snappy/exterior_to_link/geodesic_map.json +14408 -0
- snappy/exterior_to_link/hyp_utils.py +112 -0
- snappy/exterior_to_link/link_projection.py +323 -0
- snappy/exterior_to_link/main.py +197 -0
- snappy/exterior_to_link/mcomplex_with_expansion.py +261 -0
- snappy/exterior_to_link/mcomplex_with_link.py +687 -0
- snappy/exterior_to_link/mcomplex_with_memory.py +162 -0
- snappy/exterior_to_link/pl_utils.py +491 -0
- snappy/exterior_to_link/put_in_S3.py +156 -0
- snappy/exterior_to_link/rational_linear_algebra.py +123 -0
- snappy/exterior_to_link/rational_linear_algebra_wrapped.py +135 -0
- snappy/exterior_to_link/simplify_to_base_tri.py +114 -0
- snappy/exterior_to_link/stored_moves.py +475 -0
- snappy/exterior_to_link/test.py +31 -0
- snappy/geometric_structure/__init__.py +212 -0
- snappy/geometric_structure/cusp_neighborhood/__init__.py +3 -0
- snappy/geometric_structure/cusp_neighborhood/complex_cusp_cross_section.py +697 -0
- snappy/geometric_structure/cusp_neighborhood/cusp_cross_section_base.py +484 -0
- snappy/geometric_structure/cusp_neighborhood/exceptions.py +42 -0
- snappy/geometric_structure/cusp_neighborhood/real_cusp_cross_section.py +298 -0
- snappy/geometric_structure/cusp_neighborhood/tiles_for_cusp_neighborhood.py +159 -0
- snappy/geometric_structure/cusp_neighborhood/vertices.py +32 -0
- snappy/geometric_structure/geodesic/__init__.py +0 -0
- snappy/geometric_structure/geodesic/add_core_curves.py +152 -0
- snappy/geometric_structure/geodesic/avoid_core_curves.py +369 -0
- snappy/geometric_structure/geodesic/canonical_keys.py +52 -0
- snappy/geometric_structure/geodesic/check_away_from_core_curve.py +60 -0
- snappy/geometric_structure/geodesic/constants.py +6 -0
- snappy/geometric_structure/geodesic/exceptions.py +22 -0
- snappy/geometric_structure/geodesic/fixed_points.py +93 -0
- snappy/geometric_structure/geodesic/geodesic_start_point_info.py +435 -0
- snappy/geometric_structure/geodesic/graph_trace_helper.py +67 -0
- snappy/geometric_structure/geodesic/line.py +30 -0
- snappy/geometric_structure/geodesic/multiplicity.py +127 -0
- snappy/geometric_structure/geodesic/tiles_for_geodesic.py +101 -0
- snappy/geometric_structure/test.py +22 -0
- snappy/gui.py +36 -36
- snappy/horoviewer.py +50 -48
- snappy/hyperboloid/__init__.py +212 -0
- snappy/hyperboloid/distances.py +245 -0
- snappy/hyperboloid/horoball.py +19 -0
- snappy/hyperboloid/line.py +35 -0
- snappy/hyperboloid/point.py +9 -0
- snappy/hyperboloid/triangle.py +29 -0
- snappy/{infodialog.py → infowindow.py} +32 -33
- snappy/isometry_signature.py +382 -0
- snappy/len_spec/__init__.py +596 -0
- snappy/len_spec/geodesic_info.py +110 -0
- snappy/len_spec/geodesic_key_info_dict.py +117 -0
- snappy/len_spec/geodesic_piece.py +143 -0
- snappy/len_spec/geometric_structure.py +182 -0
- snappy/len_spec/geometry.py +80 -0
- snappy/len_spec/length_spectrum_geodesic_info.py +170 -0
- snappy/len_spec/spine.py +206 -0
- snappy/len_spec/test.py +24 -0
- snappy/len_spec/test_cases.py +69 -0
- snappy/len_spec/tile.py +275 -0
- snappy/len_spec/word.py +86 -0
- snappy/manifolds/__init__.py +1 -1
- snappy/math_basics.py +176 -0
- snappy/matrix.py +525 -0
- snappy/number.py +97 -21
- snappy/numeric_output_checker.py +37 -27
- snappy/pari.py +30 -69
- snappy/phone_home.py +25 -20
- snappy/polyviewer.py +39 -37
- snappy/ptolemy/__init__.py +4 -6
- snappy/ptolemy/component.py +14 -12
- snappy/ptolemy/coordinates.py +312 -295
- snappy/ptolemy/fieldExtensions.py +14 -12
- snappy/ptolemy/findLoops.py +43 -31
- snappy/ptolemy/geometricRep.py +24 -26
- snappy/ptolemy/homology.py +12 -7
- snappy/ptolemy/manifoldMethods.py +69 -70
- snappy/ptolemy/matrix.py +65 -26
- snappy/ptolemy/numericalSolutionsToGroebnerBasis.py +18 -14
- snappy/ptolemy/polynomial.py +125 -119
- snappy/ptolemy/processComponents.py +36 -30
- snappy/ptolemy/processFileBase.py +79 -18
- snappy/ptolemy/processFileDispatch.py +13 -14
- snappy/ptolemy/processMagmaFile.py +44 -39
- snappy/ptolemy/processRurFile.py +18 -11
- snappy/ptolemy/ptolemyGeneralizedObstructionClass.py +20 -17
- snappy/ptolemy/ptolemyObstructionClass.py +13 -17
- snappy/ptolemy/ptolemyVariety.py +190 -121
- snappy/ptolemy/ptolemyVarietyPrimeIdealGroebnerBasis.py +20 -19
- snappy/ptolemy/reginaWrapper.py +25 -29
- snappy/ptolemy/rur.py +6 -14
- snappy/ptolemy/solutionsToPrimeIdealGroebnerBasis.py +27 -22
- snappy/ptolemy/test.py +247 -188
- snappy/ptolemy/utilities.py +41 -43
- snappy/raytracing/__init__.py +64 -0
- snappy/raytracing/additional_horospheres.py +64 -0
- snappy/raytracing/additional_len_spec_choices.py +63 -0
- snappy/raytracing/cohomology_fractal.py +10 -6
- snappy/raytracing/eyeball.py +123 -0
- snappy/raytracing/finite_raytracing_data.py +48 -38
- snappy/raytracing/finite_viewer.py +218 -210
- snappy/raytracing/geodesic_tube_info.py +174 -0
- snappy/raytracing/geodesics.py +246 -0
- snappy/raytracing/geodesics_window.py +258 -0
- snappy/raytracing/gui_utilities.py +152 -40
- snappy/raytracing/hyperboloid_navigation.py +102 -52
- snappy/raytracing/hyperboloid_utilities.py +114 -261
- snappy/raytracing/ideal_raytracing_data.py +256 -179
- snappy/raytracing/inside_viewer.py +522 -253
- snappy/raytracing/pack.py +22 -0
- snappy/raytracing/raytracing_data.py +46 -34
- snappy/raytracing/raytracing_view.py +190 -109
- snappy/raytracing/shaders/Eye.png +0 -0
- snappy/raytracing/shaders/NonGeometric.png +0 -0
- snappy/raytracing/shaders/__init__.py +60 -4
- snappy/raytracing/shaders/fragment.glsl +575 -148
- snappy/raytracing/test.py +29 -0
- snappy/raytracing/tooltip.py +146 -0
- snappy/raytracing/upper_halfspace_utilities.py +98 -0
- snappy/raytracing/view_scale_controller.py +98 -0
- snappy/raytracing/zoom_slider/__init__.py +32 -29
- snappy/raytracing/zoom_slider/test.py +2 -0
- snappy/sage_helper.py +69 -123
- snappy/{preferences.py → settings.py} +167 -145
- snappy/shell.py +4 -0
- snappy/snap/__init__.py +12 -8
- snappy/snap/character_varieties.py +24 -18
- snappy/snap/find_field.py +35 -34
- snappy/snap/fundamental_polyhedron.py +99 -85
- snappy/snap/generators.py +6 -8
- snappy/snap/interval_reps.py +18 -6
- snappy/snap/kernel_structures.py +8 -3
- snappy/snap/mcomplex_base.py +1 -2
- snappy/snap/nsagetools.py +107 -53
- snappy/snap/peripheral/__init__.py +1 -1
- snappy/snap/peripheral/dual_cellulation.py +15 -7
- snappy/snap/peripheral/link.py +20 -16
- snappy/snap/peripheral/peripheral.py +22 -14
- snappy/snap/peripheral/surface.py +47 -50
- snappy/snap/peripheral/test.py +8 -8
- snappy/snap/polished_reps.py +65 -40
- snappy/snap/shapes.py +41 -22
- snappy/snap/slice_obs_HKL.py +64 -25
- snappy/snap/t3mlite/arrow.py +88 -51
- snappy/snap/t3mlite/corner.py +5 -6
- snappy/snap/t3mlite/edge.py +32 -21
- snappy/snap/t3mlite/face.py +7 -9
- snappy/snap/t3mlite/files.py +31 -23
- snappy/snap/t3mlite/homology.py +14 -10
- snappy/snap/t3mlite/linalg.py +158 -56
- snappy/snap/t3mlite/mcomplex.py +739 -291
- snappy/snap/t3mlite/perm4.py +236 -84
- snappy/snap/t3mlite/setup.py +9 -10
- snappy/snap/t3mlite/simplex.py +65 -48
- snappy/snap/t3mlite/spun.py +42 -30
- snappy/snap/t3mlite/surface.py +45 -45
- snappy/snap/t3mlite/test.py +3 -0
- snappy/snap/t3mlite/test_vs_regina.py +17 -13
- snappy/snap/t3mlite/tetrahedron.py +25 -24
- snappy/snap/t3mlite/vertex.py +8 -13
- snappy/snap/test.py +45 -52
- snappy/snap/utilities.py +66 -65
- snappy/test.py +155 -158
- snappy/test_cases.py +263 -0
- snappy/testing.py +131 -0
- snappy/tiling/__init__.py +2 -0
- snappy/tiling/canonical_key_dict.py +59 -0
- snappy/tiling/dict_based_set.py +79 -0
- snappy/tiling/floor.py +49 -0
- snappy/tiling/hyperboloid_dict.py +54 -0
- snappy/tiling/iter_utils.py +78 -0
- snappy/tiling/lifted_tetrahedron.py +22 -0
- snappy/tiling/lifted_tetrahedron_set.py +54 -0
- snappy/tiling/real_hash_dict.py +164 -0
- snappy/tiling/test.py +23 -0
- snappy/tiling/tile.py +215 -0
- snappy/tiling/triangle.py +33 -0
- snappy/tkterminal.py +313 -203
- snappy/twister/main.py +1 -8
- snappy/twister/twister_core.cpython-38-darwin.so +0 -0
- snappy/upper_halfspace/__init__.py +146 -0
- snappy/upper_halfspace/ideal_point.py +26 -0
- snappy/verify/__init__.py +4 -8
- snappy/verify/{verifyCanonical.py → canonical.py} +114 -97
- snappy/verify/complex_volume/__init__.py +3 -2
- snappy/verify/complex_volume/adjust_torsion.py +13 -11
- snappy/verify/complex_volume/closed.py +29 -24
- snappy/verify/complex_volume/compute_ptolemys.py +8 -6
- snappy/verify/complex_volume/cusped.py +10 -9
- snappy/verify/complex_volume/extended_bloch.py +14 -12
- snappy/verify/{cuspTranslations.py → cusp_translations.py} +15 -14
- snappy/verify/edge_equations.py +80 -0
- snappy/verify/exceptions.py +23 -56
- snappy/verify/{verifyHyperbolicity.py → hyperbolicity.py} +19 -15
- snappy/verify/interval_newton_shapes_engine.py +51 -211
- snappy/verify/interval_tree.py +27 -25
- snappy/verify/krawczyk_shapes_engine.py +47 -50
- snappy/verify/maximal_cusp_area_matrix/__init__.py +17 -86
- snappy/verify/maximal_cusp_area_matrix/cusp_tiling_engine.py +58 -48
- snappy/verify/maximal_cusp_area_matrix/cusp_translate_engine.py +53 -57
- snappy/verify/{realAlgebra.py → real_algebra.py} +26 -20
- snappy/verify/shapes.py +10 -7
- snappy/verify/short_slopes.py +41 -42
- snappy/verify/{squareExtensions.py → square_extensions.py} +96 -92
- snappy/verify/test.py +59 -57
- snappy/verify/upper_halfspace/extended_matrix.py +5 -5
- snappy/verify/upper_halfspace/finite_point.py +44 -31
- snappy/verify/upper_halfspace/ideal_point.py +69 -57
- snappy/verify/volume.py +15 -12
- snappy/version.py +2 -3
- {snappy-3.0.3.dist-info → snappy-3.2.dist-info}/METADATA +14 -12
- snappy-3.2.dist-info/RECORD +503 -0
- {snappy-3.0.3.dist-info → snappy-3.2.dist-info}/WHEEL +1 -1
- {snappy-3.0.3.dist-info → snappy-3.2.dist-info}/entry_points.txt +0 -1
- {snappy-3.0.3.dist-info → snappy-3.2.dist-info}/top_level.txt +10 -1
- snappy/doc/_sources/verify_canon.rst.txt +0 -90
- snappy/doc/_static/classic.css +0 -266
- snappy/doc/_static/jquery-3.5.1.js +0 -10872
- snappy/doc/_static/sidebar.js +0 -159
- snappy/doc/_static/underscore-1.13.1.js +0 -2042
- snappy/doc/_static/underscore.js +0 -6
- snappy/doc/verify_canon.html +0 -283
- snappy/ppm_to_png.py +0 -243
- snappy/togl/__init__.py +0 -3
- snappy/togl/darwin-tk8.6/Togl2.1/LICENSE +0 -28
- snappy/togl/darwin-tk8.6/Togl2.1/libTogl2.1.dylib +0 -0
- snappy/togl/darwin-tk8.6/Togl2.1/pkgIndex.tcl +0 -5
- snappy/togl/linux2-x86_64-tk8.6/Togl2.1/LICENSE +0 -28
- snappy/togl/linux2-x86_64-tk8.6/Togl2.1/libTogl2.1.so +0 -0
- snappy/togl/linux2-x86_64-tk8.6/Togl2.1/pkgIndex.tcl +0 -5
- snappy/togl/win32VC-tk8.6/Togl2.1/LICENSE +0 -28
- snappy/togl/win32VC-tk8.6/Togl2.1/Togl21.dll +0 -0
- snappy/togl/win32VC-tk8.6/Togl2.1/Togl21.lib +0 -0
- snappy/togl/win32VC-tk8.6/Togl2.1/pkgIndex.tcl +0 -6
- snappy/togl/win32VC-x86_64-tk8.6/Togl2.1/LICENSE +0 -28
- snappy/togl/win32VC-x86_64-tk8.6/Togl2.1/Togl21.dll +0 -0
- snappy/togl/win32VC-x86_64-tk8.6/Togl2.1/Togl21.lib +0 -0
- snappy/togl/win32VC-x86_64-tk8.6/Togl2.1/pkgIndex.tcl +0 -6
- snappy/verify/cuspCrossSection.py +0 -1413
- snappy/verify/mathHelpers.py +0 -64
- snappy-3.0.3.dist-info/RECORD +0 -360
@@ -0,0 +1,162 @@
|
|
1
|
+
from ..snap.t3mlite.simplex import *
|
2
|
+
from ..snap.t3mlite.edge import Edge
|
3
|
+
from ..snap.t3mlite.arrow import Arrow
|
4
|
+
from ..snap.t3mlite.mcomplex import Mcomplex, VERBOSE, edge_and_arrow
|
5
|
+
from ..snap.t3mlite.tetrahedron import Tetrahedron
|
6
|
+
|
7
|
+
|
8
|
+
class McomplexWithMemory(Mcomplex):
|
9
|
+
"""
|
10
|
+
A version of Mcomplex which remembers what Pachner moves have been
|
11
|
+
performed. Also, Pachner moves have additional options over the
|
12
|
+
standard Mcomplex.
|
13
|
+
|
14
|
+
>>> M = McomplexWithMemory('dLQabccbcbv') # S^3
|
15
|
+
>>> M.two_to_three(F0, M[0], must_succeed=True)
|
16
|
+
True
|
17
|
+
>>> assert M.eliminate_valence_three()
|
18
|
+
>>> M.move_memory
|
19
|
+
[('two_to_three', 6, 14, 0), ('three_to_two', 3, 7, 1)]
|
20
|
+
>>> a = M.Edges[1].get_arrow()
|
21
|
+
>>> assert M.zero_to_two(a, 4)
|
22
|
+
>>> assert M.eliminate_valence_two()
|
23
|
+
>>> M.move_memory[2:]
|
24
|
+
[('zero_to_two', 3, 7, 0, 4), ('two_to_zero', 3, 7, 3)]
|
25
|
+
|
26
|
+
|
27
|
+
>>> N = McomplexWithMemory('o9_24662')
|
28
|
+
>>> iso = N.isosig()
|
29
|
+
>>> e = [e for e in N.Edges if e.valence() == 4 and e.distinct()][0]
|
30
|
+
>>> a = e.get_arrow(); a
|
31
|
+
< E01 | F2 | tet2 >
|
32
|
+
>>> assert N.four_to_four(a)
|
33
|
+
>>> N.move_memory
|
34
|
+
[('four_to_four', 3, 11, 2)]
|
35
|
+
>>> N.rebuild(); N.isosig() != iso
|
36
|
+
True
|
37
|
+
>>> while len(N.move_memory) < 100:
|
38
|
+
... size = N.randomize()
|
39
|
+
>>> target = N.isosig()
|
40
|
+
>>> X = McomplexWithMemory('o9_24662')
|
41
|
+
>>> X.perform_moves(N.move_memory)
|
42
|
+
>>> assert X.isosig() == target
|
43
|
+
>>> X.name
|
44
|
+
'o9_24662'
|
45
|
+
"""
|
46
|
+
def __init__(self, tetrahedron_list=None, two_zero_to_one_tet=True,
|
47
|
+
invariant_tetrahedra=None):
|
48
|
+
if isinstance(tetrahedron_list, str):
|
49
|
+
self.name = tetrahedron_list
|
50
|
+
Mcomplex.__init__(self, tetrahedron_list)
|
51
|
+
self.two_zero_to_one_tet = two_zero_to_one_tet
|
52
|
+
if invariant_tetrahedra is None:
|
53
|
+
invariant_tetrahedra = []
|
54
|
+
self.invariant_tetrahedra = invariant_tetrahedra
|
55
|
+
self.move_memory = []
|
56
|
+
|
57
|
+
def _add_to_move_memory(self, move, arrow):
|
58
|
+
if hasattr(self, 'move_memory'):
|
59
|
+
T = arrow.Tetrahedron
|
60
|
+
tet_index = self.Tetrahedra.index(T)
|
61
|
+
self.move_memory.append((move, arrow.Edge, arrow.Face, tet_index))
|
62
|
+
|
63
|
+
def _relabel_tetrahedra(self):
|
64
|
+
for i, tet in enumerate(self):
|
65
|
+
tet.Index = i
|
66
|
+
|
67
|
+
def perform_moves(self, moves, tet_stop_num=0):
|
68
|
+
"""
|
69
|
+
Assumes that three_to_two, two_to_three, etc. only rebuild the
|
70
|
+
edge classes after each move and that they accept arrows as
|
71
|
+
spec for the moves.
|
72
|
+
"""
|
73
|
+
t = 0
|
74
|
+
for move, edge, face, tet_index in moves:
|
75
|
+
if len(self) <= tet_stop_num:
|
76
|
+
break
|
77
|
+
t = t+1
|
78
|
+
arrow = Arrow(edge, face, self[tet_index])
|
79
|
+
move_fn = getattr(self, move)
|
80
|
+
move_fn(arrow, must_succeed=True)
|
81
|
+
self._relabel_tetrahedra()
|
82
|
+
self.rebuild()
|
83
|
+
|
84
|
+
def _face_permits_two_to_three(self, a, b):
|
85
|
+
possible, reason = Mcomplex._face_permits_two_to_three(self, a, b)
|
86
|
+
if possible:
|
87
|
+
S, T = a.Tetrahedron, b.Tetrahedron
|
88
|
+
if (S in self.invariant_tetrahedra or T in self.invariant_tetrahedra):
|
89
|
+
return False, 'Move would effect invariant tets'
|
90
|
+
return possible, reason
|
91
|
+
|
92
|
+
def _two_to_three_move_hook(self, old_arrow, new_arrows):
|
93
|
+
self._add_to_move_memory('two_to_three', old_arrow)
|
94
|
+
|
95
|
+
def _edge_permits_three_to_two(self, edge):
|
96
|
+
possible, reason = Mcomplex._edge_permits_three_to_two(self, edge)
|
97
|
+
if possible:
|
98
|
+
if any(corner.Tetrahedron in self.invariant_tetrahedra
|
99
|
+
for corner in edge.Corners):
|
100
|
+
return False, 'Edge adjacent to fixed subcomplex'
|
101
|
+
return possible, reason
|
102
|
+
|
103
|
+
def _three_to_two_move_hook(self, old_arrow, new_arrows):
|
104
|
+
self._add_to_move_memory('three_to_two', old_arrow)
|
105
|
+
|
106
|
+
def _arrow_permits_two_to_zero(self, arrow):
|
107
|
+
possible, reason = Mcomplex._arrow_permits_two_to_zero(self, arrow)
|
108
|
+
if possible:
|
109
|
+
if len(self) == 3 and not self.two_zero_to_one_tet:
|
110
|
+
return False, '2->0 move to 1 tet manifold has been blocked'
|
111
|
+
if any(corner.Tetrahedron in self.invariant_tetrahedra
|
112
|
+
for corner in arrow.axis().Corners):
|
113
|
+
return False, 'Edge adjacent to fixed subcomplex'
|
114
|
+
return possible, reason
|
115
|
+
|
116
|
+
def _two_to_zero_hook(self, old_arrow):
|
117
|
+
self._add_to_move_memory('two_to_zero', old_arrow)
|
118
|
+
|
119
|
+
def zero_to_two(self, arrow, gap):
|
120
|
+
success = Mcomplex.zero_to_two(self, arrow, gap)
|
121
|
+
if success and hasattr(self, 'move_memory'):
|
122
|
+
T = arrow.Tetrahedron
|
123
|
+
tet_index = self.Tetrahedra.index(T)
|
124
|
+
self.move_memory.append(
|
125
|
+
('zero_to_two', arrow.Edge, arrow.Face, tet_index, gap))
|
126
|
+
return success
|
127
|
+
|
128
|
+
def _edge_permits_four_to_four(self, edge):
|
129
|
+
possible, reason = Mcomplex._edge_permits_four_to_four(self, edge)
|
130
|
+
if possible:
|
131
|
+
if any(corner.Tetrahedron in self.invariant_tetrahedra
|
132
|
+
for corner in edge.Corners):
|
133
|
+
return False, 'Edge adjacent to fixed subcomplex'
|
134
|
+
return possible, reason
|
135
|
+
|
136
|
+
def _four_to_four_move_hook(self, old_arrow, new_arrows):
|
137
|
+
self._add_to_move_memory('four_to_four', old_arrow)
|
138
|
+
|
139
|
+
def easy_simplify(self):
|
140
|
+
"""
|
141
|
+
>>> M = McomplexWithMemory('zLALvwvMwLzzAQPQQkbcbeijmoomvwuvust'
|
142
|
+
... 'wwytxtyxyahkswpmakguadppmrssxbkoxsi')
|
143
|
+
>>> N = M.copy()
|
144
|
+
>>> M.easy_simplify()
|
145
|
+
True
|
146
|
+
>>> len(M), len(M.move_memory)
|
147
|
+
(1, 25)
|
148
|
+
>>> M.rebuild(); M.isosig()
|
149
|
+
'bkaagj'
|
150
|
+
|
151
|
+
>>> N.invariant_tetrahedra = [N[1]] # core solid torus
|
152
|
+
>>> N.easy_simplify()
|
153
|
+
True
|
154
|
+
>>> len(N), len(N.move_memory)
|
155
|
+
(15, 9)
|
156
|
+
"""
|
157
|
+
return Mcomplex.easy_simplify(self)
|
158
|
+
|
159
|
+
|
160
|
+
if __name__ == '__main__':
|
161
|
+
import doctest
|
162
|
+
print(doctest.testmod())
|
@@ -0,0 +1,491 @@
|
|
1
|
+
"""
|
2
|
+
The basic computation geometry predicates for points and segments in
|
3
|
+
QQ^2 and QQ^3 that needed for PL links.
|
4
|
+
|
5
|
+
The only nonstandard one is `can_straighten_bend`.
|
6
|
+
"""
|
7
|
+
from .rational_linear_algebra import Matrix, Vector2, Vector3, QQ, rational_sqrt
|
8
|
+
|
9
|
+
|
10
|
+
def min_support(v):
|
11
|
+
"""
|
12
|
+
>>> min_support(Vector3([0, 0, -1]))
|
13
|
+
2
|
14
|
+
"""
|
15
|
+
for i, e in enumerate(v):
|
16
|
+
if e != 0:
|
17
|
+
return i
|
18
|
+
raise ValueError('Vector is 0')
|
19
|
+
|
20
|
+
|
21
|
+
def cross_product(a, b):
|
22
|
+
return Vector3([a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], a[0]*b[1] - a[1]*b[0]])
|
23
|
+
|
24
|
+
|
25
|
+
def coplanar(a, b, c, d):
|
26
|
+
"""
|
27
|
+
>>> vecs = Matrix([(1, 0, 1), (-1, 0, 2), (0, 1, 0), (1, 3, 0)])
|
28
|
+
>>> coplanar(*vecs.rows())
|
29
|
+
False
|
30
|
+
>>> coplanar(vecs[0], vecs[1], vecs[2], vecs[0])
|
31
|
+
True
|
32
|
+
"""
|
33
|
+
return Matrix([b - a, c - a, d - a]).det() == 0
|
34
|
+
|
35
|
+
|
36
|
+
def are_parallel(u, v):
|
37
|
+
"""
|
38
|
+
>>> a = Vector3([1, 0, 0])
|
39
|
+
>>> b = Vector3([1, 1, 1])
|
40
|
+
>>> are_parallel(a, b)
|
41
|
+
False
|
42
|
+
>>> are_parallel(a, 2*a)
|
43
|
+
True
|
44
|
+
"""
|
45
|
+
if u == 0 or v == 0:
|
46
|
+
return True
|
47
|
+
i = min_support(u)
|
48
|
+
if v[i] == 0:
|
49
|
+
return False
|
50
|
+
return u/u[i] == v/v[i]
|
51
|
+
|
52
|
+
|
53
|
+
def colinear(u, v, w):
|
54
|
+
return are_parallel(v - u, w - u)
|
55
|
+
|
56
|
+
|
57
|
+
def find_convex_combination(a, b, u):
|
58
|
+
"""
|
59
|
+
>>> p = Vector2([0, 1])
|
60
|
+
>>> q = Vector2([1, 0])
|
61
|
+
>>> t = QQ(1)/5
|
62
|
+
|
63
|
+
This next awkward cast is required when using the PARI kernel
|
64
|
+
because of the permissive behavior of Gen.__mul__.
|
65
|
+
|
66
|
+
>>> r = Vector2((1 - t)*p + t*q)
|
67
|
+
>>> find_convex_combination(p, q, r)
|
68
|
+
1/5
|
69
|
+
>>> find_convex_combination(p, 3*p, 2*p)
|
70
|
+
1/2
|
71
|
+
"""
|
72
|
+
if a == b:
|
73
|
+
raise ValueError('Segment is degenerate')
|
74
|
+
v, w = b - a, u - a
|
75
|
+
if not are_parallel(v, w):
|
76
|
+
raise ValueError('Point not on line')
|
77
|
+
i = min_support(v)
|
78
|
+
t = w[i]/v[i]
|
79
|
+
assert (1 - t)*a + t*b == u
|
80
|
+
return t
|
81
|
+
|
82
|
+
|
83
|
+
def point_meets_interior_of_segment(u, ab):
|
84
|
+
"""
|
85
|
+
>>> p = Vector3([1, 1, 0])
|
86
|
+
>>> q = Vector3([3, -1,0])
|
87
|
+
>>> a = Vector3([2, 0, 0])
|
88
|
+
>>> b = Vector3([0, 2, 0])
|
89
|
+
>>> c = Vector3([1, 0, 0])
|
90
|
+
>>> o = Vector3([0, 0, 0])
|
91
|
+
>>> point_meets_interior_of_segment(p, (a, b))
|
92
|
+
True
|
93
|
+
>>> point_meets_interior_of_segment(q, (a, b))
|
94
|
+
False
|
95
|
+
>>> point_meets_interior_of_segment(p, (b, c))
|
96
|
+
False
|
97
|
+
>>> point_meets_interior_of_segment(2*a/3, (a, c))
|
98
|
+
True
|
99
|
+
>>> point_meets_interior_of_segment(o, (a, b))
|
100
|
+
False
|
101
|
+
"""
|
102
|
+
a, b = ab
|
103
|
+
if a == b:
|
104
|
+
raise ValueError('Segment is degenerate')
|
105
|
+
if not are_parallel(b - a, u - a):
|
106
|
+
return False
|
107
|
+
t = find_convex_combination(a, b, u)
|
108
|
+
return 0 < t < 1
|
109
|
+
|
110
|
+
|
111
|
+
def is_pointy(a, b, c, threshold=QQ('3/4')):
|
112
|
+
"""
|
113
|
+
Whether the angle (a, b, c) is less than pi/6. This function is
|
114
|
+
not currently used by anything.
|
115
|
+
|
116
|
+
>>> p = Vector3([ 0, 0, 1])
|
117
|
+
>>> q = Vector3([10, 0, 1])
|
118
|
+
>>> r = Vector3([0, 10, 1])
|
119
|
+
>>> s = Vector3([9, 1, 1])
|
120
|
+
>>> t = Vector3([-9, 1, 1])
|
121
|
+
>>> is_pointy(t, p, q)
|
122
|
+
False
|
123
|
+
>>> is_pointy(q, p, r)
|
124
|
+
False
|
125
|
+
>>> is_pointy(p, q, r)
|
126
|
+
False
|
127
|
+
>>> is_pointy(s, p, q)
|
128
|
+
True
|
129
|
+
>>> is_pointy(q, p, q)
|
130
|
+
True
|
131
|
+
"""
|
132
|
+
v = a - b
|
133
|
+
w = c - b
|
134
|
+
dot = v*w
|
135
|
+
if dot <= 0:
|
136
|
+
return False
|
137
|
+
norms = (v*v)*(w*w)
|
138
|
+
return dot**2/norms >= threshold
|
139
|
+
|
140
|
+
|
141
|
+
def segments_meet_not_at_endpoint(ab, uv):
|
142
|
+
"""
|
143
|
+
Does the interior of either segment meet any point of the other
|
144
|
+
one?
|
145
|
+
|
146
|
+
>>> p = Vector3([1, 1, 0])
|
147
|
+
>>> q = Vector3([3, -1,0])
|
148
|
+
>>> a = Vector3([2, 0, 0])
|
149
|
+
>>> b = Vector3([0, 2, 0])
|
150
|
+
>>> c = Vector3([1, 0, 0])
|
151
|
+
>>> o = Vector3([0, 0, 0])
|
152
|
+
>>> segments_meet_not_at_endpoint((p, 2*p), (2*p, 3*p))
|
153
|
+
False
|
154
|
+
>>> segments_meet_not_at_endpoint((p, 3*p), (2*p, 4*p))
|
155
|
+
True
|
156
|
+
>>> segments_meet_not_at_endpoint((p, 2*p), (3*p, q))
|
157
|
+
False
|
158
|
+
>>> segments_meet_not_at_endpoint((p, 3*p), (2*p, q))
|
159
|
+
True
|
160
|
+
>>> segments_meet_not_at_endpoint((-a, a), (b + c, -b + c))
|
161
|
+
True
|
162
|
+
>>> segments_meet_not_at_endpoint((-a, a), (a, -b + c))
|
163
|
+
False
|
164
|
+
>>> segments_meet_not_at_endpoint((o, a), (-p, p))
|
165
|
+
True
|
166
|
+
>>> segments_meet_not_at_endpoint((-p + q, p + q), (-a + q, a + q))
|
167
|
+
True
|
168
|
+
|
169
|
+
>>> b, c = Vector3([0, 0, 1]), Vector3([0, 1, 0])
|
170
|
+
>>> u, v = Vector3([-1, 0, 1]), Vector3([-1, 1, 2])/3
|
171
|
+
>>> segments_meet_not_at_endpoint((b, c), (u, v))
|
172
|
+
False
|
173
|
+
"""
|
174
|
+
a, b = ab
|
175
|
+
u, v = uv
|
176
|
+
if a == b or u == v:
|
177
|
+
raise ValueError('Segment has no interior')
|
178
|
+
if not coplanar(a, b, u, v):
|
179
|
+
return False
|
180
|
+
|
181
|
+
# All four points lie in a common plane, first consider cases
|
182
|
+
# where (a, b, u) are colinear.
|
183
|
+
if colinear(a, b, u):
|
184
|
+
if colinear(a, b, v):
|
185
|
+
s = find_convex_combination(a, b, u)
|
186
|
+
t = find_convex_combination(a, b, v)
|
187
|
+
if s > t:
|
188
|
+
s, t = t, s
|
189
|
+
return not (t <= 0 or s >= 1)
|
190
|
+
else:
|
191
|
+
return point_meets_interior_of_segment(u, (a, b))
|
192
|
+
else:
|
193
|
+
if are_parallel(b - a, v - u):
|
194
|
+
# Since (a, b, u) are not colinear, these parallel lines
|
195
|
+
# are disjoint.
|
196
|
+
return False
|
197
|
+
|
198
|
+
# The lines containing ab and uv will meet in a unique point,
|
199
|
+
# so write it in terms of standard coordinates on the lines
|
200
|
+
# through (a, b) and (u, v).
|
201
|
+
M = Matrix([b - a, u - v]).transpose()
|
202
|
+
s, t = M.solve_right(u - a)
|
203
|
+
|
204
|
+
return ((0 < s < 1) and (0 <= t <= 1)) or ((0 <= s <= 1) and (0 < t < 1))
|
205
|
+
|
206
|
+
|
207
|
+
def standardize_bend_matrix(a, b, c):
|
208
|
+
a, c = a - b, c - b
|
209
|
+
n = cross_product(a, c)
|
210
|
+
M = Matrix([a, c, n]).transpose().inverse()
|
211
|
+
return M
|
212
|
+
|
213
|
+
|
214
|
+
def can_straighten_bend(arc, bend, check_embedded=True, bend_matrix=None):
|
215
|
+
"""
|
216
|
+
Given a "bend" of three points (a, b, c) and an arc (u, v)
|
217
|
+
determine if we can isotope the PL arc (a, b, c) to (a, c) along
|
218
|
+
the triangle (a, b, c) without passing through (u, v).
|
219
|
+
|
220
|
+
>>> a = Vector3([-1, 0, 1])
|
221
|
+
>>> b = Vector3([ 0, 0, 1])
|
222
|
+
>>> c = Vector3([ 0, 1, 0])
|
223
|
+
>>> o = Vector3([ 0, 0, 0])
|
224
|
+
>>> u = Vector3([-1, 2, 1])
|
225
|
+
>>> can_straighten_bend((o, -a), (a, b, c))
|
226
|
+
True
|
227
|
+
>>> can_straighten_bend((o, c), (a, 2*a, 3*a))
|
228
|
+
True
|
229
|
+
>>> can_straighten_bend((o, c), (a, b, c))
|
230
|
+
True
|
231
|
+
>>> can_straighten_bend((a, (a + b + c)/3), (a, b, c))
|
232
|
+
False
|
233
|
+
>>> can_straighten_bend((c, (a + c)/2), (a, b, c))
|
234
|
+
False
|
235
|
+
>>> can_straighten_bend((c, a), (a, b, c))
|
236
|
+
False
|
237
|
+
>>> can_straighten_bend((o, u), (a, b, c))
|
238
|
+
False
|
239
|
+
>>> can_straighten_bend((a + b, a + c), (a, b, c))
|
240
|
+
True
|
241
|
+
>>> can_straighten_bend((o, a + c), (a, b, c))
|
242
|
+
False
|
243
|
+
>>> can_straighten_bend((a, c - b), (a, b, c))
|
244
|
+
True
|
245
|
+
>>> M = standardize_bend_matrix(a, b, c); M.det()
|
246
|
+
1/2
|
247
|
+
>>> can_straighten_bend((o, -a), (a, b, c), bend_matrix=M)
|
248
|
+
True
|
249
|
+
"""
|
250
|
+
u, v = arc
|
251
|
+
a, b, c = bend
|
252
|
+
if hasattr(u, 'to_3d_point'):
|
253
|
+
u, v = u.to_3d_point(), v.to_3d_point()
|
254
|
+
a, b, c = a.to_3d_point(), b.to_3d_point(), c.to_3d_point()
|
255
|
+
|
256
|
+
if u == v or a == b or a == c or b == c:
|
257
|
+
raise ValueError('Input includes 0 length segments')
|
258
|
+
|
259
|
+
if check_embedded:
|
260
|
+
if (segments_meet_not_at_endpoint((a, b), (b, c)) or
|
261
|
+
segments_meet_not_at_endpoint((a, b), (u, v)) or
|
262
|
+
segments_meet_not_at_endpoint((b, c), (u, v)) or
|
263
|
+
point_meets_interior_of_segment(b, (u, v)) or
|
264
|
+
u == b or v == b):
|
265
|
+
raise ValueError('Input not embedded')
|
266
|
+
|
267
|
+
# Some quick tests to see if the arc is far from the bend
|
268
|
+
for i in range(3):
|
269
|
+
arc_cor = (u[i], v[i])
|
270
|
+
bend_cor = (a[i], b[i], c[i])
|
271
|
+
if max(arc_cor) < min(bend_cor) or min(arc_cor) > max(bend_cor):
|
272
|
+
return True
|
273
|
+
|
274
|
+
if colinear(a, b, c):
|
275
|
+
return True
|
276
|
+
# translate b to 0 and transform so a and c are e0 and 1:
|
277
|
+
if bend_matrix is None:
|
278
|
+
bend_matrix = standardize_bend_matrix(a, b, c)
|
279
|
+
a, c = Vector3([1, 0, 0]), Vector3([0, 1, 0])
|
280
|
+
u, v = bend_matrix*(u - b), bend_matrix*(v - b)
|
281
|
+
|
282
|
+
# If both u and v strictly to the same side of the plane
|
283
|
+
# containing the bend, then done.
|
284
|
+
if u[2] * v[2] > 0:
|
285
|
+
return True
|
286
|
+
|
287
|
+
if u[2] == v[2] == 0:
|
288
|
+
# The whole arc is in the plane, and we know it is disjoint
|
289
|
+
# from the bend except possibly at the endpoints.
|
290
|
+
#
|
291
|
+
# First check if this is a closed cycle.
|
292
|
+
if (u == a and v == c) or (u == c and v == a):
|
293
|
+
return False
|
294
|
+
# Check if the points are in this 2/3-open triangle.
|
295
|
+
u_in_tri = u[0] > 0 and u[1] > 0 and u[0] + u[1] <= 1
|
296
|
+
v_in_tri = v[0] > 0 and v[1] > 0 and v[0] + v[1] <= 1
|
297
|
+
return not (u_in_tri or v_in_tri)
|
298
|
+
|
299
|
+
# Now is a unique point of intersection of the arc with said
|
300
|
+
# plane, so find it.
|
301
|
+
t = u[2]/(u[2] - v[2])
|
302
|
+
p = (1 - t)*u + t*v
|
303
|
+
assert 0 <= t <= 1 and p[2] == 0
|
304
|
+
# 2/3 open triangle check
|
305
|
+
return not (p[0] > 0 and p[1] > 0 and p[0] + p[1] <= 1)
|
306
|
+
|
307
|
+
|
308
|
+
def norm_sq(v):
|
309
|
+
return sum(x**2 for x in v)
|
310
|
+
|
311
|
+
|
312
|
+
def pall_matrix(a, b, c, d):
|
313
|
+
"""
|
314
|
+
For testing, here are all 3 x 3 rational orthogonal matrices,
|
315
|
+
which Pall parameterized by four integers.
|
316
|
+
"""
|
317
|
+
n = a**2 + b**2 + c**2 + d**2
|
318
|
+
assert n % 2 == 1
|
319
|
+
entries = [[a**2 + b**2 - c**2 - d**2, 2*(-a*d + b*c), 2*(a*c + b*d)],
|
320
|
+
[2*(a*d + b*c), a**2 - b**2 + c**2 - d**2, 2*(-a*b + c*d)],
|
321
|
+
[2*(-a*c + b*d), 2*(a*b + c*d), a**2 - b**2 - c**2 + d**2]]
|
322
|
+
return Matrix([[e/QQ(n) for e in row] for row in entries])
|
323
|
+
|
324
|
+
|
325
|
+
def arc_distance_sq_checked(arc_a0, arc_b0):
|
326
|
+
"""
|
327
|
+
Check that all possible permutations of the data specifying the
|
328
|
+
arcs gives the same result, plus images under some orthogonal
|
329
|
+
transformations.
|
330
|
+
"""
|
331
|
+
ans = arc_distance_sq(arc_a0, arc_b0)
|
332
|
+
arc_a1 = (arc_a0[1], arc_a0[0])
|
333
|
+
arc_b1 = (arc_b0[1], arc_b0[0])
|
334
|
+
mats = [pall_matrix(1, 0, 0, 0),
|
335
|
+
pall_matrix(1, -2, 3, 5),
|
336
|
+
pall_matrix(4, -1, 2, 2)]
|
337
|
+
for M in mats:
|
338
|
+
arc_a0 = (M*arc_a0[0], M*arc_a0[1])
|
339
|
+
arc_a1 = (M*arc_a1[0], M*arc_a1[1])
|
340
|
+
arc_b0 = (M*arc_b0[0], M*arc_b0[1])
|
341
|
+
arc_b1 = (M*arc_b1[0], M*arc_b1[1])
|
342
|
+
assert ans == arc_distance_sq(arc_a0, arc_b0)
|
343
|
+
assert ans == arc_distance_sq(arc_a0, arc_b1)
|
344
|
+
assert ans == arc_distance_sq(arc_a1, arc_b0)
|
345
|
+
assert ans == arc_distance_sq(arc_a1, arc_b1)
|
346
|
+
assert ans == arc_distance_sq(arc_b0, arc_a0)
|
347
|
+
assert ans == arc_distance_sq(arc_b0, arc_a1)
|
348
|
+
assert ans == arc_distance_sq(arc_b1, arc_a0)
|
349
|
+
assert ans == arc_distance_sq(arc_b1, arc_a1)
|
350
|
+
return ans
|
351
|
+
|
352
|
+
|
353
|
+
def arc_distance_sq(arc_a, arc_b):
|
354
|
+
"""
|
355
|
+
>>> o = Vector3([0, 0, 0])
|
356
|
+
>>> a1 = Vector3([1, 0, 0])
|
357
|
+
>>> a2 = Vector3([2, 0, 0])
|
358
|
+
>>> a3 = Vector3([3, 0, 0])
|
359
|
+
>>> a4 = Vector3([4, 0, 0])
|
360
|
+
>>> b0 = Vector3([0, 2, 0])
|
361
|
+
>>> b1 = Vector3([1, 2, 0])
|
362
|
+
>>> b2 = Vector3([2, 2, 0])
|
363
|
+
>>> b3 = Vector3([3, 2, 0])
|
364
|
+
>>> b4 = Vector3([4, 2, 0])
|
365
|
+
>>> c1 = Vector3([0, 0, 1])
|
366
|
+
>>> arc_distance_sq_checked([o, a1], [o, b0])
|
367
|
+
0
|
368
|
+
>>> arc_distance_sq_checked([o, a1], [c1, a1 + c1])
|
369
|
+
1
|
370
|
+
>>> arc_b = [Vector3([1, 1, -1]), Vector3([1, 1, 1])]
|
371
|
+
>>> arc_distance_sq_checked([-c1, c1], arc_b)
|
372
|
+
2
|
373
|
+
|
374
|
+
Now some cases were everything is on one line.
|
375
|
+
|
376
|
+
>>> arc_distance_sq_checked([o, a3], [a1, a2])
|
377
|
+
0
|
378
|
+
>>> arc_distance_sq_checked([o, a2], [a1, a3])
|
379
|
+
0
|
380
|
+
>>> arc_distance_sq_checked([o, a1], [a3, a4])
|
381
|
+
4
|
382
|
+
>>> arc_distance_sq_checked([o, a1], [a1/2, 2*a1])
|
383
|
+
0
|
384
|
+
|
385
|
+
Arcs are parallel but on distinct lines
|
386
|
+
|
387
|
+
>>> arc_distance_sq_checked([b0, b1], [a3, a4])
|
388
|
+
8
|
389
|
+
>>> arc_distance_sq_checked([b0, b4], [a2, a3])
|
390
|
+
4
|
391
|
+
>>> arc_distance_sq_checked([b0, b1], [a1, a2])
|
392
|
+
4
|
393
|
+
|
394
|
+
Now some more generic cases
|
395
|
+
|
396
|
+
>>> half = 1/QQ(2)
|
397
|
+
>>> arc_b = [Vector3([0, 1, half]), Vector3([1, 0, half])]
|
398
|
+
>>> arc_distance_sq_checked([o, c1], arc_b) == half
|
399
|
+
True
|
400
|
+
>>> arc_b = [Vector3([ 1, 1, 0]), Vector3([0, 1, 0])]
|
401
|
+
>>> arc_distance_sq_checked([-a1, o], arc_b)
|
402
|
+
1
|
403
|
+
>>> arc_b = [Vector3([-1, 1, 0]), Vector3([2, 1, 0])]
|
404
|
+
>>> arc_distance_sq_checked([o, a1], arc_b)
|
405
|
+
1
|
406
|
+
>>> arc_b = [Vector3([-1, -1, 1]), Vector3([1, 1, 1])]
|
407
|
+
>>> arc_distance_sq_checked([-a1, a1], arc_b)
|
408
|
+
1
|
409
|
+
>>> arc_b = [Vector3([1, 0, 1]), Vector3([2, -1, 2])]
|
410
|
+
>>> arc_distance_sq_checked([o, a2], arc_b)
|
411
|
+
1
|
412
|
+
>>> arc_b = [Vector3([1, 0, 1]), Vector3([2, -1, 3])]
|
413
|
+
>>> arc_distance_sq_checked([o, a2], arc_b)
|
414
|
+
1
|
415
|
+
|
416
|
+
"""
|
417
|
+
|
418
|
+
# For general background on this question, see e.g.
|
419
|
+
#
|
420
|
+
# V. Lumelsky, On fast computation of distance between line segments
|
421
|
+
# https://doi.org/10.1016/0020-0190(85)90032-8
|
422
|
+
#
|
423
|
+
# See also
|
424
|
+
#
|
425
|
+
# https://github.com/CGAL/cgal/blob/master/Distance_3/include/CGAL/Distance_3/Segment_3_Segment_3.h
|
426
|
+
|
427
|
+
a0, a1 = arc_a
|
428
|
+
b0, b1 = arc_b
|
429
|
+
|
430
|
+
u = a1 - a0
|
431
|
+
v = b1 - b0
|
432
|
+
w = a0 - b0
|
433
|
+
|
434
|
+
if are_parallel(u, v) and are_parallel(u, w):
|
435
|
+
# arc_a and arc_b are contained in a common line, so find the
|
436
|
+
# coordinates of the endpoints of arc_b with respect to arc_a.
|
437
|
+
U = Matrix([u]).transpose()
|
438
|
+
t0, t1 = U.solve_right(b0 - a0)[0], U.solve_right(b1 - a0)[0]
|
439
|
+
if t0 > t1:
|
440
|
+
t0, t1 = t1, t0
|
441
|
+
if t1 < 0: # arc_b disjoint and to the left of arc_a
|
442
|
+
return t1**2 * norm_sq(u)
|
443
|
+
elif 1 < t0: # arc_b disjoint and to the right of arc_a
|
444
|
+
return (t0 - 1)**2 * norm_sq(u)
|
445
|
+
return 0 # arcs_overlap
|
446
|
+
|
447
|
+
# Now we solve for the closest point between the two lines
|
448
|
+
# generated by the arcs.
|
449
|
+
|
450
|
+
X = Matrix([[u*u, -u*v],
|
451
|
+
[u*v, -v*v]])
|
452
|
+
Y = Vector2([-u*w, -v*w])
|
453
|
+
|
454
|
+
if X.det() == 0:
|
455
|
+
# PARI doesn't like degenerate systems, but using that u and v
|
456
|
+
# are parallel so we can solve geometrically via a projection.
|
457
|
+
t, s = -(w*u)/norm_sq(u), 0
|
458
|
+
else:
|
459
|
+
t, s = X.solve_right(Y)
|
460
|
+
|
461
|
+
# If the closest points on the lines lie within the arcs, we're done.
|
462
|
+
if 0 <= t <= 1 and 0 <= s <= 1:
|
463
|
+
pA = a0 + Vector3(t*u)
|
464
|
+
pB = b0 + Vector3(s*v)
|
465
|
+
return norm_sq(pA - pB)
|
466
|
+
|
467
|
+
t = (b0-a0)*u/norm_sq(u)
|
468
|
+
s = (b1-a0)*u/norm_sq(u)
|
469
|
+
x = (a0-b0)*v/norm_sq(v)
|
470
|
+
y = (a1-b0)*v/norm_sq(v)
|
471
|
+
|
472
|
+
s = min(max(s, 0), 1)
|
473
|
+
t = min(max(t, 0), 1)
|
474
|
+
x = min(max(x, 0), 1)
|
475
|
+
y = min(max(y, 0), 1)
|
476
|
+
|
477
|
+
p = a0 + Vector3(t*u)
|
478
|
+
q = a0 + Vector3(s*u)
|
479
|
+
f = b0 + Vector3(x*v)
|
480
|
+
g = b0 + Vector3(y*v)
|
481
|
+
|
482
|
+
return min([norm_sq(p - b0), norm_sq(q - b1), norm_sq(f - a0), norm_sq(g - a1)])
|
483
|
+
|
484
|
+
|
485
|
+
def arc_distance(arc_a, arc_b):
|
486
|
+
return rational_sqrt(arc_distance_sq(arc_a, arc_b))
|
487
|
+
|
488
|
+
|
489
|
+
if __name__ == '__main__':
|
490
|
+
import doctest
|
491
|
+
print(doctest.testmod())
|