@ccpc/math 0.1.0 → 0.1.7
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.
- package/index.cjs +226 -0
- package/package.json +19 -37
- package/types/algorithm/bool_operate/bool2d/bool2d.d.ts +22 -0
- package/types/algorithm/bool_operate/bool2d/difference.d.ts +9 -0
- package/types/algorithm/bool_operate/bool2d/intersect.d.ts +9 -0
- package/types/algorithm/bool_operate/bool2d/split.d.ts +3 -0
- package/types/algorithm/bool_operate/bool2d/union.d.ts +9 -0
- package/types/algorithm/bool_operate/bool2d/utils.d.ts +40 -0
- package/types/algorithm/bool_operate/bool_operate_clipper.d.ts +18 -0
- package/types/algorithm/bool_operate/polycurve_polygon_bool.d.ts +13 -0
- package/types/algorithm/bool_operate_2d.d.ts +67 -0
- package/types/algorithm/calc_d.d.ts +85 -0
- package/types/algorithm/calc_offset.d.ts +70 -0
- package/types/algorithm/calc_overlap.d.ts +56 -0
- package/types/algorithm/calc_project.d.ts +29 -0
- package/types/algorithm/calc_x.d.ts +215 -0
- package/types/algorithm/calculate_util/geometry_subdevide_infos.d.ts +73 -0
- package/types/algorithm/calculate_util/iterative_method.d.ts +30 -0
- package/types/algorithm/discrete/discrete_curve.d.ts +31 -0
- package/types/algorithm/discrete/discrete_refiner.d.ts +35 -0
- package/types/algorithm/discrete/discrete_surface.d.ts +74 -0
- package/types/algorithm/discrete/discrete_topology.d.ts +32 -0
- package/types/algorithm/discrete/discrete_util.d.ts +96 -0
- package/types/algorithm/discrete/grid_discrete_data.d.ts +58 -0
- package/types/algorithm/discrete/libtess.d.ts +12 -0
- package/types/algorithm/discrete/uniform_grid_discrete.d.ts +3 -0
- package/types/algorithm/distance/base_calc_distance/curves_distance_util.d.ts +20 -0
- package/types/algorithm/distance/base_calc_distance/define_of_calculate_distance.d.ts +12 -0
- package/types/algorithm/distance/curve2ds_distance/arc2s_distance.d.ts +17 -0
- package/types/algorithm/distance/curve2ds_distance/line2d_to_arc2d_distance.d.ts +17 -0
- package/types/algorithm/distance/curve2ds_distance/line2s_distance.d.ts +15 -0
- package/types/algorithm/distance/curve2s_distance.d.ts +15 -0
- package/types/algorithm/distance/curve3ds_distance/line3d_to_line3d_distance_paramed.d.ts +12 -0
- package/types/algorithm/distance/curve3s_distance.d.ts +31 -0
- package/types/algorithm/distance/pt_to_curve2_signed_distance.d.ts +17 -0
- package/types/algorithm/distance/pt_to_curve3_distance.d.ts +25 -0
- package/types/algorithm/distance/pt_to_curve_distance_info.d.ts +12 -0
- package/types/algorithm/distance/pt_to_surface_distance.d.ts +17 -0
- package/types/algorithm/distance/pts_to_curves_distance.d.ts +13 -0
- package/types/algorithm/distance/pts_to_pts_distance.d.ts +7 -0
- package/types/algorithm/geometry_merge.d.ts +22 -0
- package/types/algorithm/index.d.ts +32 -0
- package/types/algorithm/intersect/box_cut_line.d.ts +6 -0
- package/types/algorithm/intersect/curve_self_x.d.ts +13 -0
- package/types/algorithm/intersect/curve_surface_x.d.ts +34 -0
- package/types/algorithm/intersect/curve_surface_x_util.d.ts +32 -0
- package/types/algorithm/intersect/curves_x/circulars_x.d.ts +35 -0
- package/types/algorithm/intersect/curves_x/linear_circular_x.d.ts +40 -0
- package/types/algorithm/intersect/curves_x/lines_x.d.ts +17 -0
- package/types/algorithm/intersect/curves_x/lines_x_util.d.ts +4 -0
- package/types/algorithm/intersect/curves_x.d.ts +26 -0
- package/types/algorithm/intersect/curves_x_util.d.ts +35 -0
- package/types/algorithm/intersect/intersect_info_util.d.ts +9 -0
- package/types/algorithm/intersect/surface_self_x.d.ts +8 -0
- package/types/algorithm/intersect/surfaces_x.d.ts +53 -0
- package/types/algorithm/intersect/surfaces_x_complex.d.ts +29 -0
- package/types/algorithm/intersect/surfaces_x_special.d.ts +16 -0
- package/types/algorithm/intersect/surfaces_x_util.d.ts +41 -0
- package/types/algorithm/intersect/x_info.d.ts +65 -0
- package/types/algorithm/loop_property/loop-area.d.ts +49 -0
- package/types/algorithm/loop_property/loop-centroid.d.ts +40 -0
- package/types/algorithm/merge_geometry/halfplane.d.ts +24 -0
- package/types/algorithm/merge_geometry/merge_curve.d.ts +14 -0
- package/types/algorithm/merge_geometry/merge_point.d.ts +18 -0
- package/types/algorithm/mesh/clip_mesh.d.ts +27 -0
- package/types/algorithm/mesh/extrude_clip.d.ts +236 -0
- package/types/algorithm/mesh/mesh_assist.d.ts +21 -0
- package/types/algorithm/mesh/mesh_contour.d.ts +26 -0
- package/types/algorithm/mesh/mesh_util.d.ts +115 -0
- package/types/algorithm/offset/loop2d_offset.d.ts +22 -0
- package/types/algorithm/offset/polygon_offset.d.ts +27 -0
- package/types/algorithm/overlap/curve_surface_coincide.d.ts +6 -0
- package/types/algorithm/overlap/curves_colinear.d.ts +38 -0
- package/types/algorithm/overlap/curves_merge.d.ts +74 -0
- package/types/algorithm/overlap/curves_overlap.d.ts +34 -0
- package/types/algorithm/overlap/i_overlap.d.ts +9 -0
- package/types/algorithm/overlap/surfaces_coplaner.d.ts +5 -0
- package/types/algorithm/pattern/blocks2Geometry.d.ts +50 -0
- package/types/algorithm/pattern/math.d.ts +42 -0
- package/types/algorithm/pattern/pattern.d.ts +43 -0
- package/types/algorithm/pattern/pattern_util.d.ts +53 -0
- package/types/algorithm/pattern/pave.d.ts +33 -0
- package/types/algorithm/pj/curves_oj.d.ts +19 -0
- package/types/algorithm/pj/curves_pj.d.ts +19 -0
- package/types/algorithm/pj/loops_pj.d.ts +13 -0
- package/types/algorithm/pj/pj_type.d.ts +46 -0
- package/types/algorithm/pj/pt_loop_pj.d.ts +24 -0
- package/types/algorithm/pj/pt_polygon_pj.d.ts +18 -0
- package/types/algorithm/pj/pt_polygon_position_judger.d.ts +11 -0
- package/types/algorithm/position_judge.d.ts +72 -0
- package/types/algorithm/project/curve3d_to_plane_project.d.ts +11 -0
- package/types/algorithm/project/curve_curve_project.d.ts +9 -0
- package/types/algorithm/search_graph/iloops_polygonex.d.ts +28 -0
- package/types/algorithm/search_graph/loop_tree_node.d.ts +30 -0
- package/types/algorithm/search_graph/loops_to_loop_tree_search_graph.d.ts +25 -0
- package/types/algorithm/search_graph/polygon_polygonex.d.ts +13 -0
- package/types/algorithm/search_graph/search_loop2d.d.ts +20 -0
- package/types/algorithm/search_graph/search_polyline.d.ts +11 -0
- package/types/algorithm/search_graph.d.ts +45 -0
- package/types/algorithm/topology_edit.d.ts +10 -0
- package/types/base/box.d.ts +100 -0
- package/types/base/box2.d.ts +17 -0
- package/types/base/box3.d.ts +20 -0
- package/types/base/coord.d.ts +10 -0
- package/types/base/coord2.d.ts +92 -0
- package/types/base/coord3.d.ts +139 -0
- package/types/base/discrete_param.d.ts +28 -0
- package/types/base/euler.d.ts +102 -0
- package/types/base/geo_element.d.ts +54 -0
- package/types/base/interval.d.ts +122 -0
- package/types/base/ivector.d.ts +126 -0
- package/types/base/matrix.d.ts +108 -0
- package/types/base/matrix3.d.ts +118 -0
- package/types/base/matrix4.d.ts +166 -0
- package/types/base/matrix_util.d.ts +5 -0
- package/types/base/period_inverval.d.ts +127 -0
- package/types/base/quaternion.d.ts +39 -0
- package/types/base/tangent_cone.d.ts +11 -0
- package/types/base/tilt_box.d.ts +11 -0
- package/types/base/tol.d.ts +120 -0
- package/types/base/vec.d.ts +46 -0
- package/types/base/vec2.d.ts +146 -0
- package/types/base/vec3.d.ts +158 -0
- package/types/brep-src/algorithm/alg_const.d.ts +23 -0
- package/types/brep-src/algorithm/alg_types.d.ts +47 -0
- package/types/brep-src/algorithm/algorithm_util/base_define.d.ts +7 -0
- package/types/brep-src/algorithm/algorithm_util/body_base_util.d.ts +4 -0
- package/types/brep-src/algorithm/algorithm_util/curve_solid_analysis.d.ts +28 -0
- package/types/brep-src/algorithm/algorithm_util/face_face_analysis.d.ts +39 -0
- package/types/brep-src/algorithm/algorithm_util/search_wire.d.ts +8 -0
- package/types/brep-src/algorithm/body_builder/basic_body_builder.d.ts +15 -0
- package/types/brep-src/algorithm/body_builder/extrude_body.d.ts +23 -0
- package/types/brep-src/algorithm/body_builder/sweep_body.d.ts +37 -0
- package/types/brep-src/algorithm/body_builder.d.ts +36 -0
- package/types/brep-src/algorithm/body_util.d.ts +21 -0
- package/types/brep-src/algorithm/bool_sk/brep_converter.d.ts +11 -0
- package/types/brep-src/algorithm/brep_calc_project.d.ts +50 -0
- package/types/brep-src/algorithm/brep_calc_x.d.ts +34 -0
- package/types/brep-src/algorithm/brep_pj.d.ts +47 -0
- package/types/brep-src/algorithm/index.d.ts +5 -0
- package/types/brep-src/algorithm/intersect/curve_face_overlap.d.ts +10 -0
- package/types/brep-src/algorithm/intersect/face_face_intersect.d.ts +22 -0
- package/types/brep-src/algorithm/intersect/face_faces_intersect.d.ts +15 -0
- package/types/brep-src/algorithm/intersect/line_face_intersect.d.ts +16 -0
- package/types/brep-src/algorithm/podition_judge/body_pj.d.ts +25 -0
- package/types/brep-src/algorithm/podition_judge/extrude_pj.d.ts +28 -0
- package/types/brep-src/algorithm/podition_judge/pt_body_pj.d.ts +32 -0
- package/types/brep-src/algorithm/project/body_project.d.ts +8 -0
- package/types/brep-src/algorithm/project/face_project.d.ts +20 -0
- package/types/brep-src/algorithm/project/face_surface_project.d.ts +8 -0
- package/types/brep-src/algorithm/project/space_project.d.ts +26 -0
- package/types/brep-src/algorithm/project/space_project_simple.d.ts +10 -0
- package/types/brep-src/algorithm/project/view_project.d.ts +25 -0
- package/types/brep-src/algorithm/shell_builder/create_shell_from_curves.d.ts +38 -0
- package/types/brep-src/algorithm/shell_builder.d.ts +25 -0
- package/types/brep-src/algorithm/shell_edit/add_edges/add_edges.d.ts +14 -0
- package/types/brep-src/algorithm/shell_edit/add_edges/add_edges_core.d.ts +11 -0
- package/types/brep-src/algorithm/shell_edit/copy_faces.d.ts +20 -0
- package/types/brep-src/algorithm/shell_edit/delete_faces_edges/delete_edge.d.ts +9 -0
- package/types/brep-src/algorithm/shell_edit/delete_faces_edges/delete_faces_edges.d.ts +17 -0
- package/types/brep-src/algorithm/shell_edit/faces_boolean/faces_boolean.d.ts +19 -0
- package/types/brep-src/algorithm/shell_edit/faces_boolean/faces_shells_boolean.d.ts +13 -0
- package/types/brep-src/algorithm/shell_edit/faces_boolean/octree.d.ts +11 -0
- package/types/brep-src/algorithm/shell_edit/isolate_faces.d.ts +21 -0
- package/types/brep-src/algorithm/shell_edit/merge_connect_faces.d.ts +14 -0
- package/types/brep-src/algorithm/shell_edit/merge_edges.d.ts +8 -0
- package/types/brep-src/algorithm/shell_edit/move_operators/move_edges.d.ts +31 -0
- package/types/brep-src/algorithm/shell_edit/move_operators/move_faces.d.ts +14 -0
- package/types/brep-src/algorithm/shell_edit/operator/dispose_topo.d.ts +2 -0
- package/types/brep-src/algorithm/shell_edit/operator/merge_connect_edge.d.ts +3 -0
- package/types/brep-src/algorithm/shell_edit/operator/merge_connect_face.d.ts +2 -0
- package/types/brep-src/algorithm/shell_edit/operator/merge_overlap_edge.d.ts +3 -0
- package/types/brep-src/algorithm/shell_edit/operator/merge_shell.d.ts +11 -0
- package/types/brep-src/algorithm/shell_edit/operator/merge_vertex.d.ts +2 -0
- package/types/brep-src/algorithm/shell_edit/operator/split_edge.d.ts +4 -0
- package/types/brep-src/algorithm/shell_edit/operator/split_shell.d.ts +6 -0
- package/types/brep-src/algorithm/shell_edit/pull_push_face/pull_push_face.d.ts +18 -0
- package/types/brep-src/algorithm/shell_edit/pull_push_face/pull_push_face_core.d.ts +6 -0
- package/types/brep-src/algorithm/shell_edit/pull_push_face/pull_push_face_preview.d.ts +16 -0
- package/types/brep-src/algorithm/shell_edit/pull_push_face/pull_push_face_preview_core.d.ts +24 -0
- package/types/brep-src/algorithm/shell_edit/roundinng/2d_rounding.d.ts +22 -0
- package/types/brep-src/algorithm/shell_edit/shell_modeling_base.d.ts +10 -0
- package/types/brep-src/algorithm/shell_edit/shell_modeling_result.d.ts +21 -0
- package/types/brep-src/algorithm/shell_edit/smooth/detect_loop_util.d.ts +27 -0
- package/types/brep-src/algorithm/shell_edit/smooth/shell_modeling_util.d.ts +24 -0
- package/types/brep-src/algorithm/shell_edit/smooth/smooth_util.d.ts +22 -0
- package/types/brep-src/algorithm/shell_edit/split_edge.d.ts +10 -0
- package/types/brep-src/algorithm/shell_edit.d.ts +119 -0
- package/types/brep-src/algorithm/shell_valid/base_brep_topo_error.d.ts +176 -0
- package/types/brep-src/algorithm/shell_valid/diagnose_shell.d.ts +14 -0
- package/types/brep-src/brep/brep_body.d.ts +19 -0
- package/types/brep-src/brep/coedge3d.d.ts +83 -0
- package/types/brep-src/brep/edge.d.ts +96 -0
- package/types/brep-src/brep/face.d.ts +150 -0
- package/types/brep-src/brep/shell.d.ts +166 -0
- package/types/brep-src/brep/topo_object.d.ts +40 -0
- package/types/brep-src/brep/vertex.d.ts +48 -0
- package/types/brep-src/brep/wire.d.ts +66 -0
- package/types/brep-src/continuous/continuous_edge.d.ts +17 -0
- package/types/brep-src/continuous/continuous_face.d.ts +10 -0
- package/types/brep-src/continuous/continuous_util.d.ts +60 -0
- package/types/brep-src/continuous/continuous_uv.d.ts +24 -0
- package/types/brep-src/continuous/index.d.ts +4 -0
- package/types/brep-src/index.d.ts +14 -0
- package/types/brep-src/type_define/i_types.d.ts +46 -0
- package/types/brep-src/util/util.d.ts +23 -0
- package/types/conversion/units_conversion.d.ts +14 -0
- package/types/geometry/arc2d.d.ts +249 -0
- package/types/geometry/arc3d.d.ts +204 -0
- package/types/geometry/circle3d.d.ts +92 -0
- package/types/geometry/circular_surface.d.ts +52 -0
- package/types/geometry/coord_based_surface.d.ts +25 -0
- package/types/geometry/curve.d.ts +228 -0
- package/types/geometry/curve2.d.ts +62 -0
- package/types/geometry/curve3d.d.ts +66 -0
- package/types/geometry/cylinder.d.ts +73 -0
- package/types/geometry/discrete_arrow.d.ts +3 -0
- package/types/geometry/extend_curve2.d.ts +75 -0
- package/types/geometry/geometry2d.d.ts +35 -0
- package/types/geometry/geometry3d.d.ts +36 -0
- package/types/geometry/intersect_curve3.d.ts +90 -0
- package/types/geometry/ln2.d.ts +168 -0
- package/types/geometry/ln3.d.ts +152 -0
- package/types/geometry/nurbs_curve2.d.ts +106 -0
- package/types/geometry/nurbs_curve3.d.ts +191 -0
- package/types/geometry/offset_curve2.d.ts +63 -0
- package/types/geometry/offset_curve3.d.ts +97 -0
- package/types/geometry/offset_parameter_mapper.d.ts +72 -0
- package/types/geometry/plane.d.ts +109 -0
- package/types/geometry/polyline.d.ts +12 -0
- package/types/geometry/smooth_poly2.d.ts +78 -0
- package/types/geometry/smooth_poly3.d.ts +85 -0
- package/types/geometry/surface.d.ts +173 -0
- package/types/index.d.ts +78 -0
- package/types/io/obj_parser.d.ts +4 -0
- package/types/io/svgparser.d.ts +22 -0
- package/types/loader/loader.d.ts +23 -0
- package/types/loader/register_geo.d.ts +7 -0
- package/types/math/gauss_integration.d.ts +13 -0
- package/types/math/inv_bilinear.d.ts +33 -0
- package/types/solve_equations/cubic_equation.d.ts +7 -0
- package/types/solve_equations/linear_system.d.ts +6 -0
- package/types/solve_equations/nonlinear_system.d.ts +11 -0
- package/types/solve_equations/plurality.d.ts +9 -0
- package/types/solve_equations/polynomial_equation.d.ts +6 -0
- package/types/solve_equations/quadratic_equation.d.ts +6 -0
- package/types/solve_equations/quartic_equation.d.ts +6 -0
- package/types/solve_equations/solve_equation_util.d.ts +50 -0
- package/types/test_util/loop_generator.d.ts +21 -0
- package/types/topology/evolution_map.d.ts +90 -0
- package/types/topology/loop.d.ts +50 -0
- package/types/topology/polycurve.d.ts +109 -0
- package/types/topology/polygon.d.ts +118 -0
- package/types/topology/trimmed_surface.d.ts +136 -0
- package/types/type_define/const.d.ts +18 -0
- package/types/type_define/i_element.d.ts +9 -0
- package/types/type_define/i_element_type.d.ts +34 -0
- package/types/type_define/i_geometry.d.ts +191 -0
- package/types/type_define/i_types.d.ts +280 -0
- package/types/util/array_util.d.ts +8 -0
- package/types/util/assert.d.ts +21 -0
- package/types/util/clipper2_util.d.ts +5 -0
- package/types/util/clipper_format_converter.d.ts +21 -0
- package/types/util/clipper_util.d.ts +10 -0
- package/types/util/curve_util.d.ts +72 -0
- package/types/util/geom_util.d.ts +23 -0
- package/types/util/log.d.ts +19 -0
- package/types/util/math_error.d.ts +37 -0
- package/types/util/surface_util.d.ts +13 -0
- package/types/util/util.d.ts +18 -0
- package/types/util/uv_util.d.ts +68 -0
- package/types/verb/export_verb.d.ts +2 -0
- package/types/wasm/a2d.d.ts +19 -0
- package/types/wasm/bx2.d.ts +16 -0
- package/types/wasm/c2d.d.ts +29 -0
- package/types/wasm/elli.d.ts +19 -0
- package/types/wasm/grapher2d.d.ts +39 -0
- package/types/wasm/grapherutil.d.ts +9 -0
- package/types/wasm/l2d.d.ts +14 -0
- package/types/wasm/loader.d.ts +8 -0
- package/types/wasm/pt.d.ts +19 -0
- package/types/wasm/wasm-geom.d.ts +296 -0
- package/types/wasm/wasminstance.d.ts +19 -0
- package/types/wasm/wrapper.d.ts +82 -0
- package/README.md +0 -21
- package/dist/constants/geom_type.d.ts +0 -13
- package/dist/constants/geom_type.d.ts.map +0 -1
- package/dist/constants/geom_type.js +0 -17
- package/dist/constants/math_const.d.ts +0 -9
- package/dist/constants/math_const.d.ts.map +0 -1
- package/dist/constants/math_const.js +0 -12
- package/dist/core/box2.d.ts +0 -71
- package/dist/core/box2.d.ts.map +0 -1
- package/dist/core/box2.js +0 -243
- package/dist/core/coord2d.d.ts +0 -62
- package/dist/core/coord2d.d.ts.map +0 -1
- package/dist/core/coord2d.js +0 -155
- package/dist/core/geom_base.d.ts +0 -19
- package/dist/core/geom_base.d.ts.map +0 -1
- package/dist/core/geom_base.js +0 -18
- package/dist/core/mat3.d.ts +0 -101
- package/dist/core/mat3.d.ts.map +0 -1
- package/dist/core/mat3.js +0 -290
- package/dist/core/vec2.d.ts +0 -138
- package/dist/core/vec2.d.ts.map +0 -1
- package/dist/core/vec2.js +0 -297
- package/dist/curves/arc2.d.ts +0 -49
- package/dist/curves/arc2.d.ts.map +0 -1
- package/dist/curves/arc2.js +0 -265
- package/dist/curves/bspline2.d.ts +0 -150
- package/dist/curves/bspline2.d.ts.map +0 -1
- package/dist/curves/bspline2.js +0 -793
- package/dist/curves/circle2.d.ts +0 -42
- package/dist/curves/circle2.d.ts.map +0 -1
- package/dist/curves/circle2.js +0 -135
- package/dist/curves/circle_curve2.d.ts +0 -38
- package/dist/curves/circle_curve2.d.ts.map +0 -1
- package/dist/curves/circle_curve2.js +0 -112
- package/dist/curves/curve2.d.ts +0 -214
- package/dist/curves/curve2.d.ts.map +0 -1
- package/dist/curves/curve2.js +0 -238
- package/dist/curves/ellipse2.d.ts +0 -42
- package/dist/curves/ellipse2.d.ts.map +0 -1
- package/dist/curves/ellipse2.js +0 -125
- package/dist/curves/ellipse_arc2.d.ts +0 -49
- package/dist/curves/ellipse_arc2.d.ts.map +0 -1
- package/dist/curves/ellipse_arc2.js +0 -184
- package/dist/curves/ellipse_curve2.d.ts +0 -56
- package/dist/curves/ellipse_curve2.d.ts.map +0 -1
- package/dist/curves/ellipse_curve2.js +0 -262
- package/dist/curves/interval.d.ts +0 -112
- package/dist/curves/interval.d.ts.map +0 -1
- package/dist/curves/interval.js +0 -200
- package/dist/curves/line2.d.ts +0 -64
- package/dist/curves/line2.d.ts.map +0 -1
- package/dist/curves/line2.js +0 -193
- package/dist/curves/period_interval.d.ts +0 -129
- package/dist/curves/period_interval.d.ts.map +0 -1
- package/dist/curves/period_interval.js +0 -240
- package/dist/discretize/discretize_defaults.d.ts +0 -12
- package/dist/discretize/discretize_defaults.d.ts.map +0 -1
- package/dist/discretize/discretize_defaults.js +0 -12
- package/dist/discretize/discretize_engine.d.ts +0 -33
- package/dist/discretize/discretize_engine.d.ts.map +0 -1
- package/dist/discretize/discretize_engine.js +0 -347
- package/dist/discretize/discretize_errors.d.ts +0 -15
- package/dist/discretize/discretize_errors.d.ts.map +0 -1
- package/dist/discretize/discretize_errors.js +0 -30
- package/dist/discretize/discretize_options.d.ts +0 -18
- package/dist/discretize/discretize_options.d.ts.map +0 -1
- package/dist/discretize/discretize_options.js +0 -19
- package/dist/discretize/discretize_types.d.ts +0 -36
- package/dist/discretize/discretize_types.d.ts.map +0 -1
- package/dist/discretize/discretize_types.js +0 -1
- package/dist/discretize/internal/curve_guards.d.ts +0 -35
- package/dist/discretize/internal/curve_guards.d.ts.map +0 -1
- package/dist/discretize/internal/curve_guards.js +0 -62
- package/dist/discretize/internal/postprocess.d.ts +0 -5
- package/dist/discretize/internal/postprocess.d.ts.map +0 -1
- package/dist/discretize/internal/postprocess.js +0 -109
- package/dist/discretize/internal/sampling_utils.d.ts +0 -8
- package/dist/discretize/internal/sampling_utils.d.ts.map +0 -1
- package/dist/discretize/internal/sampling_utils.js +0 -36
- package/dist/discretize/register_builtin_strategies.d.ts +0 -3
- package/dist/discretize/register_builtin_strategies.d.ts.map +0 -1
- package/dist/discretize/register_builtin_strategies.js +0 -10
- package/dist/discretize/strategies/bspline_strategy.d.ts +0 -4
- package/dist/discretize/strategies/bspline_strategy.d.ts.map +0 -1
- package/dist/discretize/strategies/bspline_strategy.js +0 -115
- package/dist/discretize/strategies/circle_strategy.d.ts +0 -7
- package/dist/discretize/strategies/circle_strategy.d.ts.map +0 -1
- package/dist/discretize/strategies/circle_strategy.js +0 -55
- package/dist/discretize/strategies/ellipse_strategy.d.ts +0 -7
- package/dist/discretize/strategies/ellipse_strategy.d.ts.map +0 -1
- package/dist/discretize/strategies/ellipse_strategy.js +0 -86
- package/dist/discretize/strategies/line_strategy.d.ts +0 -4
- package/dist/discretize/strategies/line_strategy.d.ts.map +0 -1
- package/dist/discretize/strategies/line_strategy.js +0 -40
- package/dist/discretize/strategy_registry.d.ts +0 -9
- package/dist/discretize/strategy_registry.d.ts.map +0 -1
- package/dist/discretize/strategy_registry.js +0 -34
- package/dist/index.d.ts +0 -30
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -24
- package/dist/intersections/analytic_x_algorithm.d.ts +0 -10
- package/dist/intersections/analytic_x_algorithm.d.ts.map +0 -1
- package/dist/intersections/analytic_x_algorithm.js +0 -83
- package/dist/intersections/curve_x_engine.d.ts +0 -9
- package/dist/intersections/curve_x_engine.d.ts.map +0 -1
- package/dist/intersections/curve_x_engine.js +0 -27
- package/dist/intersections/index.d.ts +0 -5
- package/dist/intersections/index.d.ts.map +0 -1
- package/dist/intersections/index.js +0 -11
- package/dist/intersections/internal/certification.d.ts +0 -34
- package/dist/intersections/internal/certification.d.ts.map +0 -1
- package/dist/intersections/internal/certification.js +0 -238
- package/dist/intersections/internal/interval_clipping.d.ts +0 -29
- package/dist/intersections/internal/interval_clipping.d.ts.map +0 -1
- package/dist/intersections/internal/interval_clipping.js +0 -123
- package/dist/intersections/internal/kind.d.ts +0 -4
- package/dist/intersections/internal/kind.d.ts.map +0 -1
- package/dist/intersections/internal/kind.js +0 -16
- package/dist/intersections/internal/pair.d.ts +0 -9
- package/dist/intersections/internal/pair.d.ts.map +0 -1
- package/dist/intersections/internal/pair.js +0 -14
- package/dist/intersections/internal/result.d.ts +0 -20
- package/dist/intersections/internal/result.d.ts.map +0 -1
- package/dist/intersections/internal/result.js +0 -125
- package/dist/intersections/internal/sampling.d.ts +0 -15
- package/dist/intersections/internal/sampling.d.ts.map +0 -1
- package/dist/intersections/internal/sampling.js +0 -131
- package/dist/intersections/internal/segment.d.ts +0 -32
- package/dist/intersections/internal/segment.d.ts.map +0 -1
- package/dist/intersections/internal/segment.js +0 -137
- package/dist/intersections/internal/tolerance.d.ts +0 -10
- package/dist/intersections/internal/tolerance.d.ts.map +0 -1
- package/dist/intersections/internal/tolerance.js +0 -20
- package/dist/intersections/intersector.d.ts +0 -6
- package/dist/intersections/intersector.d.ts.map +0 -1
- package/dist/intersections/intersector.js +0 -1
- package/dist/intersections/numeric_x_algorithm.d.ts +0 -10
- package/dist/intersections/numeric_x_algorithm.d.ts.map +0 -1
- package/dist/intersections/numeric_x_algorithm.js +0 -73
- package/dist/intersections/solvers/bspline_self_solver.d.ts +0 -7
- package/dist/intersections/solvers/bspline_self_solver.d.ts.map +0 -1
- package/dist/intersections/solvers/bspline_self_solver.js +0 -308
- package/dist/intersections/solvers/line_line_pair_solver.d.ts +0 -7
- package/dist/intersections/solvers/line_line_pair_solver.d.ts.map +0 -1
- package/dist/intersections/solvers/line_line_pair_solver.js +0 -35
- package/dist/intersections/solvers/pair_solvers.d.ts +0 -94
- package/dist/intersections/solvers/pair_solvers.d.ts.map +0 -1
- package/dist/intersections/solvers/pair_solvers.js +0 -1078
- package/dist/intersections/solvers/polyline_pair_intersector.d.ts +0 -51
- package/dist/intersections/solvers/polyline_pair_intersector.d.ts.map +0 -1
- package/dist/intersections/solvers/polyline_pair_intersector.js +0 -731
- package/dist/intersections/types.d.ts +0 -11
- package/dist/intersections/types.d.ts.map +0 -1
- package/dist/intersections/types.js +0 -1
- package/dist/serialize/dump_types.d.ts +0 -101
- package/dist/serialize/dump_types.d.ts.map +0 -1
- package/dist/serialize/dump_types.js +0 -5
- package/dist/serialize/geom_mgr.d.ts +0 -24
- package/dist/serialize/geom_mgr.d.ts.map +0 -1
- package/dist/serialize/geom_mgr.js +0 -30
- package/dist/types/type_define.d.ts +0 -29
- package/dist/types/type_define.d.ts.map +0 -1
- package/dist/types/type_define.js +0 -10
- package/dist/types/type_guard.d.ts +0 -46
- package/dist/types/type_guard.d.ts.map +0 -1
- package/dist/types/type_guard.js +0 -5
- package/dist/utils/math_error.d.ts +0 -16
- package/dist/utils/math_error.d.ts.map +0 -1
- package/dist/utils/math_error.js +0 -35
- package/dist/utils/math_utils.d.ts +0 -9
- package/dist/utils/math_utils.d.ts.map +0 -1
- package/dist/utils/math_utils.js +0 -25
- package/dist/utils/precision.d.ts +0 -29
- package/dist/utils/precision.d.ts.map +0 -1
- package/dist/utils/precision.js +0 -44
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Box2 } from '../core/box2';
|
|
2
|
-
import { Vec2 } from '../core/vec2';
|
|
3
|
-
import type { IClosestPointResult } from '../types/type_define';
|
|
4
|
-
import { Curve2 } from './curve2';
|
|
5
|
-
import { Interval } from './interval';
|
|
6
|
-
/**
|
|
7
|
-
* 椭圆族曲线基类(整椭圆与椭圆弧)。
|
|
8
|
-
*/
|
|
9
|
-
export declare abstract class EllipseCurve2 extends Curve2 {
|
|
10
|
-
protected _center: Vec2;
|
|
11
|
-
protected _rx: number;
|
|
12
|
-
protected _ry: number;
|
|
13
|
-
protected _rotation: number;
|
|
14
|
-
constructor(center: Vec2, rx: number, ry: number, rotation?: number);
|
|
15
|
-
get center(): Vec2;
|
|
16
|
-
get rx(): number;
|
|
17
|
-
get ry(): number;
|
|
18
|
-
get rotation(): number;
|
|
19
|
-
pointAt(u: number): Vec2;
|
|
20
|
-
tangentAt(u: number): Vec2;
|
|
21
|
-
derivatives(u: number, n: number): Vec2[];
|
|
22
|
-
curvatureAt(u: number): number;
|
|
23
|
-
length(range?: Interval): number;
|
|
24
|
-
lengthAtParam(u: number): number;
|
|
25
|
-
paramAtLength(s: number, tol?: number): number;
|
|
26
|
-
closestPoint(p: Vec2, tol?: number): IClosestPointResult;
|
|
27
|
-
boundingBox(): Box2;
|
|
28
|
-
/** 椭圆族结构有效性检查 */
|
|
29
|
-
protected isEllipseStructValid(eps?: number): boolean;
|
|
30
|
-
/** 将存储参数转换为椭圆角参数 */
|
|
31
|
-
protected abstract paramToAngle(u: number): number;
|
|
32
|
-
/** 将椭圆角参数转换回存储参数 */
|
|
33
|
-
protected abstract angleToParam(theta: number): number;
|
|
34
|
-
/** d(theta)/d(u),仅允许 +1 或 -1 */
|
|
35
|
-
protected abstract angleDerivativeSign(): 1 | -1;
|
|
36
|
-
protected pointAtAngle(theta: number): Vec2;
|
|
37
|
-
protected derivativeFromAngle(theta: number, order: number, sign: 1 | -1): Vec2;
|
|
38
|
-
protected normalizeParamForEval(u: number): number;
|
|
39
|
-
protected integrateLength(u0: number, u1: number, depth?: number): number;
|
|
40
|
-
protected gaussLegendre5(f: (u: number) => number, a: number, b: number): number;
|
|
41
|
-
protected compareParamForTieBreak(a: number, b: number): number;
|
|
42
|
-
/**
|
|
43
|
-
* 对当前椭圆应用仿射变换,并从变换后的形状提取规范参数
|
|
44
|
-
* (center、rx、ry、rotation)。
|
|
45
|
-
*/
|
|
46
|
-
protected transformedEllipseParams(m: import('../core/mat3').Mat3): {
|
|
47
|
-
center: Vec2;
|
|
48
|
-
rx: number;
|
|
49
|
-
ry: number;
|
|
50
|
-
rotation: number;
|
|
51
|
-
mirrored: boolean;
|
|
52
|
-
};
|
|
53
|
-
/** 将椭圆上的点反解为角参数。 */
|
|
54
|
-
protected angleFromPointOnEllipse(p: Vec2, center: Vec2, rx: number, ry: number, rotation: number): number;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=ellipse_curve2.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ellipse_curve2.d.ts","sourceRoot":"","sources":["../../src/curves/ellipse_curve2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAGnC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAGrC;;GAEG;AACH,8BAAsB,aAAc,SAAQ,MAAM;IAC9C,SAAS,CAAC,OAAO,EAAE,IAAI,CAAA;IACvB,SAAS,CAAC,GAAG,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,GAAG,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,SAAS,EAAE,MAAM,CAAA;gBAEf,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,SAAI;IAY9D,IAAW,MAAM,SAEhB;IAED,IAAW,EAAE,WAEZ;IAED,IAAW,EAAE,WAEZ;IAED,IAAW,QAAQ,WAElB;IAEe,OAAO,CAAC,CAAC,EAAE,MAAM;IAKjB,SAAS,CAAC,CAAC,EAAE,MAAM;IAKnB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAiBhC,WAAW,CAAC,CAAC,EAAE,MAAM;IAQrB,MAAM,CAAC,KAAK,CAAC,EAAE,QAAQ;IAQvB,aAAa,CAAC,CAAC,EAAE,MAAM;IAKvB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,SAA6B;IA6BzD,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,SAA6B,GAAG,mBAAmB;IAe5E,WAAW;IAuB3B,iBAAiB;IACjB,SAAS,CAAC,oBAAoB,CAAC,GAAG,SAA6B;IAU/D,oBAAoB;IACpB,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAElD,oBAAoB;IACpB,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAEtD,gCAAgC;IAChC,SAAS,CAAC,QAAQ,CAAC,mBAAmB,IAAI,CAAC,GAAG,CAAC,CAAC;IAEhD,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM;IAepC,SAAS,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IAkCxE,SAAS,CAAC,qBAAqB,CAAC,CAAC,EAAE,MAAM;IAczC,SAAS,CAAC,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,MAAM;IAoBpE,SAAS,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAyBvE,SAAS,CAAC,uBAAuB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAStD;;;OAGG;IACH,SAAS,CAAC,wBAAwB,CAAC,CAAC,EAAE,OAAO,cAAc,EAAE,IAAI;;;;;;;IAiCjE,oBAAoB;IACpB,SAAS,CAAC,uBAAuB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CASpG"}
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import { Box2 } from '../core/box2';
|
|
2
|
-
import { Vec2 } from '../core/vec2';
|
|
3
|
-
import { MathError } from '../utils/math_error';
|
|
4
|
-
import { Precision } from '../utils/precision';
|
|
5
|
-
import { Curve2 } from './curve2';
|
|
6
|
-
import { PeriodInterval } from './period_interval';
|
|
7
|
-
/**
|
|
8
|
-
* 椭圆族曲线基类(整椭圆与椭圆弧)。
|
|
9
|
-
*/
|
|
10
|
-
export class EllipseCurve2 extends Curve2 {
|
|
11
|
-
constructor(center, rx, ry, rotation = 0) {
|
|
12
|
-
super();
|
|
13
|
-
MathError.assert(Number.isFinite(center.x) && Number.isFinite(center.y), 'EllipseCurve2: center must be finite');
|
|
14
|
-
MathError.assert(Number.isFinite(rx) && rx > 0, 'EllipseCurve2: rx must be > 0');
|
|
15
|
-
MathError.assert(Number.isFinite(ry) && ry > 0, 'EllipseCurve2: ry must be > 0');
|
|
16
|
-
MathError.assert(Number.isFinite(rotation), 'EllipseCurve2: rotation must be finite');
|
|
17
|
-
this._center = center.clone();
|
|
18
|
-
this._rx = rx;
|
|
19
|
-
this._ry = ry;
|
|
20
|
-
this._rotation = rotation;
|
|
21
|
-
}
|
|
22
|
-
get center() {
|
|
23
|
-
return this._center.clone();
|
|
24
|
-
}
|
|
25
|
-
get rx() {
|
|
26
|
-
return this._rx;
|
|
27
|
-
}
|
|
28
|
-
get ry() {
|
|
29
|
-
return this._ry;
|
|
30
|
-
}
|
|
31
|
-
get rotation() {
|
|
32
|
-
return this._rotation;
|
|
33
|
-
}
|
|
34
|
-
pointAt(u) {
|
|
35
|
-
const uu = this.normalizeParamForEval(u);
|
|
36
|
-
return this.pointAtAngle(this.paramToAngle(uu));
|
|
37
|
-
}
|
|
38
|
-
tangentAt(u) {
|
|
39
|
-
const uu = this.normalizeParamForEval(u);
|
|
40
|
-
return this.derivativeFromAngle(this.paramToAngle(uu), 1, this.angleDerivativeSign());
|
|
41
|
-
}
|
|
42
|
-
derivatives(u, n) {
|
|
43
|
-
MathError.assert(Number.isInteger(n) && n >= 0, 'EllipseCurve2.derivatives: n must be a non-negative integer');
|
|
44
|
-
const uu = this.normalizeParamForEval(u);
|
|
45
|
-
const theta = this.paramToAngle(uu);
|
|
46
|
-
const sign = this.angleDerivativeSign();
|
|
47
|
-
const ret = [];
|
|
48
|
-
for (let k = 0; k <= n; k++) {
|
|
49
|
-
if (k === 0) {
|
|
50
|
-
ret.push(this.pointAtAngle(theta));
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
ret.push(this.derivativeFromAngle(theta, k, sign));
|
|
54
|
-
}
|
|
55
|
-
return ret;
|
|
56
|
-
}
|
|
57
|
-
curvatureAt(u) {
|
|
58
|
-
const d1 = this.derivativeAt(u, 1);
|
|
59
|
-
const d2 = this.derivativeAt(u, 2);
|
|
60
|
-
const denom = Math.pow(d1.lenSq(), 1.5);
|
|
61
|
-
MathError.assert(denom > Precision.CURVE_NEWTON_EPS, 'EllipseCurve2.curvatureAt: tangent is degenerate');
|
|
62
|
-
return Math.abs(d1.cross(d2)) / denom;
|
|
63
|
-
}
|
|
64
|
-
length(range) {
|
|
65
|
-
if (!range) {
|
|
66
|
-
return this.integrateLength(this._range.start, this._range.end);
|
|
67
|
-
}
|
|
68
|
-
this._range.assertContainsRange(range, Precision.CURVE_PARAM_EPS);
|
|
69
|
-
return this.integrateLength(range.start, range.end);
|
|
70
|
-
}
|
|
71
|
-
lengthAtParam(u) {
|
|
72
|
-
const uu = this.normalizeParamForEval(u);
|
|
73
|
-
return this.integrateLength(this._range.start, uu);
|
|
74
|
-
}
|
|
75
|
-
paramAtLength(s, tol = Precision.CURVE_LENGTH_EPS) {
|
|
76
|
-
MathError.assert(Number.isFinite(tol) && tol > 0, 'EllipseCurve2.paramAtLength: tol must be > 0');
|
|
77
|
-
const total = this.length();
|
|
78
|
-
const start = this._range.start;
|
|
79
|
-
const end = this._range.end;
|
|
80
|
-
MathError.assert(s >= -tol && s <= total + tol, `EllipseCurve2.paramAtLength: s out of range [0, ${total}]`);
|
|
81
|
-
if (s <= tol)
|
|
82
|
-
return start;
|
|
83
|
-
if (total - s <= tol)
|
|
84
|
-
return end;
|
|
85
|
-
const target = Math.min(total, Math.max(0, s));
|
|
86
|
-
// 与 B-spline 保持同一套求解策略:Newton 优先,失败时回退二分。
|
|
87
|
-
return this.solveParamByHybridNewton(target, start, end, tol, (u) => this.integrateLength(start, u), (u) => this.tangentAt(u).len(), 'EllipseCurve2.paramAtLength: failed to converge', start + (target / total) * (end - start));
|
|
88
|
-
}
|
|
89
|
-
closestPoint(p, tol = Precision.CURVE_LENGTH_EPS) {
|
|
90
|
-
MathError.assert(Number.isFinite(tol) && tol > 0, 'EllipseCurve2.closestPoint: tol must be > 0');
|
|
91
|
-
// 椭圆/椭圆弧都走统一最近点模板,tie-break 由子类参数语义决定。
|
|
92
|
-
return this.solveClosestPointBySampleNewton(p, tol, 96, (u) => this.pointAt(u), (u) => this.derivativeAt(u, 1), (u) => this.derivativeAt(u, 2), 'EllipseCurve2.closestPoint: failed to converge', (a, b) => this.compareParamForTieBreak(a, b));
|
|
93
|
-
}
|
|
94
|
-
boundingBox() {
|
|
95
|
-
const points = [
|
|
96
|
-
this.pointAt(this._range.start),
|
|
97
|
-
this.pointAt(this._range.end),
|
|
98
|
-
];
|
|
99
|
-
const c = Math.cos(this._rotation);
|
|
100
|
-
const s = Math.sin(this._rotation);
|
|
101
|
-
const tx = Math.atan2(-s * this._ry, c * this._rx);
|
|
102
|
-
const ty = Math.atan2(c * this._ry, s * this._rx);
|
|
103
|
-
const candidates = [tx, tx + Math.PI, ty, ty + Math.PI];
|
|
104
|
-
for (const theta of candidates) {
|
|
105
|
-
const u = this.angleToParam(theta);
|
|
106
|
-
if (this.containsParam(u)) {
|
|
107
|
-
points.push(this.pointAt(u));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return Box2.fromPoints(points);
|
|
111
|
-
}
|
|
112
|
-
/** 椭圆族结构有效性检查 */
|
|
113
|
-
isEllipseStructValid(eps = Precision.CURVE_LENGTH_EPS) {
|
|
114
|
-
return Number.isFinite(this._center.x) &&
|
|
115
|
-
Number.isFinite(this._center.y) &&
|
|
116
|
-
Number.isFinite(this._rx) &&
|
|
117
|
-
Number.isFinite(this._ry) &&
|
|
118
|
-
Number.isFinite(this._rotation) &&
|
|
119
|
-
this._rx > eps &&
|
|
120
|
-
this._ry > eps;
|
|
121
|
-
}
|
|
122
|
-
pointAtAngle(theta) {
|
|
123
|
-
const c = Math.cos(this._rotation);
|
|
124
|
-
const s = Math.sin(this._rotation);
|
|
125
|
-
const ct = Math.cos(theta);
|
|
126
|
-
const st = Math.sin(theta);
|
|
127
|
-
const lx = this._rx * ct;
|
|
128
|
-
const ly = this._ry * st;
|
|
129
|
-
return new Vec2(this._center.x + c * lx - s * ly, this._center.y + s * lx + c * ly);
|
|
130
|
-
}
|
|
131
|
-
derivativeFromAngle(theta, order, sign) {
|
|
132
|
-
const c = Math.cos(this._rotation);
|
|
133
|
-
const s = Math.sin(this._rotation);
|
|
134
|
-
const ct = Math.cos(theta);
|
|
135
|
-
const st = Math.sin(theta);
|
|
136
|
-
let lx = 0;
|
|
137
|
-
let ly = 0;
|
|
138
|
-
const phase = order % 4;
|
|
139
|
-
switch (phase) {
|
|
140
|
-
case 0:
|
|
141
|
-
lx = this._rx * ct;
|
|
142
|
-
ly = this._ry * st;
|
|
143
|
-
break;
|
|
144
|
-
case 1:
|
|
145
|
-
lx = -this._rx * st;
|
|
146
|
-
ly = this._ry * ct;
|
|
147
|
-
break;
|
|
148
|
-
case 2:
|
|
149
|
-
lx = -this._rx * ct;
|
|
150
|
-
ly = -this._ry * st;
|
|
151
|
-
break;
|
|
152
|
-
default:
|
|
153
|
-
lx = this._rx * st;
|
|
154
|
-
ly = -this._ry * ct;
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
const signPow = sign === 1 ? 1 : (order % 2 === 0 ? 1 : -1);
|
|
158
|
-
const x = (c * lx - s * ly) * signPow;
|
|
159
|
-
const y = (s * lx + c * ly) * signPow;
|
|
160
|
-
return new Vec2(x, y);
|
|
161
|
-
}
|
|
162
|
-
normalizeParamForEval(u) {
|
|
163
|
-
this._range.assertContains(u, Precision.CURVE_PARAM_EPS);
|
|
164
|
-
const start = this._range.start;
|
|
165
|
-
const end = this._range.end;
|
|
166
|
-
if (Math.abs(u - start) <= Precision.CURVE_PARAM_EPS)
|
|
167
|
-
return start;
|
|
168
|
-
if (Math.abs(u - end) <= Precision.CURVE_PARAM_EPS)
|
|
169
|
-
return end;
|
|
170
|
-
if (this._range instanceof PeriodInterval) {
|
|
171
|
-
return this._range.normalizeInPeriod(u, start);
|
|
172
|
-
}
|
|
173
|
-
return u;
|
|
174
|
-
}
|
|
175
|
-
integrateLength(u0, u1, depth = 0) {
|
|
176
|
-
if (u1 < u0)
|
|
177
|
-
return 0;
|
|
178
|
-
const f = (u) => this.tangentAt(u).len();
|
|
179
|
-
const whole = this.gaussLegendre5(f, u0, u1);
|
|
180
|
-
if (depth >= Precision.CURVE_INTEGRAL_MAX_DEPTH) {
|
|
181
|
-
return whole;
|
|
182
|
-
}
|
|
183
|
-
const mid = (u0 + u1) * 0.5;
|
|
184
|
-
const left = this.gaussLegendre5(f, u0, mid);
|
|
185
|
-
const right = this.gaussLegendre5(f, mid, u1);
|
|
186
|
-
const err = Math.abs((left + right) - whole);
|
|
187
|
-
if (err <= Precision.CURVE_LENGTH_EPS) {
|
|
188
|
-
return left + right;
|
|
189
|
-
}
|
|
190
|
-
return this.integrateLength(u0, mid, depth + 1) + this.integrateLength(mid, u1, depth + 1);
|
|
191
|
-
}
|
|
192
|
-
gaussLegendre5(f, a, b) {
|
|
193
|
-
const nodes = [
|
|
194
|
-
0,
|
|
195
|
-
-0.5384693101056831,
|
|
196
|
-
0.5384693101056831,
|
|
197
|
-
-0.906179845938664,
|
|
198
|
-
0.906179845938664,
|
|
199
|
-
];
|
|
200
|
-
const weights = [
|
|
201
|
-
0.5688888888888889,
|
|
202
|
-
0.47862867049936647,
|
|
203
|
-
0.47862867049936647,
|
|
204
|
-
0.23692688505618908,
|
|
205
|
-
0.23692688505618908,
|
|
206
|
-
];
|
|
207
|
-
const c1 = (b - a) * 0.5;
|
|
208
|
-
const c2 = (b + a) * 0.5;
|
|
209
|
-
let sum = 0;
|
|
210
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
211
|
-
sum += weights[i] * f(c1 * nodes[i] + c2);
|
|
212
|
-
}
|
|
213
|
-
return c1 * sum;
|
|
214
|
-
}
|
|
215
|
-
compareParamForTieBreak(a, b) {
|
|
216
|
-
if (this._range instanceof PeriodInterval) {
|
|
217
|
-
const aa = this._range.normalizeInPeriod(a, this._range.start);
|
|
218
|
-
const bb = this._range.normalizeInPeriod(b, this._range.start);
|
|
219
|
-
return aa - bb;
|
|
220
|
-
}
|
|
221
|
-
return a - b;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* 对当前椭圆应用仿射变换,并从变换后的形状提取规范参数
|
|
225
|
-
* (center、rx、ry、rotation)。
|
|
226
|
-
*/
|
|
227
|
-
transformedEllipseParams(m) {
|
|
228
|
-
const me = m.toArray();
|
|
229
|
-
const a = me[0], b = me[1], c = me[3], d = me[4];
|
|
230
|
-
const cr = Math.cos(this._rotation);
|
|
231
|
-
const sr = Math.sin(this._rotation);
|
|
232
|
-
const ex = new Vec2(this._rx * cr, this._rx * sr);
|
|
233
|
-
const ey = new Vec2(-this._ry * sr, this._ry * cr);
|
|
234
|
-
const vx = new Vec2(a * ex.x + b * ex.y, c * ex.x + d * ex.y);
|
|
235
|
-
const vy = new Vec2(a * ey.x + b * ey.y, c * ey.x + d * ey.y);
|
|
236
|
-
const gxx = vx.x * vx.x + vy.x * vy.x;
|
|
237
|
-
const gxy = vx.x * vx.y + vy.x * vy.y;
|
|
238
|
-
const gyy = vx.y * vx.y + vy.y * vy.y;
|
|
239
|
-
const trace = gxx + gyy;
|
|
240
|
-
const delta = Math.sqrt(Math.max(0, (gxx - gyy) * (gxx - gyy) + 4 * gxy * gxy));
|
|
241
|
-
let lambdaMax = (trace + delta) * 0.5;
|
|
242
|
-
let lambdaMin = (trace - delta) * 0.5;
|
|
243
|
-
lambdaMax = Math.max(0, lambdaMax);
|
|
244
|
-
lambdaMin = Math.max(0, lambdaMin);
|
|
245
|
-
const rx = Math.sqrt(lambdaMax);
|
|
246
|
-
const ry = Math.sqrt(lambdaMin);
|
|
247
|
-
const rotation = 0.5 * Math.atan2(2 * gxy, gxx - gyy);
|
|
248
|
-
const center = m.transformedPoint(this._center);
|
|
249
|
-
const mirrored = a * d - b * c < 0;
|
|
250
|
-
return { center, rx, ry, rotation, mirrored };
|
|
251
|
-
}
|
|
252
|
-
/** 将椭圆上的点反解为角参数。 */
|
|
253
|
-
angleFromPointOnEllipse(p, center, rx, ry, rotation) {
|
|
254
|
-
const dx = p.x - center.x;
|
|
255
|
-
const dy = p.y - center.y;
|
|
256
|
-
const c = Math.cos(rotation);
|
|
257
|
-
const s = Math.sin(rotation);
|
|
258
|
-
const lx = c * dx + s * dy;
|
|
259
|
-
const ly = -s * dx + c * dy;
|
|
260
|
-
return Math.atan2(ly / ry, lx / rx);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
export declare class Interval {
|
|
2
|
-
/**
|
|
3
|
-
* 返回数学无界区间。
|
|
4
|
-
* @returns 取值范围为 `[-Infinity, +Infinity]` 的区间实例。
|
|
5
|
-
*/
|
|
6
|
-
static infinite(): Interval;
|
|
7
|
-
/**
|
|
8
|
-
* 归并多段区间。
|
|
9
|
-
* @param intervals 待归并区间数组,可无序。
|
|
10
|
-
* @param eps 判断端点相接时使用的容差。
|
|
11
|
-
* @returns 按 `start` 升序、且相交或相接段已合并的新区间数组。
|
|
12
|
-
*/
|
|
13
|
-
static merge(intervals: readonly Interval[], eps?: number): Interval[];
|
|
14
|
-
/** 区间起点(闭区间) */
|
|
15
|
-
protected _start: number;
|
|
16
|
-
/** 区间终点(闭区间) */
|
|
17
|
-
protected _end: number;
|
|
18
|
-
/**
|
|
19
|
-
* 创建闭区间 `[start, end]`。
|
|
20
|
-
* @param start 区间起点。
|
|
21
|
-
* @param end 区间终点;若小于 `start` 会在内部自动交换顺序。
|
|
22
|
-
*/
|
|
23
|
-
constructor(start?: number, end?: number);
|
|
24
|
-
/** 区间起点 */
|
|
25
|
-
get start(): number;
|
|
26
|
-
/** 区间终点 */
|
|
27
|
-
get end(): number;
|
|
28
|
-
/**
|
|
29
|
-
* 计算区间长度。
|
|
30
|
-
* @returns `end - start`,点区间返回 `0`。
|
|
31
|
-
*/
|
|
32
|
-
length(): number;
|
|
33
|
-
/**
|
|
34
|
-
* 判断参数是否落在区间内。
|
|
35
|
-
* @param u 待判断参数。
|
|
36
|
-
* @param eps 闭区间边界比较容差。
|
|
37
|
-
* @returns 在 `[start - eps, end + eps]` 内返回 `true`,否则返回 `false`。
|
|
38
|
-
*/
|
|
39
|
-
contains(u: number, eps?: number): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* 断言参数在区间内。
|
|
42
|
-
* @param u 待校验参数。
|
|
43
|
-
* @param eps 区间边界比较容差。
|
|
44
|
-
* @returns 当前区间实例。
|
|
45
|
-
* @throws MathError 参数不在区间内时抛错。
|
|
46
|
-
*/
|
|
47
|
-
assertContains(u: number, eps?: number): this;
|
|
48
|
-
/**
|
|
49
|
-
* 断言子区间完整落在当前区间内。
|
|
50
|
-
* @param range 待校验子区间。
|
|
51
|
-
* @param eps 区间边界比较容差。
|
|
52
|
-
* @returns 当前区间实例。
|
|
53
|
-
* @throws MathError 子区间超出当前区间时抛错。
|
|
54
|
-
*/
|
|
55
|
-
assertContainsRange(range: Interval, eps?: number): this;
|
|
56
|
-
/**
|
|
57
|
-
* 将参数钳制到区间范围内。
|
|
58
|
-
* @param u 输入参数。
|
|
59
|
-
* @returns 小于起点返回 `start`,大于终点返回 `end`,否则返回自身。
|
|
60
|
-
*/
|
|
61
|
-
clamp(u: number): number;
|
|
62
|
-
/**
|
|
63
|
-
* 判断两个区间是否近似相等。
|
|
64
|
-
* @param other 另一个区间。
|
|
65
|
-
* @param eps 端点比较容差。
|
|
66
|
-
* @returns 起点和终点都在容差内时返回 `true`。
|
|
67
|
-
*/
|
|
68
|
-
equals(other: Interval, eps?: number): boolean;
|
|
69
|
-
/**
|
|
70
|
-
* 原地扩展区间。
|
|
71
|
-
* @param delta 扩展量;`delta > 0` 表示扩大,`delta < 0` 表示收缩。
|
|
72
|
-
* @returns 当前实例(便于链式调用)。
|
|
73
|
-
*/
|
|
74
|
-
expand(delta: number): this;
|
|
75
|
-
/**
|
|
76
|
-
* 返回扩展后的新区间,不修改当前实例。
|
|
77
|
-
* @param delta 扩展量;语义同 `expand`。
|
|
78
|
-
* @returns 新的区间实例。
|
|
79
|
-
*/
|
|
80
|
-
expanded(delta: number): Interval;
|
|
81
|
-
/**
|
|
82
|
-
* 计算与另一区间的交集。
|
|
83
|
-
* @param other 参与求交的区间。
|
|
84
|
-
* @param eps 判定“相离/相接”时的容差。
|
|
85
|
-
* @returns 无交集返回 `[]`;有交集返回单段 `[Interval]`;端点相接返回点区间。
|
|
86
|
-
*/
|
|
87
|
-
intersect(other: Interval, eps?: number): Interval[];
|
|
88
|
-
/**
|
|
89
|
-
* 计算与另一区间的并集(普通区间语义)。
|
|
90
|
-
* @param other 参与求并的区间。
|
|
91
|
-
* @returns 单段最小覆盖区间数组(保持与 `PeriodInterval` 的返回形态一致)。
|
|
92
|
-
*/
|
|
93
|
-
union(other: Interval): Interval[];
|
|
94
|
-
/**
|
|
95
|
-
* 以参数 `u` 切分区间。
|
|
96
|
-
* @param u 切分参数。
|
|
97
|
-
* @param eps 边界判定容差。
|
|
98
|
-
* @returns `u` 在边界或区间外返回 `[]`;在区间内部返回两段子区间。
|
|
99
|
-
*/
|
|
100
|
-
split(u: number, eps?: number): Interval[];
|
|
101
|
-
/**
|
|
102
|
-
* 克隆当前区间。
|
|
103
|
-
* @returns 与当前区间数值相同的新实例。
|
|
104
|
-
*/
|
|
105
|
-
clone(): Interval;
|
|
106
|
-
/**
|
|
107
|
-
* 规范化区间顺序,使 `_start <= _end`。
|
|
108
|
-
* 仅在内部使用。
|
|
109
|
-
*/
|
|
110
|
-
protected sortRange(): void;
|
|
111
|
-
}
|
|
112
|
-
//# sourceMappingURL=interval.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interval.d.ts","sourceRoot":"","sources":["../../src/curves/interval.ts"],"names":[],"mappings":"AASA,qBAAa,QAAQ;IACjB;;;OAGG;WACW,QAAQ;IAItB;;;;;OAKG;WACW,KAAK,CAAC,SAAS,EAAE,SAAS,QAAQ,EAAE,EAAE,GAAG,SAAgB,GAAG,QAAQ,EAAE;IAoBpF,gBAAgB;IAChB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAA;IAExB,gBAAgB;IAChB,SAAS,CAAC,IAAI,EAAE,MAAM,CAAA;IAEtB;;;;OAIG;gBACS,KAAK,SAAI,EAAE,GAAG,SAAI;IAO9B,WAAW;IACX,IAAW,KAAK,WAEf;IAED,WAAW;IACX,IAAW,GAAG,WAEb;IAED;;;OAGG;IACI,MAAM;IAIb;;;;;OAKG;IACI,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,SAAgB;IAI9C;;;;;;OAMG;IACI,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,SAAgB;IAKpD;;;;;;OAMG;IACI,mBAAmB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,SAAgB;IAQ/D;;;;OAIG;IACI,KAAK,CAAC,CAAC,EAAE,MAAM;IAMtB;;;;;OAKG;IACI,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,SAAgB;IAKlD;;;;OAIG;IACI,MAAM,CAAC,KAAK,EAAE,MAAM;IAU3B;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM;IAI7B;;;;;OAKG;IACI,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,SAAgB,GAAG,QAAQ,EAAE;IAWlE;;;;OAIG;IACI,KAAK,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,EAAE;IAOzC;;;;;OAKG;IACI,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,SAAgB,GAAG,QAAQ,EAAE;IAQxD;;;OAGG;IACI,KAAK;IAIZ;;;OAGG;IACH,SAAS,CAAC,SAAS;CAMtB"}
|
package/dist/curves/interval.js
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Linea Math - Curves
|
|
3
|
-
* Interval: 一维闭区间 [start, end]
|
|
4
|
-
*/
|
|
5
|
-
import { MathError } from '../utils/math_error';
|
|
6
|
-
import { Precision } from '../utils/precision';
|
|
7
|
-
import { MathConst } from '../constants/math_const';
|
|
8
|
-
export class Interval {
|
|
9
|
-
/**
|
|
10
|
-
* 返回数学无界区间。
|
|
11
|
-
* @returns 取值范围为 `[-Infinity, +Infinity]` 的区间实例。
|
|
12
|
-
*/
|
|
13
|
-
static infinite() {
|
|
14
|
-
return new Interval(MathConst.MIN, MathConst.MAX);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* 归并多段区间。
|
|
18
|
-
* @param intervals 待归并区间数组,可无序。
|
|
19
|
-
* @param eps 判断端点相接时使用的容差。
|
|
20
|
-
* @returns 按 `start` 升序、且相交或相接段已合并的新区间数组。
|
|
21
|
-
*/
|
|
22
|
-
static merge(intervals, eps = Precision.EPS) {
|
|
23
|
-
for (const it of intervals) {
|
|
24
|
-
MathError.assert(!Number.isNaN(it.start) && !Number.isNaN(it.end), 'Interval.merge: interval endpoint must not be NaN');
|
|
25
|
-
}
|
|
26
|
-
if (intervals.length === 0)
|
|
27
|
-
return [];
|
|
28
|
-
const sorted = [...intervals].sort((a, b) => a.start - b.start);
|
|
29
|
-
const ret = [sorted[0].clone()];
|
|
30
|
-
for (let i = 1; i < sorted.length; i++) {
|
|
31
|
-
const cur = sorted[i];
|
|
32
|
-
const last = ret[ret.length - 1];
|
|
33
|
-
if (cur.start <= last.end + eps) {
|
|
34
|
-
ret[ret.length - 1] = new Interval(last.start, Math.max(last.end, cur.end));
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
ret.push(cur.clone());
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return ret;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 创建闭区间 `[start, end]`。
|
|
44
|
-
* @param start 区间起点。
|
|
45
|
-
* @param end 区间终点;若小于 `start` 会在内部自动交换顺序。
|
|
46
|
-
*/
|
|
47
|
-
constructor(start = 0, end = 0) {
|
|
48
|
-
MathError.assert(!Number.isNaN(start) && !Number.isNaN(end), 'Interval: start/end must not be NaN');
|
|
49
|
-
this._start = start;
|
|
50
|
-
this._end = end;
|
|
51
|
-
this.sortRange();
|
|
52
|
-
}
|
|
53
|
-
/** 区间起点 */
|
|
54
|
-
get start() {
|
|
55
|
-
return this._start;
|
|
56
|
-
}
|
|
57
|
-
/** 区间终点 */
|
|
58
|
-
get end() {
|
|
59
|
-
return this._end;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* 计算区间长度。
|
|
63
|
-
* @returns `end - start`,点区间返回 `0`。
|
|
64
|
-
*/
|
|
65
|
-
length() {
|
|
66
|
-
return this._end - this._start;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* 判断参数是否落在区间内。
|
|
70
|
-
* @param u 待判断参数。
|
|
71
|
-
* @param eps 闭区间边界比较容差。
|
|
72
|
-
* @returns 在 `[start - eps, end + eps]` 内返回 `true`,否则返回 `false`。
|
|
73
|
-
*/
|
|
74
|
-
contains(u, eps = Precision.EPS) {
|
|
75
|
-
return u >= this._start - eps && u <= this._end + eps;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* 断言参数在区间内。
|
|
79
|
-
* @param u 待校验参数。
|
|
80
|
-
* @param eps 区间边界比较容差。
|
|
81
|
-
* @returns 当前区间实例。
|
|
82
|
-
* @throws MathError 参数不在区间内时抛错。
|
|
83
|
-
*/
|
|
84
|
-
assertContains(u, eps = Precision.EPS) {
|
|
85
|
-
MathError.assert(this.contains(u, eps), 'Interval.assertContains: parameter out of range');
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* 断言子区间完整落在当前区间内。
|
|
90
|
-
* @param range 待校验子区间。
|
|
91
|
-
* @param eps 区间边界比较容差。
|
|
92
|
-
* @returns 当前区间实例。
|
|
93
|
-
* @throws MathError 子区间超出当前区间时抛错。
|
|
94
|
-
*/
|
|
95
|
-
assertContainsRange(range, eps = Precision.EPS) {
|
|
96
|
-
MathError.assert(this.contains(range.start, eps) && this.contains(range.end, eps), 'Interval.assertContainsRange: range out of bounds');
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* 将参数钳制到区间范围内。
|
|
101
|
-
* @param u 输入参数。
|
|
102
|
-
* @returns 小于起点返回 `start`,大于终点返回 `end`,否则返回自身。
|
|
103
|
-
*/
|
|
104
|
-
clamp(u) {
|
|
105
|
-
if (u < this._start)
|
|
106
|
-
return this._start;
|
|
107
|
-
if (u > this._end)
|
|
108
|
-
return this._end;
|
|
109
|
-
return u;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* 判断两个区间是否近似相等。
|
|
113
|
-
* @param other 另一个区间。
|
|
114
|
-
* @param eps 端点比较容差。
|
|
115
|
-
* @returns 起点和终点都在容差内时返回 `true`。
|
|
116
|
-
*/
|
|
117
|
-
equals(other, eps = Precision.EPS) {
|
|
118
|
-
return Precision.equal(this._start, other._start, eps) &&
|
|
119
|
-
Precision.equal(this._end, other._end, eps);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* 原地扩展区间。
|
|
123
|
-
* @param delta 扩展量;`delta > 0` 表示扩大,`delta < 0` 表示收缩。
|
|
124
|
-
* @returns 当前实例(便于链式调用)。
|
|
125
|
-
*/
|
|
126
|
-
expand(delta) {
|
|
127
|
-
MathError.assert(Number.isFinite(delta), 'Interval.expand: delta must be finite');
|
|
128
|
-
const nextStart = this._start - delta;
|
|
129
|
-
const nextEnd = this._end + delta;
|
|
130
|
-
MathError.assert(nextStart <= nextEnd, 'Interval.expand: shrink exceeds interval length');
|
|
131
|
-
this._start = nextStart;
|
|
132
|
-
this._end = nextEnd;
|
|
133
|
-
return this;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* 返回扩展后的新区间,不修改当前实例。
|
|
137
|
-
* @param delta 扩展量;语义同 `expand`。
|
|
138
|
-
* @returns 新的区间实例。
|
|
139
|
-
*/
|
|
140
|
-
expanded(delta) {
|
|
141
|
-
return this.clone().expand(delta);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* 计算与另一区间的交集。
|
|
145
|
-
* @param other 参与求交的区间。
|
|
146
|
-
* @param eps 判定“相离/相接”时的容差。
|
|
147
|
-
* @returns 无交集返回 `[]`;有交集返回单段 `[Interval]`;端点相接返回点区间。
|
|
148
|
-
*/
|
|
149
|
-
intersect(other, eps = Precision.EPS) {
|
|
150
|
-
const s = Math.max(this._start, other._start);
|
|
151
|
-
const e = Math.min(this._end, other._end);
|
|
152
|
-
if (s > e + eps)
|
|
153
|
-
return [];
|
|
154
|
-
if (Precision.equal(s, e, eps)) {
|
|
155
|
-
const m = (s + e) / 2;
|
|
156
|
-
return [new Interval(m, m)];
|
|
157
|
-
}
|
|
158
|
-
return [new Interval(s, e)];
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* 计算与另一区间的并集(普通区间语义)。
|
|
162
|
-
* @param other 参与求并的区间。
|
|
163
|
-
* @returns 单段最小覆盖区间数组(保持与 `PeriodInterval` 的返回形态一致)。
|
|
164
|
-
*/
|
|
165
|
-
union(other) {
|
|
166
|
-
return [new Interval(Math.min(this._start, other._start), Math.max(this._end, other._end))];
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* 以参数 `u` 切分区间。
|
|
170
|
-
* @param u 切分参数。
|
|
171
|
-
* @param eps 边界判定容差。
|
|
172
|
-
* @returns `u` 在边界或区间外返回 `[]`;在区间内部返回两段子区间。
|
|
173
|
-
*/
|
|
174
|
-
split(u, eps = Precision.EPS) {
|
|
175
|
-
if (!this.contains(u, eps))
|
|
176
|
-
return [];
|
|
177
|
-
if (Precision.equal(u, this._start, eps) || Precision.equal(u, this._end, eps)) {
|
|
178
|
-
return [];
|
|
179
|
-
}
|
|
180
|
-
return [new Interval(this._start, u), new Interval(u, this._end)];
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* 克隆当前区间。
|
|
184
|
-
* @returns 与当前区间数值相同的新实例。
|
|
185
|
-
*/
|
|
186
|
-
clone() {
|
|
187
|
-
return new Interval(this._start, this._end);
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* 规范化区间顺序,使 `_start <= _end`。
|
|
191
|
-
* 仅在内部使用。
|
|
192
|
-
*/
|
|
193
|
-
sortRange() {
|
|
194
|
-
if (this._start <= this._end)
|
|
195
|
-
return;
|
|
196
|
-
const t = this._start;
|
|
197
|
-
this._start = this._end;
|
|
198
|
-
this._end = t;
|
|
199
|
-
}
|
|
200
|
-
}
|