From e940ff7a64197bba304cab885b51368206b5e0a1 Mon Sep 17 00:00:00 2001 From: snowykami Date: Wed, 28 Aug 2024 12:35:22 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20docs=20from=20@=20snowykami/mb?= =?UTF-8?q?cp@0320f13ae94700c8dd360db43593d8106874601f=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 404.html | 2 +- api-ex.html | 303 +++++++++++++++++- api/index.html | 8 +- api/mp_math/angle.html | 59 ++-- api/mp_math/const.html | 8 +- api/mp_math/equation.html | 43 +-- api/mp_math/index.html | 8 +- api/mp_math/line.html | 115 ++++--- api/mp_math/mp_math_typing.html | 8 +- api/mp_math/plane.html | 114 +++---- api/mp_math/point.html | 41 ++- api/mp_math/segment.html | 12 +- api/mp_math/utils.html | 51 ++- api/mp_math/vector.html | 143 +++++++-- api/particle/index.html | 8 +- api/presets/index.html | 8 +- api/presets/model/index.html | 35 +- assets/api_index.md.BvazTqTB.js | 1 + assets/api_index.md.BvazTqTB.lean.js | 1 + assets/api_index.md.CsKClHFh.js | 1 - assets/api_index.md.CsKClHFh.lean.js | 1 - assets/api_mp_math_angle.md.7ZvAVHFT.js | 101 ++++++ assets/api_mp_math_angle.md.7ZvAVHFT.lean.js | 1 + assets/api_mp_math_angle.md.9eUTSIe4.js | 102 ------ assets/api_mp_math_angle.md.9eUTSIe4.lean.js | 1 - assets/api_mp_math_const.md.Bc1LxtcU.js | 1 + assets/api_mp_math_const.md.Bc1LxtcU.lean.js | 1 + assets/api_mp_math_const.md.Bhz27OPg.js | 1 - assets/api_mp_math_const.md.Bhz27OPg.lean.js | 1 - assets/api_mp_math_equation.md.DcgE8elZ.js | 63 ++++ .../api_mp_math_equation.md.DcgE8elZ.lean.js | 1 + .../api_mp_math_equation.md.xiyFVY1c.lean.js | 1 - assets/api_mp_math_index.md.4P0hk6gb.js | 1 + assets/api_mp_math_index.md.4P0hk6gb.lean.js | 1 + assets/api_mp_math_index.md.DTIfeUA1.js | 1 - assets/api_mp_math_index.md.DTIfeUA1.lean.js | 1 - assets/api_mp_math_line.md.BybnyRUL.js | 193 ----------- assets/api_mp_math_line.md.BybnyRUL.lean.js | 1 - assets/api_mp_math_line.md.CPz5W_V9.js | 192 +++++++++++ assets/api_mp_math_line.md.CPz5W_V9.lean.js | 1 + .../api_mp_math_mp_math_typing.md.BHJOAxTl.js | 1 + ...mp_math_mp_math_typing.md.BHJOAxTl.lean.js | 1 + .../api_mp_math_mp_math_typing.md.DXaadYgy.js | 1 - ...mp_math_mp_math_typing.md.DXaadYgy.lean.js | 1 - assets/api_mp_math_plane.md.B7Mh7SKE.js | 208 ++++++++++++ assets/api_mp_math_plane.md.B7Mh7SKE.lean.js | 1 + assets/api_mp_math_plane.md.Cdj0PlKB.lean.js | 1 - assets/api_mp_math_point.md.BhIb1HeT.js | 41 +++ assets/api_mp_math_point.md.BhIb1HeT.lean.js | 1 + assets/api_mp_math_point.md.D3f-vzVt.js | 30 -- assets/api_mp_math_point.md.D3f-vzVt.lean.js | 1 - assets/api_mp_math_segment.md.BpLgqrZ6.js | 16 + .../api_mp_math_segment.md.BpLgqrZ6.lean.js | 1 + assets/api_mp_math_segment.md.DIViBThe.js | 14 - .../api_mp_math_segment.md.DIViBThe.lean.js | 1 - assets/api_mp_math_utils.md.BgmONBdf.js | 65 ++++ assets/api_mp_math_utils.md.BgmONBdf.lean.js | 1 + assets/api_mp_math_utils.md.CDwq4icO.js | 74 ----- assets/api_mp_math_utils.md.CDwq4icO.lean.js | 1 - assets/api_mp_math_vector.md.BgK1TmFY.js | 116 ------- assets/api_mp_math_vector.md.BgK1TmFY.lean.js | 1 - assets/api_mp_math_vector.md.BxisUL7s.js | 189 +++++++++++ assets/api_mp_math_vector.md.BxisUL7s.lean.js | 1 + assets/api_particle_index.md.BRCSxC3e.js | 1 + assets/api_particle_index.md.BRCSxC3e.lean.js | 1 + assets/api_particle_index.md.BqH-w2FR.js | 1 - assets/api_particle_index.md.BqH-w2FR.lean.js | 1 - assets/api_presets_index.md.CvgR5vOS.js | 1 - assets/api_presets_index.md.CvgR5vOS.lean.js | 1 - assets/api_presets_index.md.Dl6Ss91J.js | 1 + assets/api_presets_index.md.Dl6Ss91J.lean.js | 1 + assets/api_presets_model_index.md.D1iZ1qEr.js | 43 --- ...pi_presets_model_index.md.D1iZ1qEr.lean.js | 1 - assets/api_presets_model_index.md.O3tM1JKS.js | 18 ++ ...pi_presets_model_index.md.O3tM1JKS.lean.js | 1 + assets/en_api_index.md.Bgu-LD1B.js | 1 + assets/en_api_index.md.Bgu-LD1B.lean.js | 1 + assets/en_api_mp_math_angle.md.Cpkg14Nd.js | 101 ++++++ .../en_api_mp_math_angle.md.Cpkg14Nd.lean.js | 1 + assets/en_api_mp_math_const.md.DfcWuGeV.js | 1 + .../en_api_mp_math_const.md.DfcWuGeV.lean.js | 1 + ...=> en_api_mp_math_equation.md.BEubflOs.js} | 37 ++- ...n_api_mp_math_equation.md.BEubflOs.lean.js | 1 + assets/en_api_mp_math_index.md.DrjDUYBY.js | 1 + .../en_api_mp_math_index.md.DrjDUYBY.lean.js | 1 + assets/en_api_mp_math_line.md.JAqG1sD6.js | 192 +++++++++++ .../en_api_mp_math_line.md.JAqG1sD6.lean.js | 1 + ..._api_mp_math_mp_math_typing.md.Dh1by9kw.js | 1 + ...mp_math_mp_math_typing.md.Dh1by9kw.lean.js | 1 + ...js => en_api_mp_math_plane.md.BRPMklJt.js} | 108 +++---- .../en_api_mp_math_plane.md.BRPMklJt.lean.js | 1 + assets/en_api_mp_math_point.md.D_AsGf3x.js | 41 +++ .../en_api_mp_math_point.md.D_AsGf3x.lean.js | 1 + assets/en_api_mp_math_segment.md.CRs1-Itg.js | 16 + ...en_api_mp_math_segment.md.CRs1-Itg.lean.js | 1 + assets/en_api_mp_math_utils.md.CoXbSyss.js | 65 ++++ .../en_api_mp_math_utils.md.CoXbSyss.lean.js | 1 + assets/en_api_mp_math_vector.md.Dk4b7P4S.js | 189 +++++++++++ .../en_api_mp_math_vector.md.Dk4b7P4S.lean.js | 1 + assets/en_api_particle_index.md.CmC1QX5o.js | 1 + .../en_api_particle_index.md.CmC1QX5o.lean.js | 1 + assets/en_api_presets_index.md.CZ5hl_7D.js | 1 + .../en_api_presets_index.md.CZ5hl_7D.lean.js | 1 + .../en_api_presets_model_index.md.DD5WCYA0.js | 18 ++ ...pi_presets_model_index.md.DD5WCYA0.lean.js | 1 + assets/ja_api_index.md.4BnflFIm.js | 1 + assets/ja_api_index.md.4BnflFIm.lean.js | 1 + assets/ja_api_mp_math_angle.md.B0vK-3H7.js | 101 ++++++ .../ja_api_mp_math_angle.md.B0vK-3H7.lean.js | 1 + assets/ja_api_mp_math_const.md.CQY-Qdbh.js | 1 + .../ja_api_mp_math_const.md.CQY-Qdbh.lean.js | 1 + assets/ja_api_mp_math_equation.md.CxOZG3Ck.js | 63 ++++ ...a_api_mp_math_equation.md.CxOZG3Ck.lean.js | 1 + assets/ja_api_mp_math_index.md.CSAMHYsB.js | 1 + .../ja_api_mp_math_index.md.CSAMHYsB.lean.js | 1 + assets/ja_api_mp_math_line.md.B_sNS7i2.js | 192 +++++++++++ .../ja_api_mp_math_line.md.B_sNS7i2.lean.js | 1 + ..._api_mp_math_mp_math_typing.md.CeASNaiE.js | 1 + ...mp_math_mp_math_typing.md.CeASNaiE.lean.js | 1 + assets/ja_api_mp_math_plane.md.DoFcs9On.js | 208 ++++++++++++ .../ja_api_mp_math_plane.md.DoFcs9On.lean.js | 1 + assets/ja_api_mp_math_point.md.DsWUjRQD.js | 41 +++ .../ja_api_mp_math_point.md.DsWUjRQD.lean.js | 1 + assets/ja_api_mp_math_segment.md.B3JRHboi.js | 16 + ...ja_api_mp_math_segment.md.B3JRHboi.lean.js | 1 + assets/ja_api_mp_math_utils.md.CMaGJtHQ.js | 65 ++++ .../ja_api_mp_math_utils.md.CMaGJtHQ.lean.js | 1 + assets/ja_api_mp_math_vector.md.BaQ1gWXc.js | 189 +++++++++++ .../ja_api_mp_math_vector.md.BaQ1gWXc.lean.js | 1 + assets/ja_api_particle_index.md.E2YnH7EN.js | 1 + .../ja_api_particle_index.md.E2YnH7EN.lean.js | 1 + assets/ja_api_presets_index.md.ATGcHt9d.js | 1 + .../ja_api_presets_index.md.ATGcHt9d.lean.js | 1 + .../ja_api_presets_model_index.md.D4BAOCXn.js | 18 ++ ...pi_presets_model_index.md.D4BAOCXn.lean.js | 1 + en/api/index.html | 24 ++ en/api/mp_math/angle.html | 124 +++++++ en/api/mp_math/const.html | 24 ++ en/api/mp_math/equation.html | 86 +++++ en/api/mp_math/index.html | 24 ++ en/api/mp_math/line.html | 215 +++++++++++++ en/api/mp_math/mp_math_typing.html | 24 ++ en/api/mp_math/plane.html | 231 +++++++++++++ en/api/mp_math/point.html | 64 ++++ en/api/mp_math/segment.html | 39 +++ en/api/mp_math/utils.html | 88 +++++ en/api/mp_math/vector.html | 212 ++++++++++++ en/api/particle/index.html | 24 ++ en/api/presets/index.html | 24 ++ en/api/presets/model/index.html | 41 +++ hashmap.json | 2 +- index.html | 4 +- ja/api/index.html | 24 ++ ja/api/mp_math/angle.html | 124 +++++++ ja/api/mp_math/const.html | 24 ++ ja/api/mp_math/equation.html | 86 +++++ ja/api/mp_math/index.html | 24 ++ ja/api/mp_math/line.html | 215 +++++++++++++ ja/api/mp_math/mp_math_typing.html | 24 ++ ja/api/mp_math/plane.html | 231 +++++++++++++ ja/api/mp_math/point.html | 64 ++++ ja/api/mp_math/segment.html | 39 +++ ja/api/mp_math/utils.html | 88 +++++ ja/api/mp_math/vector.html | 212 ++++++++++++ ja/api/particle/index.html | 24 ++ ja/api/presets/index.html | 24 ++ ja/api/presets/model/index.html | 41 +++ md-ex.html | 4 +- 168 files changed, 5689 insertions(+), 984 deletions(-) create mode 100644 assets/api_index.md.BvazTqTB.js create mode 100644 assets/api_index.md.BvazTqTB.lean.js delete mode 100644 assets/api_index.md.CsKClHFh.js delete mode 100644 assets/api_index.md.CsKClHFh.lean.js create mode 100644 assets/api_mp_math_angle.md.7ZvAVHFT.js create mode 100644 assets/api_mp_math_angle.md.7ZvAVHFT.lean.js delete mode 100644 assets/api_mp_math_angle.md.9eUTSIe4.js delete mode 100644 assets/api_mp_math_angle.md.9eUTSIe4.lean.js create mode 100644 assets/api_mp_math_const.md.Bc1LxtcU.js create mode 100644 assets/api_mp_math_const.md.Bc1LxtcU.lean.js delete mode 100644 assets/api_mp_math_const.md.Bhz27OPg.js delete mode 100644 assets/api_mp_math_const.md.Bhz27OPg.lean.js create mode 100644 assets/api_mp_math_equation.md.DcgE8elZ.js create mode 100644 assets/api_mp_math_equation.md.DcgE8elZ.lean.js delete mode 100644 assets/api_mp_math_equation.md.xiyFVY1c.lean.js create mode 100644 assets/api_mp_math_index.md.4P0hk6gb.js create mode 100644 assets/api_mp_math_index.md.4P0hk6gb.lean.js delete mode 100644 assets/api_mp_math_index.md.DTIfeUA1.js delete mode 100644 assets/api_mp_math_index.md.DTIfeUA1.lean.js delete mode 100644 assets/api_mp_math_line.md.BybnyRUL.js delete mode 100644 assets/api_mp_math_line.md.BybnyRUL.lean.js create mode 100644 assets/api_mp_math_line.md.CPz5W_V9.js create mode 100644 assets/api_mp_math_line.md.CPz5W_V9.lean.js create mode 100644 assets/api_mp_math_mp_math_typing.md.BHJOAxTl.js create mode 100644 assets/api_mp_math_mp_math_typing.md.BHJOAxTl.lean.js delete mode 100644 assets/api_mp_math_mp_math_typing.md.DXaadYgy.js delete mode 100644 assets/api_mp_math_mp_math_typing.md.DXaadYgy.lean.js create mode 100644 assets/api_mp_math_plane.md.B7Mh7SKE.js create mode 100644 assets/api_mp_math_plane.md.B7Mh7SKE.lean.js delete mode 100644 assets/api_mp_math_plane.md.Cdj0PlKB.lean.js create mode 100644 assets/api_mp_math_point.md.BhIb1HeT.js create mode 100644 assets/api_mp_math_point.md.BhIb1HeT.lean.js delete mode 100644 assets/api_mp_math_point.md.D3f-vzVt.js delete mode 100644 assets/api_mp_math_point.md.D3f-vzVt.lean.js create mode 100644 assets/api_mp_math_segment.md.BpLgqrZ6.js create mode 100644 assets/api_mp_math_segment.md.BpLgqrZ6.lean.js delete mode 100644 assets/api_mp_math_segment.md.DIViBThe.js delete mode 100644 assets/api_mp_math_segment.md.DIViBThe.lean.js create mode 100644 assets/api_mp_math_utils.md.BgmONBdf.js create mode 100644 assets/api_mp_math_utils.md.BgmONBdf.lean.js delete mode 100644 assets/api_mp_math_utils.md.CDwq4icO.js delete mode 100644 assets/api_mp_math_utils.md.CDwq4icO.lean.js delete mode 100644 assets/api_mp_math_vector.md.BgK1TmFY.js delete mode 100644 assets/api_mp_math_vector.md.BgK1TmFY.lean.js create mode 100644 assets/api_mp_math_vector.md.BxisUL7s.js create mode 100644 assets/api_mp_math_vector.md.BxisUL7s.lean.js create mode 100644 assets/api_particle_index.md.BRCSxC3e.js create mode 100644 assets/api_particle_index.md.BRCSxC3e.lean.js delete mode 100644 assets/api_particle_index.md.BqH-w2FR.js delete mode 100644 assets/api_particle_index.md.BqH-w2FR.lean.js delete mode 100644 assets/api_presets_index.md.CvgR5vOS.js delete mode 100644 assets/api_presets_index.md.CvgR5vOS.lean.js create mode 100644 assets/api_presets_index.md.Dl6Ss91J.js create mode 100644 assets/api_presets_index.md.Dl6Ss91J.lean.js delete mode 100644 assets/api_presets_model_index.md.D1iZ1qEr.js delete mode 100644 assets/api_presets_model_index.md.D1iZ1qEr.lean.js create mode 100644 assets/api_presets_model_index.md.O3tM1JKS.js create mode 100644 assets/api_presets_model_index.md.O3tM1JKS.lean.js create mode 100644 assets/en_api_index.md.Bgu-LD1B.js create mode 100644 assets/en_api_index.md.Bgu-LD1B.lean.js create mode 100644 assets/en_api_mp_math_angle.md.Cpkg14Nd.js create mode 100644 assets/en_api_mp_math_angle.md.Cpkg14Nd.lean.js create mode 100644 assets/en_api_mp_math_const.md.DfcWuGeV.js create mode 100644 assets/en_api_mp_math_const.md.DfcWuGeV.lean.js rename assets/{api_mp_math_equation.md.xiyFVY1c.js => en_api_mp_math_equation.md.BEubflOs.js} (52%) create mode 100644 assets/en_api_mp_math_equation.md.BEubflOs.lean.js create mode 100644 assets/en_api_mp_math_index.md.DrjDUYBY.js create mode 100644 assets/en_api_mp_math_index.md.DrjDUYBY.lean.js create mode 100644 assets/en_api_mp_math_line.md.JAqG1sD6.js create mode 100644 assets/en_api_mp_math_line.md.JAqG1sD6.lean.js create mode 100644 assets/en_api_mp_math_mp_math_typing.md.Dh1by9kw.js create mode 100644 assets/en_api_mp_math_mp_math_typing.md.Dh1by9kw.lean.js rename assets/{api_mp_math_plane.md.Cdj0PlKB.js => en_api_mp_math_plane.md.BRPMklJt.js} (55%) create mode 100644 assets/en_api_mp_math_plane.md.BRPMklJt.lean.js create mode 100644 assets/en_api_mp_math_point.md.D_AsGf3x.js create mode 100644 assets/en_api_mp_math_point.md.D_AsGf3x.lean.js create mode 100644 assets/en_api_mp_math_segment.md.CRs1-Itg.js create mode 100644 assets/en_api_mp_math_segment.md.CRs1-Itg.lean.js create mode 100644 assets/en_api_mp_math_utils.md.CoXbSyss.js create mode 100644 assets/en_api_mp_math_utils.md.CoXbSyss.lean.js create mode 100644 assets/en_api_mp_math_vector.md.Dk4b7P4S.js create mode 100644 assets/en_api_mp_math_vector.md.Dk4b7P4S.lean.js create mode 100644 assets/en_api_particle_index.md.CmC1QX5o.js create mode 100644 assets/en_api_particle_index.md.CmC1QX5o.lean.js create mode 100644 assets/en_api_presets_index.md.CZ5hl_7D.js create mode 100644 assets/en_api_presets_index.md.CZ5hl_7D.lean.js create mode 100644 assets/en_api_presets_model_index.md.DD5WCYA0.js create mode 100644 assets/en_api_presets_model_index.md.DD5WCYA0.lean.js create mode 100644 assets/ja_api_index.md.4BnflFIm.js create mode 100644 assets/ja_api_index.md.4BnflFIm.lean.js create mode 100644 assets/ja_api_mp_math_angle.md.B0vK-3H7.js create mode 100644 assets/ja_api_mp_math_angle.md.B0vK-3H7.lean.js create mode 100644 assets/ja_api_mp_math_const.md.CQY-Qdbh.js create mode 100644 assets/ja_api_mp_math_const.md.CQY-Qdbh.lean.js create mode 100644 assets/ja_api_mp_math_equation.md.CxOZG3Ck.js create mode 100644 assets/ja_api_mp_math_equation.md.CxOZG3Ck.lean.js create mode 100644 assets/ja_api_mp_math_index.md.CSAMHYsB.js create mode 100644 assets/ja_api_mp_math_index.md.CSAMHYsB.lean.js create mode 100644 assets/ja_api_mp_math_line.md.B_sNS7i2.js create mode 100644 assets/ja_api_mp_math_line.md.B_sNS7i2.lean.js create mode 100644 assets/ja_api_mp_math_mp_math_typing.md.CeASNaiE.js create mode 100644 assets/ja_api_mp_math_mp_math_typing.md.CeASNaiE.lean.js create mode 100644 assets/ja_api_mp_math_plane.md.DoFcs9On.js create mode 100644 assets/ja_api_mp_math_plane.md.DoFcs9On.lean.js create mode 100644 assets/ja_api_mp_math_point.md.DsWUjRQD.js create mode 100644 assets/ja_api_mp_math_point.md.DsWUjRQD.lean.js create mode 100644 assets/ja_api_mp_math_segment.md.B3JRHboi.js create mode 100644 assets/ja_api_mp_math_segment.md.B3JRHboi.lean.js create mode 100644 assets/ja_api_mp_math_utils.md.CMaGJtHQ.js create mode 100644 assets/ja_api_mp_math_utils.md.CMaGJtHQ.lean.js create mode 100644 assets/ja_api_mp_math_vector.md.BaQ1gWXc.js create mode 100644 assets/ja_api_mp_math_vector.md.BaQ1gWXc.lean.js create mode 100644 assets/ja_api_particle_index.md.E2YnH7EN.js create mode 100644 assets/ja_api_particle_index.md.E2YnH7EN.lean.js create mode 100644 assets/ja_api_presets_index.md.ATGcHt9d.js create mode 100644 assets/ja_api_presets_index.md.ATGcHt9d.lean.js create mode 100644 assets/ja_api_presets_model_index.md.D4BAOCXn.js create mode 100644 assets/ja_api_presets_model_index.md.D4BAOCXn.lean.js create mode 100644 en/api/index.html create mode 100644 en/api/mp_math/angle.html create mode 100644 en/api/mp_math/const.html create mode 100644 en/api/mp_math/equation.html create mode 100644 en/api/mp_math/index.html create mode 100644 en/api/mp_math/line.html create mode 100644 en/api/mp_math/mp_math_typing.html create mode 100644 en/api/mp_math/plane.html create mode 100644 en/api/mp_math/point.html create mode 100644 en/api/mp_math/segment.html create mode 100644 en/api/mp_math/utils.html create mode 100644 en/api/mp_math/vector.html create mode 100644 en/api/particle/index.html create mode 100644 en/api/presets/index.html create mode 100644 en/api/presets/model/index.html create mode 100644 ja/api/index.html create mode 100644 ja/api/mp_math/angle.html create mode 100644 ja/api/mp_math/const.html create mode 100644 ja/api/mp_math/equation.html create mode 100644 ja/api/mp_math/index.html create mode 100644 ja/api/mp_math/line.html create mode 100644 ja/api/mp_math/mp_math_typing.html create mode 100644 ja/api/mp_math/plane.html create mode 100644 ja/api/mp_math/point.html create mode 100644 ja/api/mp_math/segment.html create mode 100644 ja/api/mp_math/utils.html create mode 100644 ja/api/mp_math/vector.html create mode 100644 ja/api/particle/index.html create mode 100644 ja/api/presets/index.html create mode 100644 ja/api/presets/model/index.html diff --git a/404.html b/404.html index 3c5c336..50f0607 100644 --- a/404.html +++ b/404.html @@ -15,7 +15,7 @@
- + \ No newline at end of file diff --git a/api-ex.html b/api-ex.html index 931de17..103cfc1 100644 --- a/api-ex.html +++ b/api-ex.html @@ -17,7 +17,7 @@ -
Skip to content

Runtime API Examples

This page demonstrates usage of some of the runtime APIs provided by VitePress.

The main useData() API can be used to access site, theme, and page data for the current page. It works in both .md and .vue files:

md
<script setup>
+    
Skip to content

Runtime API Examples

This page demonstrates usage of some of the runtime APIs provided by VitePress.

The main useData() API can be used to access site, theme, and page data for the current page. It works in both .md and .vue files:

md
<script setup>
 import { useData } from 'vitepress'
 
 const { theme, page, frontmatter } = useData()
@@ -38,6 +38,305 @@
       "icon": "github",
       "link": "https://github.com/snowykami/mbcp"
     }
+  ],
+  "sidebar": {
+    "/api/": [
+      {
+        "text": "api",
+        "items": [
+          {
+            "text": "mbcp",
+            "link": "/api/index.md"
+          },
+          {
+            "text": "mp_math",
+            "items": [
+              {
+                "text": "mbcp.mp_math",
+                "link": "/api/mp_math/index.md"
+              },
+              {
+                "text": "mbcp.mp_math.angle",
+                "link": "/api/mp_math/angle.md"
+              },
+              {
+                "text": "mbcp.mp_math.const",
+                "link": "/api/mp_math/const.md"
+              },
+              {
+                "text": "mbcp.mp_math.equation",
+                "link": "/api/mp_math/equation.md"
+              },
+              {
+                "text": "mbcp.mp_math.line",
+                "link": "/api/mp_math/line.md"
+              },
+              {
+                "text": "mbcp.mp_math.mp_math_typing",
+                "link": "/api/mp_math/mp_math_typing.md"
+              },
+              {
+                "text": "mbcp.mp_math.plane",
+                "link": "/api/mp_math/plane.md"
+              },
+              {
+                "text": "mbcp.mp_math.point",
+                "link": "/api/mp_math/point.md"
+              },
+              {
+                "text": "mbcp.mp_math.segment",
+                "link": "/api/mp_math/segment.md"
+              },
+              {
+                "text": "mbcp.mp_math.utils",
+                "link": "/api/mp_math/utils.md"
+              },
+              {
+                "text": "mbcp.mp_math.vector",
+                "link": "/api/mp_math/vector.md"
+              }
+            ]
+          },
+          {
+            "text": "particle",
+            "items": [
+              {
+                "text": "mbcp.particle",
+                "link": "/api/particle/index.md"
+              }
+            ]
+          },
+          {
+            "text": "presets",
+            "items": [
+              {
+                "text": "mbcp.presets",
+                "link": "/api/presets/index.md"
+              },
+              {
+                "text": "model",
+                "items": [
+                  {
+                    "text": "mbcp.presets.model",
+                    "link": "/api/presets/model/index.md"
+                  }
+                ]
+              }
+            ]
+          }
+        ]
+      }
+    ],
+    "/en/": [
+      {
+        "text": "en",
+        "items": [
+          {
+            "text": "api",
+            "items": [
+              {
+                "text": "mbcp",
+                "link": "/en/api/index.md"
+              },
+              {
+                "text": "mp_math",
+                "items": [
+                  {
+                    "text": "mbcp.mp_math",
+                    "link": "/en/api/mp_math/index.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.angle",
+                    "link": "/en/api/mp_math/angle.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.const",
+                    "link": "/en/api/mp_math/const.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.equation",
+                    "link": "/en/api/mp_math/equation.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.line",
+                    "link": "/en/api/mp_math/line.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.mp_math_typing",
+                    "link": "/en/api/mp_math/mp_math_typing.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.plane",
+                    "link": "/en/api/mp_math/plane.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.point",
+                    "link": "/en/api/mp_math/point.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.segment",
+                    "link": "/en/api/mp_math/segment.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.utils",
+                    "link": "/en/api/mp_math/utils.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.vector",
+                    "link": "/en/api/mp_math/vector.md"
+                  }
+                ]
+              },
+              {
+                "text": "particle",
+                "items": [
+                  {
+                    "text": "mbcp.particle",
+                    "link": "/en/api/particle/index.md"
+                  }
+                ]
+              },
+              {
+                "text": "presets",
+                "items": [
+                  {
+                    "text": "mbcp.presets",
+                    "link": "/en/api/presets/index.md"
+                  },
+                  {
+                    "text": "model",
+                    "items": [
+                      {
+                        "text": "mbcp.presets.model",
+                        "link": "/en/api/presets/model/index.md"
+                      }
+                    ]
+                  }
+                ]
+              }
+            ]
+          }
+        ]
+      }
+    ],
+    "/ja/": [
+      {
+        "text": "ja",
+        "items": [
+          {
+            "text": "api",
+            "items": [
+              {
+                "text": "mbcp",
+                "link": "/ja/api/index.md"
+              },
+              {
+                "text": "mp_math",
+                "items": [
+                  {
+                    "text": "mbcp.mp_math",
+                    "link": "/ja/api/mp_math/index.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.angle",
+                    "link": "/ja/api/mp_math/angle.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.const",
+                    "link": "/ja/api/mp_math/const.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.equation",
+                    "link": "/ja/api/mp_math/equation.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.line",
+                    "link": "/ja/api/mp_math/line.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.mp_math_typing",
+                    "link": "/ja/api/mp_math/mp_math_typing.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.plane",
+                    "link": "/ja/api/mp_math/plane.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.point",
+                    "link": "/ja/api/mp_math/point.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.segment",
+                    "link": "/ja/api/mp_math/segment.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.utils",
+                    "link": "/ja/api/mp_math/utils.md"
+                  },
+                  {
+                    "text": "mbcp.mp_math.vector",
+                    "link": "/ja/api/mp_math/vector.md"
+                  }
+                ]
+              },
+              {
+                "text": "particle",
+                "items": [
+                  {
+                    "text": "mbcp.particle",
+                    "link": "/ja/api/particle/index.md"
+                  }
+                ]
+              },
+              {
+                "text": "presets",
+                "items": [
+                  {
+                    "text": "mbcp.presets",
+                    "link": "/ja/api/presets/index.md"
+                  },
+                  {
+                    "text": "model",
+                    "items": [
+                      {
+                        "text": "mbcp.presets.model",
+                        "link": "/ja/api/presets/model/index.md"
+                      }
+                    ]
+                  }
+                ]
+              }
+            ]
+          }
+        ]
+      }
+    ],
+    "/api-ex.md/": [
+      {
+        "text": "Runtime API Examples",
+        "items": []
+      }
+    ],
+    "/md-ex.md/": [
+      {
+        "text": "Markdown Extension Examples",
+        "items": []
+      }
+    ]
+  },
+  "nav": [
+    {
+      "text": "快速开始",
+      "link": "/guide"
+    },
+    {
+      "text": "API文档",
+      "link": "/api/"
+    },
+    {
+      "text": "实例",
+      "link": "/demo/"
+    }
   ]
 }

Page Data

{
   "title": "Runtime API Examples",
@@ -51,7 +350,7 @@
 }

Page Frontmatter

{
   "outline": "deep"
 }

More

Check out the documentation for the full list of runtime APIs.

- + \ No newline at end of file diff --git a/api/index.html b/api/index.html index a6a05f2..86753fe 100644 --- a/api/index.html +++ b/api/index.html @@ -3,7 +3,7 @@ - mbcp.\n\ninit\n\n | MBCP docs + mbcp | MBCP docs @@ -12,13 +12,13 @@ - + -
Skip to content
- + + \ No newline at end of file diff --git a/api/mp_math/angle.html b/api/mp_math/angle.html index d696950..bd8e36d 100644 --- a/api/mp_math/angle.html +++ b/api/mp_math/angle.html @@ -3,7 +3,7 @@ - mbcp.mp\nmath.angle | MBCP docs + mbcp.mp_math.angle | MBCP docs @@ -12,15 +12,12 @@ - + -
Skip to content

class AnyAngle

def __init__(self, value: float, is_radian: bool) -> None

 任意角度。

Args:

value: 角度或弧度值
-
-is_radian: 是否为弧度,默认为否
-
源代码
python
def __init__(self, value: float, is_radian: bool=False):
+    
Skip to content

class Angle

class AnyAngle

  • def __init__(self, value: float, is_radian: bool = False)

任意角度。

参数:

value: 角度或弧度值

is_radian: 是否为弧度,默认为否

源码
python
def __init__(self, value: float, is_radian: bool=False):
     """
         任意角度。
         Args:
@@ -30,96 +27,98 @@ is_radian: 是否为弧度,默认为否
     if is_radian:
         self.radian = value
     else:
-        self.radian = value * PI / 180

@property

def complementary(self: Any) -> 'AnyAngle'

 余角:两角的和为90°。

Returns:

余角
-
源代码
python
@property
+        self.radian = value * PI / 180
  • @property

  • def complementary(self)

余角:两角的和为90°。

返回:

余角

源码
python
@property
 def complementary(self) -> 'AnyAngle':
     """
         余角:两角的和为90°。
         Returns:
             余角
         """
-    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

def supplementary(self: Any) -> 'AnyAngle'

 补角:两角的和为180°。

Returns:

补角
-
源代码
python
@property
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)
  • @property

  • def supplementary(self)

补角:两角的和为180°。

返回:

补角

源码
python
@property
 def supplementary(self) -> 'AnyAngle':
     """
         补角:两角的和为180°。
         Returns:
             补角
         """
-    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

def degree(self: Any) -> float

 角度。

Returns:

弧度
-
源代码
python
@property
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)
  • @property

  • def degree(self)

角度。

返回:

弧度

源码
python
@property
 def degree(self) -> float:
     """
         角度。
         Returns:
             弧度
         """
-    return self.radian * 180 / PI

@property

def minimum_positive(self: Any) -> 'AnyAngle'

 最小正角。

Returns:

最小正角度
-
源代码
python
@property
+    return self.radian * 180 / PI
  • @property

  • def minimum_positive(self)

最小正角。

返回:

最小正角度

源码
python
@property
 def minimum_positive(self) -> 'AnyAngle':
     """
         最小正角。
         Returns:
             最小正角度
         """
-    return AnyAngle(self.radian % (2 * PI))

@property

def maximum_negative(self: Any) -> 'AnyAngle'

 最大负角。

Returns:

最大负角度
-
源代码
python
@property
+    return AnyAngle(self.radian % (2 * PI))
  • @property

  • def maximum_negative(self)

最大负角。

返回:

最大负角度

源码
python
@property
 def maximum_negative(self) -> 'AnyAngle':
     """
         最大负角。
         Returns:
             最大负角度
         """
-    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

def sin(self: Any) -> float

 正弦值。

Returns:

正弦值
-
源代码
python
@property
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)
  • @property

  • def sin(self)

正弦值。

返回:

正弦值

源码
python
@property
 def sin(self) -> float:
     """
         正弦值。
         Returns:
             正弦值
         """
-    return math.sin(self.radian)

@property

def cos(self: Any) -> float

 余弦值。

Returns:

余弦值
-
源代码
python
@property
+    return math.sin(self.radian)
  • @property

  • def cos(self)

余弦值。

返回:

余弦值

源码
python
@property
 def cos(self) -> float:
     """
         余弦值。
         Returns:
             余弦值
         """
-    return math.cos(self.radian)

@property

def tan(self: Any) -> float

 正切值。

Returns:

正切值
-
源代码
python
@property
+    return math.cos(self.radian)
  • @property

  • def tan(self)

正切值。

返回:

正切值

源码
python
@property
 def tan(self) -> float:
     """
         正切值。
         Returns:
             正切值
         """
-    return math.tan(self.radian)

@property

def cot(self: Any) -> float

 余切值。

Returns:

余切值
-
源代码
python
@property
+    return math.tan(self.radian)
  • @property

  • def cot(self)

余切值。

返回:

余切值

源码
python
@property
 def cot(self) -> float:
     """
         余切值。
         Returns:
             余切值
         """
-    return 1 / math.tan(self.radian)

@property

def sec(self: Any) -> float

 正割值。

Returns:

正割值
-
源代码
python
@property
+    return 1 / math.tan(self.radian)
  • @property

  • def sec(self)

正割值。

返回:

正割值

源码
python
@property
 def sec(self) -> float:
     """
         正割值。
         Returns:
             正割值
         """
-    return 1 / math.cos(self.radian)

@property

def csc(self: Any) -> float

 余割值。

Returns:

余割值
-
源代码
python
@property
+    return 1 / math.cos(self.radian)
  • @property

  • def csc(self)

余割值。

返回:

余割值

源码
python
@property
 def csc(self) -> float:
     """
         余割值。
         Returns:
             余割值
         """
-    return 1 / math.sin(self.radian)
- + return 1 / math.sin(self.radian)
  • def __add__(self, other: 'AnyAngle')

源码
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)
  • def __eq__(self, other)

源码
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)
  • def __sub__(self, other: 'AnyAngle')

源码
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)
  • def __mul__(self, other: float)

源码
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)
源码
python
def __repr__(self):
+    return f'AnyAngle({self.radian}, is_radian=True)'
源码
python
def __str__(self):
+    return f'AnyAngle({self.degree}° or {self.radian} rad)'
  • @overload

  • def __truediv__(self, other: float)

源码
python
@overload
+def __truediv__(self, other: float) -> 'AnyAngle':
+    ...
  • @overload

  • def __truediv__(self, other: 'AnyAngle')

源码
python
@overload
+def __truediv__(self, other: 'AnyAngle') -> float:
+    ...
  • def __truediv__(self, other)

源码
python
def __truediv__(self, other):
+    if isinstance(other, AnyAngle):
+        return self.radian / other.radian
+    return AnyAngle(self.radian / other, is_radian=True)
+ \ No newline at end of file diff --git a/api/mp_math/const.html b/api/mp_math/const.html index 527ccae..dd24f17 100644 --- a/api/mp_math/const.html +++ b/api/mp_math/const.html @@ -3,7 +3,7 @@ - mbcp.mp\nmath.const | MBCP docs + mbcp.mp_math.const | MBCP docs @@ -12,13 +12,13 @@ - + -
Skip to content

var PI = math.pi

var E = math.e

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

var GAMMA = 0.5772156649015329

var EPSILON = 0.0001

var APPROX = 0.001

- +
Skip to content

var PI = math.pi

var E = math.e

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

var GAMMA = 0.5772156649015329

var EPSILON = 0.0001

var APPROX = 0.001

+ \ No newline at end of file diff --git a/api/mp_math/equation.html b/api/mp_math/equation.html index 0ea964b..515be17 100644 --- a/api/mp_math/equation.html +++ b/api/mp_math/equation.html @@ -3,7 +3,7 @@ - mbcp.mp\nmath.equation | MBCP docs + mbcp.mp_math.equation | MBCP docs @@ -12,19 +12,12 @@ - + -
Skip to content

def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number) -> MultiVarsFunc

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

Args:

func: 函数
-
-var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
-
-epsilon: 偏移量
-

Returns:

偏导函数
-

Raises:

ValueError: 无效变量类型
-
源代码
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+    
Skip to content

var result_func = get_partial_derivative_func(result_func, v, epsilon)

def get_partial_derivative_func(func: MultiVarsFunc = EPSILON)

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

参数:

func: 函数

var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

epsilon: 偏移量

源码
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
     """
     求N元函数一阶偏导函数。这玩意不太稳定,慎用。
     Args:
@@ -54,26 +47,40 @@ epsilon: 偏移量
             return result_func(*args)
         return high_order_partial_derivative_func
     else:
-        raise ValueError('Invalid var type')

def partial_derivative_func() -> Var

源代码
python
def partial_derivative_func(*args: Var) -> Var:
+        raise ValueError('Invalid var type')

def partial_derivative_func()

源码
python
def partial_derivative_func(*args: Var) -> Var:
     args_list_plus = list(args)
     args_list_plus[var] += epsilon
     args_list_minus = list(args)
     args_list_minus[var] -= epsilon
-    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

def high_order_partial_derivative_func() -> Var

源代码
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

def high_order_partial_derivative_func()

源码
python
def high_order_partial_derivative_func(*args: Var) -> Var:
     result_func = func
     for v in var:
         result_func = get_partial_derivative_func(result_func, v, epsilon)
-    return result_func(*args)

class CurveEquation

def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc) -> None

 曲线方程。

:param x_func:

:param y_func:

:param z_func:

源代码
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    return result_func(*args)

class CurveEquation

  • def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

参数:

x_func: x函数

y_func: y函数

z_func: z函数

源码
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
     """
         曲线方程。
-        :param x_func:
-        :param y_func:
-        :param z_func:
+        Args:
+            x_func: x函数
+            y_func: y函数
+            z_func: z函数
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

var args_list_plus = list(args)

var args_list_minus = list(args)

var result_func = func

var result_func = get_partial_derivative_func(result_func, v, epsilon)

- + self.z_func = z_func
  • def __call__(self)

计算曲线上的点。

参数:

*t:

参数:

源码
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    """
+        计算曲线上的点。
+        Args:
+            *t:
+                参数
+        Returns:
+
+        """
+    if len(t) == 1:
+        return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
+    else:
+        return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
源码
python
def __str__(self):
+    return 'CurveEquation()'
+ \ No newline at end of file diff --git a/api/mp_math/index.html b/api/mp_math/index.html index 36a8ec5..1514ffb 100644 --- a/api/mp_math/index.html +++ b/api/mp_math/index.html @@ -3,7 +3,7 @@ - mbcp.mp\nmath.\n\ninit\n\n | MBCP docs + mbcp.mp_math | MBCP docs @@ -12,13 +12,13 @@ - + -
Skip to content
- + + \ No newline at end of file diff --git a/api/mp_math/line.html b/api/mp_math/line.html index 84932ef..5be626d 100644 --- a/api/mp_math/line.html +++ b/api/mp_math/line.html @@ -3,7 +3,7 @@ - mbcp.mp\nmath.line | MBCP docs + mbcp.mp_math.line | MBCP docs @@ -12,15 +12,12 @@ - + -
Skip to content

class Line3

def __init__(self, point: 'Point3', direction: 'Vector3') -> None

 三维空间中的直线。由一个点和一个方向向量确定。

Args:

point: 直线上的一点
-
-direction: 直线的方向向量
-
源代码
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    
Skip to content

class Line3

  • def __init__(self, point: 'Point3', direction: 'Vector3')

三维空间中的直线。由一个点和一个方向向量确定。

参数:

point: 直线上的一点

direction: 直线的方向向量

源码
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
     """
         三维空间中的直线。由一个点和一个方向向量确定。
         Args:
@@ -28,11 +25,7 @@ direction: 直线的方向向量
             direction: 直线的方向向量
         """
     self.point = point
-    self.direction = direction

def approx(self, other: 'Line3', epsilon: float) -> bool

 判断两条直线是否近似相等。

Args:

other: 另一条直线
-
-epsilon: 误差
-

Returns:

是否近似相等
-
源代码
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    self.direction = direction
  • def approx(self, other: 'Line3', epsilon: float = APPROX)

判断两条直线是否近似相等。

参数:

other: 另一条直线

epsilon: 误差

源码
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
     """
         判断两条直线是否近似相等。
         Args:
@@ -41,10 +34,7 @@ epsilon: 误差
         Returns:
             是否近似相等
         """
-    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

def cal_angle(self, other: 'Line3') -> 'AnyAngle'

 计算直线和直线之间的夹角。

Args:

other: 另一条直线
-

Returns:

夹角弧度
-

Raises:

TypeError: 不支持的类型
-
源代码
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)
  • def cal_angle(self, other: 'Line3')

计算直线和直线之间的夹角。

参数:

other: 另一条直线

源码
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
     """
         计算直线和直线之间的夹角。
         Args:
@@ -54,10 +44,7 @@ epsilon: 误差
         Raises:
             TypeError: 不支持的类型
         """
-    return self.direction.cal_angle(other.direction)

def cal_distance(self, other: 'Line3 | Point3') -> float

 计算直线和直线或点之间的距离。

Args:

other: 平行直线或点
-

Returns:

距离
-

Raises:

TypeError: 不支持的类型
-
源代码
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    return self.direction.cal_angle(other.direction)
  • def cal_distance(self, other: 'Line3 | Point3')

计算直线和直线或点之间的距离。

参数:

other: 平行直线或点

源码
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
     """
         计算直线和直线或点之间的距离。
         Args:
@@ -80,12 +67,7 @@ epsilon: 误差
     elif isinstance(other, Point3):
         return (other - self.point).cross(self.direction).length / self.direction.length
     else:
-        raise TypeError('Unsupported type.')

def cal_intersection(self, other: 'Line3') -> 'Point3'

 计算两条直线的交点。

Args:

other: 另一条直线
-

Returns:

交点
-

Raises:

ValueError: 直线平行
-
-ValueError: 直线不共面
-
源代码
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+        raise TypeError('Unsupported type.')
  • def cal_intersection(self, other: 'Line3')

计算两条直线的交点。

参数:

other: 另一条直线

源码
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
     """
         计算两条直线的交点。
         Args:
@@ -100,9 +82,7 @@ ValueError: 直线不共面
         raise ValueError('Lines are parallel and do not intersect.')
     if not self.is_coplanar(other):
         raise ValueError('Lines are not coplanar and do not intersect.')
-    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

def cal_perpendicular(self, point: 'Point3') -> 'Line3'

 计算直线经过指定点p的垂线。

Args:

point: 指定点
-

Returns:

垂线
-
源代码
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction
  • def cal_perpendicular(self, point: 'Point3')

计算直线经过指定点p的垂线。

参数:

point: 指定点

源码
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
     """
         计算直线经过指定点p的垂线。
         Args:
@@ -110,9 +90,7 @@ ValueError: 直线不共面
         Returns:
             垂线
         """
-    return Line3(point, self.direction.cross(point - self.point))

def get_point(self, t: RealNumber) -> 'Point3'

 获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

Args:

t: 参数t
-

Returns:

点
-
源代码
python
def get_point(self, t: RealNumber) -> 'Point3':
+    return Line3(point, self.direction.cross(point - self.point))
  • def get_point(self, t: RealNumber)

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

参数:

t: 参数t

源码
python
def get_point(self, t: RealNumber) -> 'Point3':
     """
         获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
         Args:
@@ -120,18 +98,13 @@ ValueError: 直线不共面
         Returns:
 
         """
-    return self.point + t * self.direction

def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

 获取直线的参数方程。

Returns:

x(t), y(t), z(t)
-
源代码
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    return self.point + t * self.direction
  • def get_parametric_equations(self)

获取直线的参数方程。

返回:

x(t), y(t), z(t)

源码
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
     """
         获取直线的参数方程。
         Returns:
             x(t), y(t), z(t)
         """
-    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

def is_approx_parallel(self, other: 'Line3', epsilon: float) -> bool

 判断两条直线是否近似平行。

Args:

other: 另一条直线
-
-epsilon: 误差
-

Returns:

是否近似平行
-
源代码
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)
  • def is_approx_parallel(self, other: 'Line3', epsilon: float = 1e-06)

判断两条直线是否近似平行。

参数:

other: 另一条直线

epsilon: 误差

源码
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
     """
         判断两条直线是否近似平行。
         Args:
@@ -140,9 +113,7 @@ epsilon: 误差
         Returns:
             是否近似平行
         """
-    return self.direction.is_approx_parallel(other.direction, epsilon)

def is_parallel(self, other: 'Line3') -> bool

 判断两条直线是否平行。

Args:

other: 另一条直线
-

Returns:

是否平行
-
源代码
python
def is_parallel(self, other: 'Line3') -> bool:
+    return self.direction.is_approx_parallel(other.direction, epsilon)
  • def is_parallel(self, other: 'Line3')

判断两条直线是否平行。

参数:

other: 另一条直线

源码
python
def is_parallel(self, other: 'Line3') -> bool:
     """
         判断两条直线是否平行。
         Args:
@@ -150,9 +121,7 @@ epsilon: 误差
         Returns:
             是否平行
         """
-    return self.direction.is_parallel(other.direction)

def is_collinear(self, other: 'Line3') -> bool

 判断两条直线是否共线。

Args:

other: 另一条直线
-

Returns:

是否共线
-
源代码
python
def is_collinear(self, other: 'Line3') -> bool:
+    return self.direction.is_parallel(other.direction)
  • def is_collinear(self, other: 'Line3')

判断两条直线是否共线。

参数:

other: 另一条直线

源码
python
def is_collinear(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共线。
         Args:
@@ -160,9 +129,7 @@ epsilon: 误差
         Returns:
             是否共线
         """
-    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

def is_point_on(self, point: 'Point3') -> bool

 判断点是否在直线上。

Args:

point: 点
-

Returns:

是否在直线上
-
源代码
python
def is_point_on(self, point: 'Point3') -> bool:
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)
  • def is_point_on(self, point: 'Point3')

判断点是否在直线上。

参数:

point: 点

源码
python
def is_point_on(self, point: 'Point3') -> bool:
     """
         判断点是否在直线上。
         Args:
@@ -170,9 +137,7 @@ epsilon: 误差
         Returns:
             是否在直线上
         """
-    return (point - self.point).is_parallel(self.direction)

def is_coplanar(self, other: 'Line3') -> bool

 判断两条直线是否共面。

充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

Args:

other: 另一条直线
-

Returns:

是否共面
-
源代码
python
def is_coplanar(self, other: 'Line3') -> bool:
+    return (point - self.point).is_parallel(self.direction)
  • def is_coplanar(self, other: 'Line3')

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

参数:

other: 另一条直线

源码
python
def is_coplanar(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共面。
         充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
@@ -181,7 +146,7 @@ epsilon: 误差
         Returns:
             是否共面
         """
-    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

def simplify(self) -> None

 简化直线方程,等价相等。

自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

源代码
python
def simplify(self):
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0
  • def simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

源码
python
def simplify(self):
     """
         简化直线方程,等价相等。
         自体简化,不返回值。
@@ -194,11 +159,7 @@ epsilon: 误差
     if self.direction.y == 0:
         self.point.y = 0
     if self.direction.z == 0:
-        self.point.z = 0

@classmethod

def from_two_points(cls: Any, p1: 'Point3', p2: 'Point3') -> 'Line3'

 工厂函数 由两点构造直线。

Args:

p1: 点1
-
-p2: 点2
-

Returns:

直线
-
源代码
python
@classmethod
+        self.point.z = 0
  • @classmethod

  • def from_two_points(cls, p1: 'Point3', p2: 'Point3')

工厂函数 由两点构造直线。

参数:

p1: 点1

p2: 点2

源码
python
@classmethod
 def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
     """
         工厂函数 由两点构造直线。
@@ -209,8 +170,46 @@ p2: 点2
             直线
         """
     direction = p2 - p1
-    return cls(p1, direction)

var direction = p2 - p1

var s = 'Line3: '

- + return cls(p1, direction)
  • def __and__(self, other: 'Line3')

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

参数:

other: 另一条直线

源码
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    """
+        计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
+        Args:
+            other: 另一条直线
+        Returns:
+            交点
+        """
+    if self.is_collinear(other):
+        return self
+    elif self.is_parallel(other) or not self.is_coplanar(other):
+        return None
+    else:
+        return self.cal_intersection(other)
  • def __eq__(self, other)

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

参数:

other:

源码
python
def __eq__(self, other) -> bool:
+    """
+        判断两条直线是否等价。
+
+        v1 // v2 ∧ (p1 - p2) // v1
+        Args:
+            other:
+
+        Returns:
+
+        """
+    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
源码
python
def __str__(self):
+    """
+        返回点向式(x-x0)
+        Returns:
+
+        """
+    s = 'Line3: '
+    if self.direction.x != 0:
+        s += f'(x{sign_format(-self.point.x)})/{self.direction.x}'
+    if self.direction.y != 0:
+        s += f' = (y{sign_format(-self.point.y)})/{self.direction.y}'
+    if self.direction.z != 0:
+        s += f' = (z{sign_format(-self.point.z)})/{self.direction.z}'
+    return s
源码
python
def __repr__(self):
+    return f'Line3({self.point}, {self.direction})'
+ \ No newline at end of file diff --git a/api/mp_math/mp_math_typing.html b/api/mp_math/mp_math_typing.html index f39333e..73a1cd9 100644 --- a/api/mp_math/mp_math_typing.html +++ b/api/mp_math/mp_math_typing.html @@ -3,7 +3,7 @@ - mbcp.mp\nmath.mp\nmath\ntyping | MBCP docs + mbcp.mp_math.mp_math_typing | MBCP docs @@ -12,13 +12,13 @@ - + -
Skip to content

var SingleVar = TypeVar('SingleVar', bound=Number)

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

- +
Skip to content

var RealNumber: TypeAlias = int | float

var Number: TypeAlias = RealNumber | complex

var SingleVar = TypeVar('SingleVar', bound=Number)

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

var Var: TypeAlias = SingleVar | ArrayVar

var OneSingleVarFunc: TypeAlias = Callable[[SingleVar], SingleVar]

var OneArrayFunc: TypeAlias = Callable[[ArrayVar], ArrayVar]

var OneVarFunc: TypeAlias = OneSingleVarFunc | OneArrayFunc

var TwoSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar], SingleVar]

var TwoArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar], ArrayVar]

var TwoVarsFunc: TypeAlias = TwoSingleVarsFunc | TwoArraysFunc

var ThreeSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar, SingleVar], SingleVar]

var ThreeArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar, ArrayVar], ArrayVar]

var ThreeVarsFunc: TypeAlias = ThreeSingleVarsFunc | ThreeArraysFunc

var MultiSingleVarsFunc: TypeAlias = Callable[..., SingleVar]

var MultiArraysFunc: TypeAlias = Callable[..., ArrayVar]

var MultiVarsFunc: TypeAlias = MultiSingleVarsFunc | MultiArraysFunc

+ \ No newline at end of file diff --git a/api/mp_math/plane.html b/api/mp_math/plane.html index 2e7bd78..b02677b 100644 --- a/api/mp_math/plane.html +++ b/api/mp_math/plane.html @@ -3,7 +3,7 @@ - mbcp.mp\nmath.plane | MBCP docs + mbcp.mp_math.plane | MBCP docs @@ -12,19 +12,12 @@ - + -
Skip to content

class Plane3

def __init__(self, a: float, b: float, c: float, d: float) -> None

 平面方程:ax + by + cz + d = 0

Args:

a:
-
-b:
-
-c:
-
-d:
-
源代码
python
def __init__(self, a: float, b: float, c: float, d: float):
+    
Skip to content

var k = other.a / self.a

var A = np.array([[self.b, self.c], [other.b, other.c]])

var B = np.array([-self.d, -other.d])

var v2 = l2.get_point(1) - l1.point

var k = other.b / self.b

var A = np.array([[self.a, self.c], [other.a, other.c]])

var B = np.array([-self.d, -other.d])

var k = other.c / self.c

var A = np.array([[self.a, self.b], [other.a, other.b]])

var B = np.array([-self.d, -other.d])

class Plane3

  • def __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

参数:

a:

b:

c:

d:

源码
python
def __init__(self, a: float, b: float, c: float, d: float):
     """
         平面方程:ax + by + cz + d = 0
         Args:
@@ -36,16 +29,11 @@ d:
     self.a = a
     self.b = b
     self.c = c
-    self.d = d

def approx(self, other: 'Plane3', epsilon: float) -> bool

 判断两个平面是否近似相等。

Args:

other:
-
-epsilon:
-

Returns:

是否近似相等
-
源代码
python
def approx(self, other: 'Plane3', epsilon: float=APPROX) -> bool:
+    self.d = d
  • def approx(self, other: 'Plane3')

判断两个平面是否近似相等。

参数:

other:

源码
python
def approx(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否近似相等。
         Args:
             other:
-            epsilon:
 
         Returns:
             是否近似相等
@@ -60,10 +48,7 @@ epsilon:
         k = other.c / self.c
         return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
     else:
-        return False

def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle'

 计算平面与平面之间的夹角。

Args:

other: 另一个平面
-

Returns:

夹角弧度
-

Raises:

TypeError: 不支持的类型
-
源代码
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+        return False
  • def cal_angle(self, other: 'Line3 | Plane3')

计算平面与平面之间的夹角。

参数:

other: 另一个平面

源码
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
     """
         计算平面与平面之间的夹角。
         Args:
@@ -78,10 +63,7 @@ epsilon:
     elif isinstance(other, Plane3):
         return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

def cal_distance(self, other: 'Plane3 | Point3') -> float

 计算平面与平面或点之间的距离。

Args:

other: 另一个平面或点
-

Returns:

距离
-

Raises:

TypeError: 不支持的类型
-
源代码
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+        raise TypeError(f'Unsupported type: {type(other)}')
  • def cal_distance(self, other: 'Plane3 | Point3')

计算平面与平面或点之间的距离。

参数:

other: 另一个平面或点

源码
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
     """
         计算平面与平面或点之间的距离。
         Args:
@@ -96,9 +78,7 @@ epsilon:
     elif isinstance(other, Point3):
         return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

def cal_intersection_line3(self, other: 'Plane3') -> 'Line3'

 计算两平面的交线。该方法有问题,待修复。

Args:

other: 另一个平面
-

Returns:

交线
-

Raises:

源代码
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+        raise TypeError(f'Unsupported type: {type(other)}')
  • def cal_intersection_line3(self, other: 'Plane3')

计算两平面的交线。该方法有问题,待修复。

参数:

other: 另一个平面

源码
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
     """
         计算两平面的交线。该方法有问题,待修复。
         Args:
@@ -123,10 +103,7 @@ epsilon:
         A = np.array([[self.a, self.b], [other.a, other.b]])
         B = np.array([-self.d, -other.d])
         x, y = np.linalg.solve(A, B)
-    return Line3(Point3(x, y, z), direction)

def cal_intersection_point3(self, other: 'Line3') -> 'Point3'

 计算平面与直线的交点。

Args:

other: 不与平面平行或在平面上的直线
-

Returns:

交点
-

Raises:

ValueError: 平面与直线平行或重合
-
源代码
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    return Line3(Point3(x, y, z), direction)
  • def cal_intersection_point3(self, other: 'Line3')

计算平面与直线的交点。

参数:

other: 不与平面平行或在平面上的直线

源码
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
     """
         计算平面与直线的交点。
         Args:
@@ -140,9 +117,7 @@ epsilon:
         raise ValueError('The plane and the line are parallel or coincident.')
     x, y, z = other.get_parametric_equations()
     t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
-    return Point3(x(t), y(t), z(t))

def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3'

 计算平行于该平面且过指定点的平面。

Args:

point: 指定点
-

Returns:

平面
-
源代码
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    return Point3(x(t), y(t), z(t))
  • def cal_parallel_plane3(self, point: 'Point3')

计算平行于该平面且过指定点的平面。

参数:

point: 指定点

源码
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
     """
         计算平行于该平面且过指定点的平面。
         Args:
@@ -150,9 +125,7 @@ epsilon:
         Returns:
             平面
         """
-    return Plane3.from_point_and_normal(point, self.normal)

def is_parallel(self, other: 'Plane3') -> bool

 判断两个平面是否平行。

Args:

other: 另一个平面
-

Returns:

是否平行
-
源代码
python
def is_parallel(self, other: 'Plane3') -> bool:
+    return Plane3.from_point_and_normal(point, self.normal)
  • def is_parallel(self, other: 'Plane3')

判断两个平面是否平行。

参数:

other: 另一个平面

源码
python
def is_parallel(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否平行。
         Args:
@@ -160,19 +133,14 @@ epsilon:
         Returns:
             是否平行
         """
-    return self.normal.is_parallel(other.normal)

@property

def normal(self: Any) -> 'Vector3'

 平面的法向量。

Returns:

法向量
-
源代码
python
@property
+    return self.normal.is_parallel(other.normal)
  • @property

  • def normal(self)

平面的法向量。

返回:

法向量

源码
python
@property
 def normal(self) -> 'Vector3':
     """
         平面的法向量。
         Returns:
             法向量
         """
-    return Vector3(self.a, self.b, self.c)

@classmethod

def from_point_and_normal(cls: Any, point: 'Point3', normal: 'Vector3') -> 'Plane3'

 工厂函数 由点和法向量构造平面(点法式构造)。

Args:

point: 平面上的一点
-
-normal: 法向量
-

Returns:

平面
-
源代码
python
@classmethod
+    return Vector3(self.a, self.b, self.c)
  • @classmethod

  • def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3')

工厂函数 由点和法向量构造平面(点法式构造)。

参数:

point: 平面上的一点

normal: 法向量

源码
python
@classmethod
 def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
     """
         工厂函数 由点和法向量构造平面(点法式构造)。
@@ -184,13 +152,7 @@ normal: 法向量
         """
     a, b, c = (normal.x, normal.y, normal.z)
     d = -a * point.x - b * point.y - c * point.z
-    return cls(a, b, c, d)

@classmethod

def from_three_points(cls: Any, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3'

 工厂函数 由三点构造平面。

Args:

p1: 点1
-
-p2: 点2
-
-p3: 点3
-

Returns:

平面
-
源代码
python
@classmethod
+    return cls(a, b, c, d)
  • @classmethod

  • def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3')

工厂函数 由三点构造平面。

参数:

p1: 点1

p2: 点2

p3: 点3

源码
python
@classmethod
 def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
     """
         工厂函数 由三点构造平面。
@@ -204,11 +166,7 @@ p3: 点3
     v1 = p2 - p1
     v2 = p3 - p1
     normal = v1.cross(v2)
-    return cls.from_point_and_normal(p1, normal)

@classmethod

def from_two_lines(cls: Any, l1: 'Line3', l2: 'Line3') -> 'Plane3'

 工厂函数 由两直线构造平面。

Args:

l1: 直线1
-
-l2: 直线2
-

Returns:

平面
-
源代码
python
@classmethod
+    return cls.from_point_and_normal(p1, normal)
  • @classmethod

  • def from_two_lines(cls, l1: 'Line3', l2: 'Line3')

工厂函数 由两直线构造平面。

参数:

l1: 直线1

l2: 直线2

源码
python
@classmethod
 def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
     """
         工厂函数 由两直线构造平面。
@@ -222,11 +180,7 @@ l2: 直线2
     v2 = l2.point - l1.point
     if v2 == zero_vector3:
         v2 = l2.get_point(1) - l1.point
-    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

def from_point_and_line(cls: Any, point: 'Point3', line: 'Line3') -> 'Plane3'

 工厂函数 由点和直线构造平面。

Args:

point: 面上一点
-
-line: 面上直线,不包含点
-

Returns:

平面
-
源代码
python
@classmethod
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))
  • @classmethod

  • def from_point_and_line(cls, point: 'Point3', line: 'Line3')

工厂函数 由点和直线构造平面。

参数:

point: 面上一点

line: 面上直线,不包含点

源码
python
@classmethod
 def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
     """
         工厂函数 由点和直线构造平面。
@@ -236,8 +190,42 @@ line: 面上直线,不包含点
         Returns:
             平面
         """
-    return cls.from_point_and_normal(point, line.direction)

var direction = self.normal.cross(other.normal)

var t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)

var d = -a * point.x - b * point.y - c * point.z

var v1 = p2 - p1

var v2 = p3 - p1

var normal = v1.cross(v2)

var v1 = l1.direction

var v2 = l2.point - l1.point

var s = 'Plane3: '

var k = other.a / self.a

var A = np.array([[self.b, self.c], [other.b, other.c]])

var B = np.array([-self.d, -other.d])

var v2 = l2.get_point(1) - l1.point

var k = other.b / self.b

var A = np.array([[self.a, self.c], [other.a, other.c]])

var B = np.array([-self.d, -other.d])

var k = other.c / self.c

var A = np.array([[self.a, self.b], [other.a, other.b]])

var B = np.array([-self.d, -other.d])

- + return cls.from_point_and_normal(point, line.direction)
源码
python
def __repr__(self):
+    return f'Plane3({self.a}, {self.b}, {self.c}, {self.d})'
源码
python
def __str__(self):
+    s = 'Plane3: '
+    if self.a != 0:
+        s += f'{sign(self.a, only_neg=True)}{abs(self.a)}x'
+    if self.b != 0:
+        s += f' {sign(self.b)} {abs(self.b)}y'
+    if self.c != 0:
+        s += f' {sign(self.c)} {abs(self.c)}z'
+    if self.d != 0:
+        s += f' {sign(self.d)} {abs(self.d)}'
+    return s + ' = 0'
  • @overload

  • def __and__(self, other: 'Line3')

源码
python
@overload
+def __and__(self, other: 'Line3') -> 'Point3 | None':
+    ...
  • @overload

  • def __and__(self, other: 'Plane3')

源码
python
@overload
+def __and__(self, other: 'Plane3') -> 'Line3 | None':
+    ...
  • def __and__(self, other)

取两平面的交集(人话:交线)

参数:

other:

源码
python
def __and__(self, other):
+    """
+        取两平面的交集(人话:交线)
+        Args:
+            other:
+        Returns:
+            不平行平面的交线,平面平行返回None
+        """
+    if isinstance(other, Plane3):
+        if self.normal.is_parallel(other.normal):
+            return None
+        return self.cal_intersection_line3(other)
+    elif isinstance(other, Line3):
+        if self.normal @ other.direction == 0:
+            return None
+        return self.cal_intersection_point3(other)
+    else:
+        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")
  • def __eq__(self, other)

源码
python
def __eq__(self, other) -> bool:
+    return self.approx(other)
  • def __rand__(self, other: 'Line3')

源码
python
def __rand__(self, other: 'Line3') -> 'Point3':
+    return self.cal_intersection_point3(other)
+ \ No newline at end of file diff --git a/api/mp_math/point.html b/api/mp_math/point.html index 5d38d3d..9013fb6 100644 --- a/api/mp_math/point.html +++ b/api/mp_math/point.html @@ -3,7 +3,7 @@ - mbcp.mp\nmath.point | MBCP docs + mbcp.mp_math.point | MBCP docs @@ -12,17 +12,12 @@ - + -
Skip to content

class Point3

def __init__(self, x: float, y: float, z: float) -> None

 笛卡尔坐标系中的点。

Args:

x: x 坐标
-
-y: y 坐标
-
-z: z 坐标
-
源代码
python
def __init__(self, x: float, y: float, z: float):
+    
Skip to content

class Point3

  • def __init__(self, x: float, y: float, z: float)

笛卡尔坐标系中的点。

参数:

x: x 坐标

y: y 坐标

z: z 坐标

源码
python
def __init__(self, x: float, y: float, z: float):
     """
         笛卡尔坐标系中的点。
         Args:
@@ -32,11 +27,7 @@ z: z 坐标
         """
     self.x = x
     self.y = y
-    self.z = z

def approx(self, other: 'Point3', epsilon: float) -> bool

 判断两个点是否近似相等。

Args:

other:
-
-epsilon:
-

Returns:

是否近似相等
-
源代码
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    self.z = z
  • def approx(self, other: 'Point3', epsilon: float = APPROX)

判断两个点是否近似相等。

参数:

other:

epsilon:

源码
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
     """
         判断两个点是否近似相等。
         Args:
@@ -46,8 +37,28 @@ epsilon:
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
- + return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
源码
python
def __str__(self):
+    return f'Point3({self.x}, {self.y}, {self.z})'
  • @overload

  • def __add__(self, other: 'Vector3')

源码
python
@overload
+def __add__(self, other: 'Vector3') -> 'Point3':
+    ...
  • @overload

  • def __add__(self, other: 'Point3')

源码
python
@overload
+def __add__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __add__(self, other)

P + V -> P P + P -> P

参数:

other:

源码
python
def __add__(self, other):
+    """
+        P + V -> P
+        P + P -> P
+        Args:
+            other:
+        Returns:
+        """
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
  • def __eq__(self, other)

判断两个点是否相等。

参数:

other:

源码
python
def __eq__(self, other):
+    """
+        判断两个点是否相等。
+        Args:
+            other:
+        Returns:
+        """
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)
+ \ No newline at end of file diff --git a/api/mp_math/segment.html b/api/mp_math/segment.html index 378c75d..47ebfec 100644 --- a/api/mp_math/segment.html +++ b/api/mp_math/segment.html @@ -3,7 +3,7 @@ - mbcp.mp\nmath.segment | MBCP docs + mbcp.mp_math.segment | MBCP docs @@ -12,12 +12,12 @@ - + -
Skip to content

class Segment3

def __init__(self, p1: 'Point3', p2: 'Point3') -> None

 三维空间中的线段。

:param p1:

:param p2:

源代码
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+    
Skip to content

class Segment3

  • def __init__(self, p1: 'Point3', p2: 'Point3')

三维空间中的线段。 :param p1: :param p2:

源码
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
     """
         三维空间中的线段。
         :param p1:
@@ -30,8 +30,10 @@
     '长度'
     self.length = self.direction.length
     '中心点'
-    self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
- + self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
源码
python
def __repr__(self):
+    return f'Segment3({self.p1}, {self.p2})'
源码
python
def __str__(self):
+    return f'Segment3({self.p1} -> {self.p2})'
+ \ No newline at end of file diff --git a/api/mp_math/utils.html b/api/mp_math/utils.html index e5322b1..272252c 100644 --- a/api/mp_math/utils.html +++ b/api/mp_math/utils.html @@ -3,7 +3,7 @@ - mbcp.mp\nmath.utils | MBCP docs + mbcp.mp_math.utils | MBCP docs @@ -12,18 +12,12 @@ - + -
Skip to content

def clamp(x: float, min_: float, max_: float) -> float

区间截断函数。

Args:

x:
-
-min_:
-
-max_:
-

Returns:

限制后的值
-
源代码
python
def clamp(x: float, min_: float, max_: float) -> float:
+    
Skip to content

def clamp()

区间截断函数。

参数:

x:

min_:

max_:

源码
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间截断函数。
     Args:
@@ -34,13 +28,7 @@ max_:
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

def approx(x: float, y: float, epsilon: float) -> bool

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

Args:

x:
-
-y:
-
-epsilon:
-

Returns:

是否近似相等
-
源代码
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    return max(min(x, max_), min_)

def approx(x: float = 0.0, y: float = APPROX)

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

参数:

x:

y:

epsilon:

源码
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
     """
     判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
     Args:
@@ -51,11 +39,7 @@ epsilon:
     Returns:
         是否近似相等
     """
-    return abs(x - y) < epsilon

def sign(x: float, only_neg: bool) -> str

获取数的符号。

Args:

x: 数
-
-only_neg: 是否只返回负数的符号
-

Returns:

符号 + - ""
-
源代码
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

def sign(x: float = False)

获取数的符号。

参数:

x: 数

only_neg: 是否只返回负数的符号

源码
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -68,11 +52,7 @@ only_neg: 是否只返回负数的符号
     elif x < 0:
         return '-'
     else:
-        return ''

def sign_format(x: float, only_neg: bool) -> str

格式化符号数

-1 -> -1

1 -> +1

0 -> ""

Args:

x: 数
-
-only_neg: 是否只返回负数的符号
-

Returns:

符号 + - ""
-
源代码
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

def sign_format(x: float = False)

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

参数:

x: 数

only_neg: 是否只返回负数的符号

源码
python
def sign_format(x: float, only_neg: bool=False) -> str:
     """格式化符号数
     -1 -> -1
     1 -> +1
@@ -88,10 +68,21 @@ only_neg: 是否只返回负数的符号
     elif x < 0:
         return f'-{abs(x)}'
     else:
-        return ''

class Approx

用于近似比较对象

已实现对象 实数 Vector3 Point3 Plane3 Line3

def __init__(self, value: RealNumber) -> None

源代码
python
def __init__(self, value: RealNumber):
-    self.value = value

def raise_type_error(self, other: Any) -> None

源代码
python
def raise_type_error(self, other):
-    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')
- + return ''

class Approx

  • def __init__(self, value: RealNumber)

源码
python
def __init__(self, value: RealNumber):
+    self.value = value
  • def __eq__(self, other)

源码
python
def __eq__(self, other):
+    if isinstance(self.value, (float, int)):
+        if isinstance(other, (float, int)):
+            return abs(self.value - other) < APPROX
+        else:
+            self.raise_type_error(other)
+    elif isinstance(self.value, Vector3):
+        if isinstance(other, (Vector3, Point3, Plane3, Line3)):
+            return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
+        else:
+            self.raise_type_error(other)
  • def raise_type_error(self, other)

源码
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')
  • def __ne__(self, other)

源码
python
def __ne__(self, other):
+    return not self.__eq__(other)
+ \ No newline at end of file diff --git a/api/mp_math/vector.html b/api/mp_math/vector.html index 7445219..2b0a890 100644 --- a/api/mp_math/vector.html +++ b/api/mp_math/vector.html @@ -3,7 +3,7 @@ - mbcp.mp\nmath.vector | MBCP docs + mbcp.mp_math.vector | MBCP docs @@ -12,17 +12,12 @@ - + -
Skip to content

class Vector3

def __init__(self, x: float, y: float, z: float) -> None

 3维向量

Args:

x: x轴分量
-
-y: y轴分量
-
-z: z轴分量
-
源代码
python
def __init__(self, x: float, y: float, z: float):
+    
Skip to content

var zero_vector3 = Vector3(0, 0, 0)

var x_axis = Vector3(1, 0, 0)

var y_axis = Vector3(0, 1, 0)

var z_axis = Vector3(0, 0, 1)

class Vector3

  • def __init__(self, x: float, y: float, z: float)

3维向量

参数:

x: x轴分量

y: y轴分量

z: z轴分量

源码
python
def __init__(self, x: float, y: float, z: float):
     """
         3维向量
         Args:
@@ -32,11 +27,7 @@ z: z轴分量
         """
     self.x = x
     self.y = y
-    self.z = z

def approx(self, other: 'Vector3', epsilon: float) -> bool

 判断两个向量是否近似相等。

Args:

other:
-
-epsilon:
-

Returns:

是否近似相等
-
源代码
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    self.z = z
  • def approx(self, other: 'Vector3', epsilon: float = APPROX)

判断两个向量是否近似相等。

参数:

other:

epsilon:

源码
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似相等。
         Args:
@@ -46,9 +37,7 @@ epsilon:
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

def cal_angle(self, other: 'Vector3') -> 'AnyAngle'

 计算两个向量之间的夹角。

Args:

other: 另一个向量
-

Returns:

夹角
-
源代码
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
  • def cal_angle(self, other: 'Vector3')

计算两个向量之间的夹角。

参数:

other: 另一个向量

源码
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
     """
         计算两个向量之间的夹角。
         Args:
@@ -56,9 +45,7 @@ epsilon:
         Returns:
             夹角
         """
-    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

def cross(self, other: 'Vector3') -> 'Vector3'

 向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。

其余结果的模为平行四边形的面积。

返回如下行列式的结果:

i j k

x1 y1 z1

x2 y2 z2

Args:

other:
-

Returns:

行列式的结果
-
源代码
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)
  • def cross(self, other: 'Vector3')

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

源码
python
def cross(self, other: 'Vector3') -> 'Vector3':
     """
         向量积 叉乘:v1 cross v2 -> v3
 
@@ -78,11 +65,7 @@ epsilon:
         Returns:
             行列式的结果
         """
-    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

def is_approx_parallel(self, other: 'Vector3', epsilon: float) -> bool

 判断两个向量是否近似平行。

Args:

other: 另一个向量
-
-epsilon: 允许的误差
-

Returns:

是否近似平行
-
源代码
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)
  • def is_approx_parallel(self, other: 'Vector3', epsilon: float = APPROX)

判断两个向量是否近似平行。

参数:

other: 另一个向量

epsilon: 允许的误差

源码
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似平行。
         Args:
@@ -91,9 +74,7 @@ epsilon: 允许的误差
         Returns:
             是否近似平行
         """
-    return self.cross(other).length < epsilon

def is_parallel(self, other: 'Vector3') -> bool

 判断两个向量是否平行。

Args:

other: 另一个向量
-

Returns:

是否平行
-
源代码
python
def is_parallel(self, other: 'Vector3') -> bool:
+    return self.cross(other).length < epsilon
  • def is_parallel(self, other: 'Vector3')

判断两个向量是否平行。

参数:

other: 另一个向量

源码
python
def is_parallel(self, other: 'Vector3') -> bool:
     """
         判断两个向量是否平行。
         Args:
@@ -101,7 +82,7 @@ epsilon: 允许的误差
         Returns:
             是否平行
         """
-    return self.cross(other).approx(zero_vector3)

def normalize(self) -> None

 将向量归一化。

自体归一化,不返回值。

源代码
python
def normalize(self):
+    return self.cross(other).approx(zero_vector3)
  • def normalize(self)

将向量归一化。

自体归一化,不返回值。

源码
python
def normalize(self):
     """
         将向量归一化。
 
@@ -110,30 +91,122 @@ epsilon: 允许的误差
     length = self.length
     self.x /= length
     self.y /= length
-    self.z /= length

@property

def np_array(self: Any) -> 'np.ndarray'

 返回numpy数组

Returns:

源代码
python
@property
+    self.z /= length
源码
python
@property
 def np_array(self) -> 'np.ndarray':
     """
         返回numpy数组
         Returns:
         """
-    return np.array([self.x, self.y, self.z])

@property

def length(self: Any) -> float

 向量的模。

Returns:

模
-
源代码
python
@property
+    return np.array([self.x, self.y, self.z])
  • @property

  • def length(self)

向量的模。

返回:

源码
python
@property
 def length(self) -> float:
     """
         向量的模。
         Returns:
 
         """
-    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

def unit(self: Any) -> 'Vector3'

 获取该向量的单位向量。

Returns:

单位向量
-
源代码
python
@property
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)
  • @property

  • def unit(self)

获取该向量的单位向量。

返回:

单位向量

源码
python
@property
 def unit(self) -> 'Vector3':
     """
         获取该向量的单位向量。
         Returns:
             单位向量
         """
-    return self / self.length

var zero_vector3 = Vector3(0, 0, 0)

var x_axis = Vector3(1, 0, 0)

var y_axis = Vector3(0, 1, 0)

var z_axis = Vector3(0, 0, 1)

var length = self.length

- + return self / self.length
源码
python
def __abs__(self):
+    return self.length
  • @overload

  • def __add__(self, other: 'Vector3')

源码
python
@overload
+def __add__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __add__(self, other: 'Point3')

源码
python
@overload
+def __add__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __add__(self, other)

V + P -> P

V + V -> V

参数:

other:

源码
python
def __add__(self, other):
+    """
+        V + P -> P
+
+        V + V -> V
+        Args:
+            other:
+        Returns:
+
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x + other.x, self.y + other.y, self.z + other.z)
+    elif isinstance(other, Point3):
+        return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
+    else:
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")
  • def __eq__(self, other)

判断两个向量是否相等。

参数:

other:

源码
python
def __eq__(self, other):
+    """
+        判断两个向量是否相等。
+        Args:
+            other:
+        Returns:
+            是否相等
+        """
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)
  • def __radd__(self, other: 'Point3')

P + V -> P

别去点那边实现了。 :param other: :return:

源码
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    """
+        P + V -> P
+
+        别去点那边实现了。
+        :param other:
+        :return:
+        """
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
  • @overload

  • def __sub__(self, other: 'Vector3')

源码
python
@overload
+def __sub__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __sub__(self, other: 'Point3')

源码
python
@overload
+def __sub__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __sub__(self, other)

V - P -> P

V - V -> V

参数:

other:

源码
python
def __sub__(self, other):
+    """
+        V - P -> P
+
+        V - V -> V
+        Args:
+            other:
+        Returns:
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
+    elif isinstance(other, Point3):
+        return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
+    else:
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')
  • def __rsub__(self, other: 'Point3')

P - V -> P

参数:

other:

源码
python
def __rsub__(self, other: 'Point3'):
+    """
+        P - V -> P
+        Args:
+            other:
+        Returns:
+
+        """
+    if isinstance(other, Point3):
+        return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
+    else:
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")
  • @overload

  • def __mul__(self, other: 'Vector3')

源码
python
@overload
+def __mul__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __mul__(self, other: RealNumber)

源码
python
@overload
+def __mul__(self, other: RealNumber) -> 'Vector3':
+    ...
  • def __mul__(self, other: 'int | float | Vector3')

数组运算 非点乘。点乘使用@,叉乘使用cross。

参数:

other:

源码
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    """
+        数组运算 非点乘。点乘使用@,叉乘使用cross。
+        Args:
+            other:
+
+        Returns:
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x * other.x, self.y * other.y, self.z * other.z)
+    elif isinstance(other, (float, int)):
+        return Vector3(self.x * other, self.y * other, self.z * other)
+    else:
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")
  • def __rmul__(self, other: 'RealNumber')

源码
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)
  • def __matmul__(self, other: 'Vector3')

点乘。

参数:

other:

源码
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+    """
+        点乘。
+        Args:
+            other:
+        Returns:
+        """
+    return self.x * other.x + self.y * other.y + self.z * other.z
  • def __truediv__(self, other: RealNumber)

源码
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)
源码
python
def __neg__(self):
+    return Vector3(-self.x, -self.y, -self.z)
源码
python
def __repr__(self):
+    return f'Vector3({self.x}, {self.y}, {self.z})'
源码
python
def __str__(self):
+    return f'Vector3({self.x}, {self.y}, {self.z})'
+ \ No newline at end of file diff --git a/api/particle/index.html b/api/particle/index.html index fb560ac..b73caba 100644 --- a/api/particle/index.html +++ b/api/particle/index.html @@ -3,7 +3,7 @@ - mbcp.particle.\n\ninit\n\n | MBCP docs + mbcp.particle | MBCP docs @@ -12,13 +12,13 @@ - + -
Skip to content
- + + \ No newline at end of file diff --git a/api/presets/index.html b/api/presets/index.html index 17c9720..7d167b3 100644 --- a/api/presets/index.html +++ b/api/presets/index.html @@ -3,7 +3,7 @@ - mbcp.presets.\n\ninit\n\n | MBCP docs + mbcp.presets | MBCP docs @@ -12,13 +12,13 @@ - + -
Skip to content
- + + \ No newline at end of file diff --git a/api/presets/model/index.html b/api/presets/model/index.html index 19dfbff..f2beffb 100644 --- a/api/presets/model/index.html +++ b/api/presets/model/index.html @@ -3,7 +3,7 @@ - mbcp.presets.model.\n\ninit\n\n | MBCP docs + mbcp.presets.model | MBCP docs @@ -12,16 +12,12 @@ - + -
Skip to content

def sphere(radius: float, density: float) -> None

生成球体上的点集。

Args:

radius:
-
-density:
-

Returns:

List[Point3]: 球体上的点集。
-
源代码
python
@staticmethod
+    
Skip to content

class GeometricModels

  • @staticmethod

  • def sphere(radius: float, density: float)

生成球体上的点集。

参数:

radius:

density:

源码
python
@staticmethod
 def sphere(radius: float, density: float):
     """
         生成球体上的点集。
@@ -38,29 +34,8 @@ density:
     x_array = radius * np.sin(phi_list) * np.cos(theta_list)
     y_array = radius * np.sin(phi_list) * np.sin(theta_list)
     z_array = radius * np.cos(phi_list)
-    return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]

class GeometricModels

@staticmethod

def sphere(radius: float, density: float) -> None

 生成球体上的点集。

Args:

radius:
-
-density:
-

Returns:

List[Point3]: 球体上的点集。
-
源代码
python
@staticmethod
-def sphere(radius: float, density: float):
-    """
-        生成球体上的点集。
-        Args:
-            radius:
-            density:
-        Returns:
-            List[Point3]: 球体上的点集。
-        """
-    area = 4 * np.pi * radius ** 2
-    num = int(area * density)
-    phi_list = np.arccos([clamp(-1 + (2.0 * _ - 1.0) / num, -1, 1) for _ in range(num)])
-    theta_list = np.sqrt(num * np.pi) * phi_list
-    x_array = radius * np.sin(phi_list) * np.cos(theta_list)
-    y_array = radius * np.sin(phi_list) * np.sin(theta_list)
-    z_array = radius * np.cos(phi_list)
-    return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]

var area = 4 * np.pi * radius ** 2

var num = int(area * density)

var phi_list = np.arccos([clamp(-1 + (2.0 * _ - 1.0) / num, -1, 1) for _ in range(num)])

var theta_list = np.sqrt(num * np.pi) * phi_list

var x_array = radius * np.sin(phi_list) * np.cos(theta_list)

var y_array = radius * np.sin(phi_list) * np.sin(theta_list)

var z_array = radius * np.cos(phi_list)

- + return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
+ \ No newline at end of file diff --git a/assets/api_index.md.BvazTqTB.js b/assets/api_index.md.BvazTqTB.js new file mode 100644 index 0000000..8dcd57c --- /dev/null +++ b/assets/api_index.md.BvazTqTB.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp","description":"","frontmatter":{"title":"mbcp"},"headers":[],"relativePath":"api/index.md","filePath":"api/index.md"}'),n={name:"api/index.md"};function i(r,c,o,p,s,d){return a(),t("div")}const f=e(n,[["render",i]]);export{_ as __pageData,f as default}; diff --git a/assets/api_index.md.BvazTqTB.lean.js b/assets/api_index.md.BvazTqTB.lean.js new file mode 100644 index 0000000..8dcd57c --- /dev/null +++ b/assets/api_index.md.BvazTqTB.lean.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp","description":"","frontmatter":{"title":"mbcp"},"headers":[],"relativePath":"api/index.md","filePath":"api/index.md"}'),n={name:"api/index.md"};function i(r,c,o,p,s,d){return a(),t("div")}const f=e(n,[["render",i]]);export{_ as __pageData,f as default}; diff --git a/assets/api_index.md.CsKClHFh.js b/assets/api_index.md.CsKClHFh.js deleted file mode 100644 index 5e98a95..0000000 --- a/assets/api_index.md.CsKClHFh.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,c as t,o as n}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp.\\\\n\\\\ninit\\\\n\\\\n","description":"","frontmatter":{"title":"mbcp.\\\\n\\\\ninit\\\\n\\\\n","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/index.md","filePath":"api/index.md"}'),a={name:"api/index.md"};function i(o,r,c,p,d,s){return n(),t("div")}const l=e(a,[["render",i]]);export{_ as __pageData,l as default}; diff --git a/assets/api_index.md.CsKClHFh.lean.js b/assets/api_index.md.CsKClHFh.lean.js deleted file mode 100644 index 5e98a95..0000000 --- a/assets/api_index.md.CsKClHFh.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,c as t,o as n}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp.\\\\n\\\\ninit\\\\n\\\\n","description":"","frontmatter":{"title":"mbcp.\\\\n\\\\ninit\\\\n\\\\n","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/index.md","filePath":"api/index.md"}'),a={name:"api/index.md"};function i(o,r,c,p,d,s){return n(),t("div")}const l=e(a,[["render",i]]);export{_ as __pageData,l as default}; diff --git a/assets/api_mp_math_angle.md.7ZvAVHFT.js b/assets/api_mp_math_angle.md.7ZvAVHFT.js new file mode 100644 index 0000000..8294e09 --- /dev/null +++ b/assets/api_mp_math_angle.md.7ZvAVHFT.js @@ -0,0 +1,101 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const c=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"api/mp_math/angle.md","filePath":"api/mp_math/angle.md"}'),e={name:"api/mp_math/angle.md"},n=l(`

class Angle

class AnyAngle

  • def __init__(self, value: float, is_radian: bool = False)

任意角度。

参数:

value: 角度或弧度值

is_radian: 是否为弧度,默认为否

源码
python
def __init__(self, value: float, is_radian: bool=False):
+    """
+        任意角度。
+        Args:
+            value: 角度或弧度值
+            is_radian: 是否为弧度,默认为否
+        """
+    if is_radian:
+        self.radian = value
+    else:
+        self.radian = value * PI / 180
  • @property

  • def complementary(self)

余角:两角的和为90°。

返回:

余角

源码
python
@property
+def complementary(self) -> 'AnyAngle':
+    """
+        余角:两角的和为90°。
+        Returns:
+            余角
+        """
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)
  • @property

  • def supplementary(self)

补角:两角的和为180°。

返回:

补角

源码
python
@property
+def supplementary(self) -> 'AnyAngle':
+    """
+        补角:两角的和为180°。
+        Returns:
+            补角
+        """
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)
  • @property

  • def degree(self)

角度。

返回:

弧度

源码
python
@property
+def degree(self) -> float:
+    """
+        角度。
+        Returns:
+            弧度
+        """
+    return self.radian * 180 / PI
  • @property

  • def minimum_positive(self)

最小正角。

返回:

最小正角度

源码
python
@property
+def minimum_positive(self) -> 'AnyAngle':
+    """
+        最小正角。
+        Returns:
+            最小正角度
+        """
+    return AnyAngle(self.radian % (2 * PI))
  • @property

  • def maximum_negative(self)

最大负角。

返回:

最大负角度

源码
python
@property
+def maximum_negative(self) -> 'AnyAngle':
+    """
+        最大负角。
+        Returns:
+            最大负角度
+        """
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)
  • @property

  • def sin(self)

正弦值。

返回:

正弦值

源码
python
@property
+def sin(self) -> float:
+    """
+        正弦值。
+        Returns:
+            正弦值
+        """
+    return math.sin(self.radian)
  • @property

  • def cos(self)

余弦值。

返回:

余弦值

源码
python
@property
+def cos(self) -> float:
+    """
+        余弦值。
+        Returns:
+            余弦值
+        """
+    return math.cos(self.radian)
  • @property

  • def tan(self)

正切值。

返回:

正切值

源码
python
@property
+def tan(self) -> float:
+    """
+        正切值。
+        Returns:
+            正切值
+        """
+    return math.tan(self.radian)
  • @property

  • def cot(self)

余切值。

返回:

余切值

源码
python
@property
+def cot(self) -> float:
+    """
+        余切值。
+        Returns:
+            余切值
+        """
+    return 1 / math.tan(self.radian)
  • @property

  • def sec(self)

正割值。

返回:

正割值

源码
python
@property
+def sec(self) -> float:
+    """
+        正割值。
+        Returns:
+            正割值
+        """
+    return 1 / math.cos(self.radian)
  • @property

  • def csc(self)

余割值。

返回:

余割值

源码
python
@property
+def csc(self) -> float:
+    """
+        余割值。
+        Returns:
+            余割值
+        """
+    return 1 / math.sin(self.radian)
  • def __add__(self, other: 'AnyAngle')

源码
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)
  • def __eq__(self, other)

源码
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)
  • def __sub__(self, other: 'AnyAngle')

源码
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)
  • def __mul__(self, other: float)

源码
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)
源码
python
def __repr__(self):
+    return f'AnyAngle({self.radian}, is_radian=True)'
源码
python
def __str__(self):
+    return f'AnyAngle({self.degree}° or {self.radian} rad)'
  • @overload

  • def __truediv__(self, other: float)

源码
python
@overload
+def __truediv__(self, other: float) -> 'AnyAngle':
+    ...
  • @overload

  • def __truediv__(self, other: 'AnyAngle')

源码
python
@overload
+def __truediv__(self, other: 'AnyAngle') -> float:
+    ...
  • def __truediv__(self, other)

源码
python
def __truediv__(self, other):
+    if isinstance(other, AnyAngle):
+        return self.radian / other.radian
+    return AnyAngle(self.radian / other, is_radian=True)
`,93),t=[n];function h(p,k,r,d,o,y){return a(),i("div",null,t)}const F=s(e,[["render",h]]);export{c as __pageData,F as default}; diff --git a/assets/api_mp_math_angle.md.7ZvAVHFT.lean.js b/assets/api_mp_math_angle.md.7ZvAVHFT.lean.js new file mode 100644 index 0000000..9273f75 --- /dev/null +++ b/assets/api_mp_math_angle.md.7ZvAVHFT.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const c=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"api/mp_math/angle.md","filePath":"api/mp_math/angle.md"}'),e={name:"api/mp_math/angle.md"},n=l("",93),t=[n];function h(p,k,r,d,o,y){return a(),i("div",null,t)}const F=s(e,[["render",h]]);export{c as __pageData,F as default}; diff --git a/assets/api_mp_math_angle.md.9eUTSIe4.js b/assets/api_mp_math_angle.md.9eUTSIe4.js deleted file mode 100644 index 94733bd..0000000 --- a/assets/api_mp_math_angle.md.9eUTSIe4.js +++ /dev/null @@ -1,102 +0,0 @@ -import{_ as s,c as a,o as i,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp\\\\nmath.angle","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.angle","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/angle.md","filePath":"api/mp_math/angle.md"}'),e={name:"api/mp_math/angle.md"},t=n(`

class AnyAngle

def __init__(self, value: float, is_radian: bool) -> None

 任意角度。

Args:

value: 角度或弧度值
-
-is_radian: 是否为弧度,默认为否
-
源代码
python
def __init__(self, value: float, is_radian: bool=False):
-    """
-        任意角度。
-        Args:
-            value: 角度或弧度值
-            is_radian: 是否为弧度,默认为否
-        """
-    if is_radian:
-        self.radian = value
-    else:
-        self.radian = value * PI / 180

@property

def complementary(self: Any) -> 'AnyAngle'

 余角:两角的和为90°。

Returns:

余角
-
源代码
python
@property
-def complementary(self) -> 'AnyAngle':
-    """
-        余角:两角的和为90°。
-        Returns:
-            余角
-        """
-    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

def supplementary(self: Any) -> 'AnyAngle'

 补角:两角的和为180°。

Returns:

补角
-
源代码
python
@property
-def supplementary(self) -> 'AnyAngle':
-    """
-        补角:两角的和为180°。
-        Returns:
-            补角
-        """
-    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

def degree(self: Any) -> float

 角度。

Returns:

弧度
-
源代码
python
@property
-def degree(self) -> float:
-    """
-        角度。
-        Returns:
-            弧度
-        """
-    return self.radian * 180 / PI

@property

def minimum_positive(self: Any) -> 'AnyAngle'

 最小正角。

Returns:

最小正角度
-
源代码
python
@property
-def minimum_positive(self) -> 'AnyAngle':
-    """
-        最小正角。
-        Returns:
-            最小正角度
-        """
-    return AnyAngle(self.radian % (2 * PI))

@property

def maximum_negative(self: Any) -> 'AnyAngle'

 最大负角。

Returns:

最大负角度
-
源代码
python
@property
-def maximum_negative(self) -> 'AnyAngle':
-    """
-        最大负角。
-        Returns:
-            最大负角度
-        """
-    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

def sin(self: Any) -> float

 正弦值。

Returns:

正弦值
-
源代码
python
@property
-def sin(self) -> float:
-    """
-        正弦值。
-        Returns:
-            正弦值
-        """
-    return math.sin(self.radian)

@property

def cos(self: Any) -> float

 余弦值。

Returns:

余弦值
-
源代码
python
@property
-def cos(self) -> float:
-    """
-        余弦值。
-        Returns:
-            余弦值
-        """
-    return math.cos(self.radian)

@property

def tan(self: Any) -> float

 正切值。

Returns:

正切值
-
源代码
python
@property
-def tan(self) -> float:
-    """
-        正切值。
-        Returns:
-            正切值
-        """
-    return math.tan(self.radian)

@property

def cot(self: Any) -> float

 余切值。

Returns:

余切值
-
源代码
python
@property
-def cot(self) -> float:
-    """
-        余切值。
-        Returns:
-            余切值
-        """
-    return 1 / math.tan(self.radian)

@property

def sec(self: Any) -> float

 正割值。

Returns:

正割值
-
源代码
python
@property
-def sec(self) -> float:
-    """
-        正割值。
-        Returns:
-            正割值
-        """
-    return 1 / math.cos(self.radian)

@property

def csc(self: Any) -> float

 余割值。

Returns:

余割值
-
源代码
python
@property
-def csc(self) -> float:
-    """
-        余割值。
-        Returns:
-            余割值
-        """
-    return 1 / math.sin(self.radian)
`,72),p=[t];function l(h,k,r,d,o,y){return i(),a("div",null,p)}const c=s(e,[["render",l]]);export{F as __pageData,c as default}; diff --git a/assets/api_mp_math_angle.md.9eUTSIe4.lean.js b/assets/api_mp_math_angle.md.9eUTSIe4.lean.js deleted file mode 100644 index a668d4f..0000000 --- a/assets/api_mp_math_angle.md.9eUTSIe4.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as a,o as i,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp\\\\nmath.angle","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.angle","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/angle.md","filePath":"api/mp_math/angle.md"}'),e={name:"api/mp_math/angle.md"},t=n("",72),p=[t];function l(h,k,r,d,o,y){return i(),a("div",null,p)}const c=s(e,[["render",l]]);export{F as __pageData,c as default}; diff --git a/assets/api_mp_math_const.md.Bc1LxtcU.js b/assets/api_mp_math_const.md.Bc1LxtcU.js new file mode 100644 index 0000000..74807f8 --- /dev/null +++ b/assets/api_mp_math_const.md.Bc1LxtcU.js @@ -0,0 +1 @@ +import{_ as a,c as e,o as t,a2 as r}from"./chunks/framework.BV61Qrc0.js";const v=JSON.parse('{"title":"mbcp.mp_math.const","description":"","frontmatter":{"title":"mbcp.mp_math.const"},"headers":[],"relativePath":"api/mp_math/const.md","filePath":"api/mp_math/const.md"}'),o={name:"api/mp_math/const.md"},n=r('

var PI = math.pi

var E = math.e

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

var GAMMA = 0.5772156649015329

var EPSILON = 0.0001

var APPROX = 0.001

',6),s=[n];function m(h,c,i,d,l,_){return t(),e("div",null,s)}const P=a(o,[["render",m]]);export{v as __pageData,P as default}; diff --git a/assets/api_mp_math_const.md.Bc1LxtcU.lean.js b/assets/api_mp_math_const.md.Bc1LxtcU.lean.js new file mode 100644 index 0000000..c5d9a74 --- /dev/null +++ b/assets/api_mp_math_const.md.Bc1LxtcU.lean.js @@ -0,0 +1 @@ +import{_ as a,c as e,o as t,a2 as r}from"./chunks/framework.BV61Qrc0.js";const v=JSON.parse('{"title":"mbcp.mp_math.const","description":"","frontmatter":{"title":"mbcp.mp_math.const"},"headers":[],"relativePath":"api/mp_math/const.md","filePath":"api/mp_math/const.md"}'),o={name:"api/mp_math/const.md"},n=r("",6),s=[n];function m(h,c,i,d,l,_){return t(),e("div",null,s)}const P=a(o,[["render",m]]);export{v as __pageData,P as default}; diff --git a/assets/api_mp_math_const.md.Bhz27OPg.js b/assets/api_mp_math_const.md.Bhz27OPg.js deleted file mode 100644 index 3a2275d..0000000 --- a/assets/api_mp_math_const.md.Bhz27OPg.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as a,c as e,o as t,a2 as r}from"./chunks/framework.BV61Qrc0.js";const v=JSON.parse('{"title":"mbcp.mp\\\\nmath.const","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.const","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/const.md","filePath":"api/mp_math/const.md"}'),o={name:"api/mp_math/const.md"},n=r('

var PI = math.pi

var E = math.e

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

var GAMMA = 0.5772156649015329

var EPSILON = 0.0001

var APPROX = 0.001

',6),s=[n];function m(c,h,i,d,l,p){return t(),e("div",null,s)}const P=a(o,[["render",m]]);export{v as __pageData,P as default}; diff --git a/assets/api_mp_math_const.md.Bhz27OPg.lean.js b/assets/api_mp_math_const.md.Bhz27OPg.lean.js deleted file mode 100644 index 11fcd53..0000000 --- a/assets/api_mp_math_const.md.Bhz27OPg.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as a,c as e,o as t,a2 as r}from"./chunks/framework.BV61Qrc0.js";const v=JSON.parse('{"title":"mbcp.mp\\\\nmath.const","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.const","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/const.md","filePath":"api/mp_math/const.md"}'),o={name:"api/mp_math/const.md"},n=r("",6),s=[n];function m(c,h,i,d,l,p){return t(),e("div",null,s)}const P=a(o,[["render",m]]);export{v as __pageData,P as default}; diff --git a/assets/api_mp_math_equation.md.DcgE8elZ.js b/assets/api_mp_math_equation.md.DcgE8elZ.js new file mode 100644 index 0000000..7e8e7cb --- /dev/null +++ b/assets/api_mp_math_equation.md.DcgE8elZ.js @@ -0,0 +1,63 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"api/mp_math/equation.md","filePath":"api/mp_math/equation.md"}'),l={name:"api/mp_math/equation.md"},t=n(`

var result_func = get_partial_derivative_func(result_func, v, epsilon)

def get_partial_derivative_func(func: MultiVarsFunc = EPSILON)

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

参数:

func: 函数

var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

epsilon: 偏移量

源码
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+    """
+    求N元函数一阶偏导函数。这玩意不太稳定,慎用。
+    Args:
+        func: 函数
+        var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
+        epsilon: 偏移量
+    Returns:
+        偏导函数
+    Raises:
+        ValueError: 无效变量类型
+    """
+    if isinstance(var, int):
+
+        def partial_derivative_func(*args: Var) -> Var:
+            args_list_plus = list(args)
+            args_list_plus[var] += epsilon
+            args_list_minus = list(args)
+            args_list_minus[var] -= epsilon
+            return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)
+        return partial_derivative_func
+    elif isinstance(var, tuple):
+
+        def high_order_partial_derivative_func(*args: Var) -> Var:
+            result_func = func
+            for v in var:
+                result_func = get_partial_derivative_func(result_func, v, epsilon)
+            return result_func(*args)
+        return high_order_partial_derivative_func
+    else:
+        raise ValueError('Invalid var type')

def partial_derivative_func()

源码
python
def partial_derivative_func(*args: Var) -> Var:
+    args_list_plus = list(args)
+    args_list_plus[var] += epsilon
+    args_list_minus = list(args)
+    args_list_minus[var] -= epsilon
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

def high_order_partial_derivative_func()

源码
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    result_func = func
+    for v in var:
+        result_func = get_partial_derivative_func(result_func, v, epsilon)
+    return result_func(*args)

class CurveEquation

  • def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

参数:

x_func: x函数

y_func: y函数

z_func: z函数

源码
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    """
+        曲线方程。
+        Args:
+            x_func: x函数
+            y_func: y函数
+            z_func: z函数
+        """
+    self.x_func = x_func
+    self.y_func = y_func
+    self.z_func = z_func
  • def __call__(self)

计算曲线上的点。

参数:

*t:

参数:

源码
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    """
+        计算曲线上的点。
+        Args:
+            *t:
+                参数
+        Returns:
+
+        """
+    if len(t) == 1:
+        return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
+    else:
+        return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
源码
python
def __str__(self):
+    return 'CurveEquation()'
`,30),h=[t];function p(e,k,r,d,E,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; diff --git a/assets/api_mp_math_equation.md.DcgE8elZ.lean.js b/assets/api_mp_math_equation.md.DcgE8elZ.lean.js new file mode 100644 index 0000000..1da9d96 --- /dev/null +++ b/assets/api_mp_math_equation.md.DcgE8elZ.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"api/mp_math/equation.md","filePath":"api/mp_math/equation.md"}'),l={name:"api/mp_math/equation.md"},t=n("",30),h=[t];function p(e,k,r,d,E,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; diff --git a/assets/api_mp_math_equation.md.xiyFVY1c.lean.js b/assets/api_mp_math_equation.md.xiyFVY1c.lean.js deleted file mode 100644 index 3b86eb7..0000000 --- a/assets/api_mp_math_equation.md.xiyFVY1c.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const u=JSON.parse('{"title":"mbcp.mp\\\\nmath.equation","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.equation","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/equation.md","filePath":"api/mp_math/equation.md"}'),t={name:"api/mp_math/equation.md"},l=n("",24),e=[l];function h(p,k,r,d,E,g){return a(),i("div",null,e)}const o=s(t,[["render",h]]);export{u as __pageData,o as default}; diff --git a/assets/api_mp_math_index.md.4P0hk6gb.js b/assets/api_mp_math_index.md.4P0hk6gb.js new file mode 100644 index 0000000..b374540 --- /dev/null +++ b/assets/api_mp_math_index.md.4P0hk6gb.js @@ -0,0 +1 @@ +import{_ as t,c as e,o as a}from"./chunks/framework.BV61Qrc0.js";const d=JSON.parse('{"title":"mbcp.mp_math","description":"","frontmatter":{"title":"mbcp.mp_math"},"headers":[],"relativePath":"api/mp_math/index.md","filePath":"api/mp_math/index.md"}'),m={name:"api/mp_math/index.md"};function p(n,i,r,c,o,s){return a(),e("div")}const h=t(m,[["render",p]]);export{d as __pageData,h as default}; diff --git a/assets/api_mp_math_index.md.4P0hk6gb.lean.js b/assets/api_mp_math_index.md.4P0hk6gb.lean.js new file mode 100644 index 0000000..b374540 --- /dev/null +++ b/assets/api_mp_math_index.md.4P0hk6gb.lean.js @@ -0,0 +1 @@ +import{_ as t,c as e,o as a}from"./chunks/framework.BV61Qrc0.js";const d=JSON.parse('{"title":"mbcp.mp_math","description":"","frontmatter":{"title":"mbcp.mp_math"},"headers":[],"relativePath":"api/mp_math/index.md","filePath":"api/mp_math/index.md"}'),m={name:"api/mp_math/index.md"};function p(n,i,r,c,o,s){return a(),e("div")}const h=t(m,[["render",p]]);export{d as __pageData,h as default}; diff --git a/assets/api_mp_math_index.md.DTIfeUA1.js b/assets/api_mp_math_index.md.DTIfeUA1.js deleted file mode 100644 index 2362a78..0000000 --- a/assets/api_mp_math_index.md.DTIfeUA1.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as t,c as e,o as n}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp.mp\\\\nmath.\\\\n\\\\ninit\\\\n\\\\n","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.\\\\n\\\\ninit\\\\n\\\\n","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/index.md","filePath":"api/mp_math/index.md"}'),a={name:"api/mp_math/index.md"};function i(p,o,m,r,c,d){return n(),e("div")}const h=t(a,[["render",i]]);export{_ as __pageData,h as default}; diff --git a/assets/api_mp_math_index.md.DTIfeUA1.lean.js b/assets/api_mp_math_index.md.DTIfeUA1.lean.js deleted file mode 100644 index 2362a78..0000000 --- a/assets/api_mp_math_index.md.DTIfeUA1.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as t,c as e,o as n}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp.mp\\\\nmath.\\\\n\\\\ninit\\\\n\\\\n","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.\\\\n\\\\ninit\\\\n\\\\n","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/index.md","filePath":"api/mp_math/index.md"}'),a={name:"api/mp_math/index.md"};function i(p,o,m,r,c,d){return n(),e("div")}const h=t(a,[["render",i]]);export{_ as __pageData,h as default}; diff --git a/assets/api_mp_math_line.md.BybnyRUL.js b/assets/api_mp_math_line.md.BybnyRUL.js deleted file mode 100644 index c0b376e..0000000 --- a/assets/api_mp_math_line.md.BybnyRUL.js +++ /dev/null @@ -1,193 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp\\\\nmath.line","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.line","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/line.md","filePath":"api/mp_math/line.md"}'),e={name:"api/mp_math/line.md"},l=n(`

class Line3

def __init__(self, point: 'Point3', direction: 'Vector3') -> None

 三维空间中的直线。由一个点和一个方向向量确定。

Args:

point: 直线上的一点
-
-direction: 直线的方向向量
-
源代码
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
-    """
-        三维空间中的直线。由一个点和一个方向向量确定。
-        Args:
-            point: 直线上的一点
-            direction: 直线的方向向量
-        """
-    self.point = point
-    self.direction = direction

def approx(self, other: 'Line3', epsilon: float) -> bool

 判断两条直线是否近似相等。

Args:

other: 另一条直线
-
-epsilon: 误差
-

Returns:

是否近似相等
-
源代码
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
-    """
-        判断两条直线是否近似相等。
-        Args:
-            other: 另一条直线
-            epsilon: 误差
-        Returns:
-            是否近似相等
-        """
-    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

def cal_angle(self, other: 'Line3') -> 'AnyAngle'

 计算直线和直线之间的夹角。

Args:

other: 另一条直线
-

Returns:

夹角弧度
-

Raises:

TypeError: 不支持的类型
-
源代码
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
-    """
-        计算直线和直线之间的夹角。
-        Args:
-            other: 另一条直线
-        Returns:
-            夹角弧度
-        Raises:
-            TypeError: 不支持的类型
-        """
-    return self.direction.cal_angle(other.direction)

def cal_distance(self, other: 'Line3 | Point3') -> float

 计算直线和直线或点之间的距离。

Args:

other: 平行直线或点
-

Returns:

距离
-

Raises:

TypeError: 不支持的类型
-
源代码
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
-    """
-        计算直线和直线或点之间的距离。
-        Args:
-            other: 平行直线或点
-
-        Returns:
-            距离
-        Raises:
-            TypeError: 不支持的类型
-        """
-    if isinstance(other, Line3):
-        if self == other:
-            return 0
-        elif self.is_parallel(other):
-            return (other.point - self.point).cross(self.direction).length / self.direction.length
-        elif not self.is_coplanar(other):
-            return abs(self.direction.cross(other.direction) @ (self.point - other.point) / self.direction.cross(other.direction).length)
-        else:
-            return 0
-    elif isinstance(other, Point3):
-        return (other - self.point).cross(self.direction).length / self.direction.length
-    else:
-        raise TypeError('Unsupported type.')

def cal_intersection(self, other: 'Line3') -> 'Point3'

 计算两条直线的交点。

Args:

other: 另一条直线
-

Returns:

交点
-

Raises:

ValueError: 直线平行
-
-ValueError: 直线不共面
-
源代码
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
-    """
-        计算两条直线的交点。
-        Args:
-            other: 另一条直线
-        Returns:
-            交点
-        Raises:
-            ValueError: 直线平行
-            ValueError: 直线不共面
-        """
-    if self.is_parallel(other):
-        raise ValueError('Lines are parallel and do not intersect.')
-    if not self.is_coplanar(other):
-        raise ValueError('Lines are not coplanar and do not intersect.')
-    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

def cal_perpendicular(self, point: 'Point3') -> 'Line3'

 计算直线经过指定点p的垂线。

Args:

point: 指定点
-

Returns:

垂线
-
源代码
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
-    """
-        计算直线经过指定点p的垂线。
-        Args:
-            point: 指定点
-        Returns:
-            垂线
-        """
-    return Line3(point, self.direction.cross(point - self.point))

def get_point(self, t: RealNumber) -> 'Point3'

 获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

Args:

t: 参数t
-

Returns:

点
-
源代码
python
def get_point(self, t: RealNumber) -> 'Point3':
-    """
-        获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
-        Args:
-            t: 参数t
-        Returns:
-
-        """
-    return self.point + t * self.direction

def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

 获取直线的参数方程。

Returns:

x(t), y(t), z(t)
-
源代码
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
-    """
-        获取直线的参数方程。
-        Returns:
-            x(t), y(t), z(t)
-        """
-    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

def is_approx_parallel(self, other: 'Line3', epsilon: float) -> bool

 判断两条直线是否近似平行。

Args:

other: 另一条直线
-
-epsilon: 误差
-

Returns:

是否近似平行
-
源代码
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
-    """
-        判断两条直线是否近似平行。
-        Args:
-            other: 另一条直线
-            epsilon: 误差
-        Returns:
-            是否近似平行
-        """
-    return self.direction.is_approx_parallel(other.direction, epsilon)

def is_parallel(self, other: 'Line3') -> bool

 判断两条直线是否平行。

Args:

other: 另一条直线
-

Returns:

是否平行
-
源代码
python
def is_parallel(self, other: 'Line3') -> bool:
-    """
-        判断两条直线是否平行。
-        Args:
-            other: 另一条直线
-        Returns:
-            是否平行
-        """
-    return self.direction.is_parallel(other.direction)

def is_collinear(self, other: 'Line3') -> bool

 判断两条直线是否共线。

Args:

other: 另一条直线
-

Returns:

是否共线
-
源代码
python
def is_collinear(self, other: 'Line3') -> bool:
-    """
-        判断两条直线是否共线。
-        Args:
-            other: 另一条直线
-        Returns:
-            是否共线
-        """
-    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

def is_point_on(self, point: 'Point3') -> bool

 判断点是否在直线上。

Args:

point: 点
-

Returns:

是否在直线上
-
源代码
python
def is_point_on(self, point: 'Point3') -> bool:
-    """
-        判断点是否在直线上。
-        Args:
-            point: 点
-        Returns:
-            是否在直线上
-        """
-    return (point - self.point).is_parallel(self.direction)

def is_coplanar(self, other: 'Line3') -> bool

 判断两条直线是否共面。

充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

Args:

other: 另一条直线
-

Returns:

是否共面
-
源代码
python
def is_coplanar(self, other: 'Line3') -> bool:
-    """
-        判断两条直线是否共面。
-        充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
-        Args:
-            other: 另一条直线
-        Returns:
-            是否共面
-        """
-    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

def simplify(self) -> None

 简化直线方程,等价相等。

自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

源代码
python
def simplify(self):
-    """
-        简化直线方程,等价相等。
-        自体简化,不返回值。
-
-        按照可行性一次对x y z 化 0 处理,并对向量单位化
-        """
-    self.direction.normalize()
-    if self.direction.x == 0:
-        self.point.x = 0
-    if self.direction.y == 0:
-        self.point.y = 0
-    if self.direction.z == 0:
-        self.point.z = 0

@classmethod

def from_two_points(cls: Any, p1: 'Point3', p2: 'Point3') -> 'Line3'

 工厂函数 由两点构造直线。

Args:

p1: 点1
-
-p2: 点2
-

Returns:

直线
-
源代码
python
@classmethod
-def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
-    """
-        工厂函数 由两点构造直线。
-        Args:
-            p1: 点1
-            p2: 点2
-        Returns:
-            直线
-        """
-    direction = p2 - p1
-    return cls(p1, direction)

var direction = p2 - p1

var s = 'Line3: '

`,110),p=[l];function t(h,k,r,d,o,g){return a(),i("div",null,p)}const c=s(e,[["render",t]]);export{E as __pageData,c as default}; diff --git a/assets/api_mp_math_line.md.BybnyRUL.lean.js b/assets/api_mp_math_line.md.BybnyRUL.lean.js deleted file mode 100644 index a5a9e33..0000000 --- a/assets/api_mp_math_line.md.BybnyRUL.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp\\\\nmath.line","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.line","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/line.md","filePath":"api/mp_math/line.md"}'),e={name:"api/mp_math/line.md"},l=n("",110),p=[l];function t(h,k,r,d,o,g){return a(),i("div",null,p)}const c=s(e,[["render",t]]);export{E as __pageData,c as default}; diff --git a/assets/api_mp_math_line.md.CPz5W_V9.js b/assets/api_mp_math_line.md.CPz5W_V9.js new file mode 100644 index 0000000..2338bdb --- /dev/null +++ b/assets/api_mp_math_line.md.CPz5W_V9.js @@ -0,0 +1,192 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"api/mp_math/line.md","filePath":"api/mp_math/line.md"}'),l={name:"api/mp_math/line.md"},h=n(`

class Line3

  • def __init__(self, point: 'Point3', direction: 'Vector3')

三维空间中的直线。由一个点和一个方向向量确定。

参数:

point: 直线上的一点

direction: 直线的方向向量

源码
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    """
+        三维空间中的直线。由一个点和一个方向向量确定。
+        Args:
+            point: 直线上的一点
+            direction: 直线的方向向量
+        """
+    self.point = point
+    self.direction = direction
  • def approx(self, other: 'Line3', epsilon: float = APPROX)

判断两条直线是否近似相等。

参数:

other: 另一条直线

epsilon: 误差

源码
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    """
+        判断两条直线是否近似相等。
+        Args:
+            other: 另一条直线
+            epsilon: 误差
+        Returns:
+            是否近似相等
+        """
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)
  • def cal_angle(self, other: 'Line3')

计算直线和直线之间的夹角。

参数:

other: 另一条直线

源码
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    """
+        计算直线和直线之间的夹角。
+        Args:
+            other: 另一条直线
+        Returns:
+            夹角弧度
+        Raises:
+            TypeError: 不支持的类型
+        """
+    return self.direction.cal_angle(other.direction)
  • def cal_distance(self, other: 'Line3 | Point3')

计算直线和直线或点之间的距离。

参数:

other: 平行直线或点

源码
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    """
+        计算直线和直线或点之间的距离。
+        Args:
+            other: 平行直线或点
+
+        Returns:
+            距离
+        Raises:
+            TypeError: 不支持的类型
+        """
+    if isinstance(other, Line3):
+        if self == other:
+            return 0
+        elif self.is_parallel(other):
+            return (other.point - self.point).cross(self.direction).length / self.direction.length
+        elif not self.is_coplanar(other):
+            return abs(self.direction.cross(other.direction) @ (self.point - other.point) / self.direction.cross(other.direction).length)
+        else:
+            return 0
+    elif isinstance(other, Point3):
+        return (other - self.point).cross(self.direction).length / self.direction.length
+    else:
+        raise TypeError('Unsupported type.')
  • def cal_intersection(self, other: 'Line3')

计算两条直线的交点。

参数:

other: 另一条直线

源码
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+    """
+        计算两条直线的交点。
+        Args:
+            other: 另一条直线
+        Returns:
+            交点
+        Raises:
+            ValueError: 直线平行
+            ValueError: 直线不共面
+        """
+    if self.is_parallel(other):
+        raise ValueError('Lines are parallel and do not intersect.')
+    if not self.is_coplanar(other):
+        raise ValueError('Lines are not coplanar and do not intersect.')
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction
  • def cal_perpendicular(self, point: 'Point3')

计算直线经过指定点p的垂线。

参数:

point: 指定点

源码
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    """
+        计算直线经过指定点p的垂线。
+        Args:
+            point: 指定点
+        Returns:
+            垂线
+        """
+    return Line3(point, self.direction.cross(point - self.point))
  • def get_point(self, t: RealNumber)

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

参数:

t: 参数t

源码
python
def get_point(self, t: RealNumber) -> 'Point3':
+    """
+        获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
+        Args:
+            t: 参数t
+        Returns:
+
+        """
+    return self.point + t * self.direction
  • def get_parametric_equations(self)

获取直线的参数方程。

返回:

x(t), y(t), z(t)

源码
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    """
+        获取直线的参数方程。
+        Returns:
+            x(t), y(t), z(t)
+        """
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)
  • def is_approx_parallel(self, other: 'Line3', epsilon: float = 1e-06)

判断两条直线是否近似平行。

参数:

other: 另一条直线

epsilon: 误差

源码
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    """
+        判断两条直线是否近似平行。
+        Args:
+            other: 另一条直线
+            epsilon: 误差
+        Returns:
+            是否近似平行
+        """
+    return self.direction.is_approx_parallel(other.direction, epsilon)
  • def is_parallel(self, other: 'Line3')

判断两条直线是否平行。

参数:

other: 另一条直线

源码
python
def is_parallel(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否平行。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否平行
+        """
+    return self.direction.is_parallel(other.direction)
  • def is_collinear(self, other: 'Line3')

判断两条直线是否共线。

参数:

other: 另一条直线

源码
python
def is_collinear(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否共线。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否共线
+        """
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)
  • def is_point_on(self, point: 'Point3')

判断点是否在直线上。

参数:

point: 点

源码
python
def is_point_on(self, point: 'Point3') -> bool:
+    """
+        判断点是否在直线上。
+        Args:
+            point: 点
+        Returns:
+            是否在直线上
+        """
+    return (point - self.point).is_parallel(self.direction)
  • def is_coplanar(self, other: 'Line3')

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

参数:

other: 另一条直线

源码
python
def is_coplanar(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否共面。
+        充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否共面
+        """
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0
  • def simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

源码
python
def simplify(self):
+    """
+        简化直线方程,等价相等。
+        自体简化,不返回值。
+
+        按照可行性一次对x y z 化 0 处理,并对向量单位化
+        """
+    self.direction.normalize()
+    if self.direction.x == 0:
+        self.point.x = 0
+    if self.direction.y == 0:
+        self.point.y = 0
+    if self.direction.z == 0:
+        self.point.z = 0
  • @classmethod

  • def from_two_points(cls, p1: 'Point3', p2: 'Point3')

工厂函数 由两点构造直线。

参数:

p1: 点1

p2: 点2

源码
python
@classmethod
+def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
+    """
+        工厂函数 由两点构造直线。
+        Args:
+            p1: 点1
+            p2: 点2
+        Returns:
+            直线
+        """
+    direction = p2 - p1
+    return cls(p1, direction)
  • def __and__(self, other: 'Line3')

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

参数:

other: 另一条直线

源码
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    """
+        计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
+        Args:
+            other: 另一条直线
+        Returns:
+            交点
+        """
+    if self.is_collinear(other):
+        return self
+    elif self.is_parallel(other) or not self.is_coplanar(other):
+        return None
+    else:
+        return self.cal_intersection(other)
  • def __eq__(self, other)

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

参数:

other:

源码
python
def __eq__(self, other) -> bool:
+    """
+        判断两条直线是否等价。
+
+        v1 // v2 ∧ (p1 - p2) // v1
+        Args:
+            other:
+
+        Returns:
+
+        """
+    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
源码
python
def __str__(self):
+    """
+        返回点向式(x-x0)
+        Returns:
+
+        """
+    s = 'Line3: '
+    if self.direction.x != 0:
+        s += f'(x{sign_format(-self.point.x)})/{self.direction.x}'
+    if self.direction.y != 0:
+        s += f' = (y{sign_format(-self.point.y)})/{self.direction.y}'
+    if self.direction.z != 0:
+        s += f' = (z{sign_format(-self.point.z)})/{self.direction.z}'
+    return s
源码
python
def __repr__(self):
+    return f'Line3({self.point}, {self.direction})'
`,111),t=[h];function p(e,k,r,d,o,F){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{g as __pageData,y as default}; diff --git a/assets/api_mp_math_line.md.CPz5W_V9.lean.js b/assets/api_mp_math_line.md.CPz5W_V9.lean.js new file mode 100644 index 0000000..6e645a3 --- /dev/null +++ b/assets/api_mp_math_line.md.CPz5W_V9.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"api/mp_math/line.md","filePath":"api/mp_math/line.md"}'),l={name:"api/mp_math/line.md"},h=n("",111),t=[h];function p(e,k,r,d,o,F){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{g as __pageData,y as default}; diff --git a/assets/api_mp_math_mp_math_typing.md.BHJOAxTl.js b/assets/api_mp_math_mp_math_typing.md.BHJOAxTl.js new file mode 100644 index 0000000..3a682b3 --- /dev/null +++ b/assets/api_mp_math_mp_math_typing.md.BHJOAxTl.js @@ -0,0 +1 @@ +import{_ as a,c as r,o as e,a2 as l}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.mp_math.mp_math_typing","description":"","frontmatter":{"title":"mbcp.mp_math.mp_math_typing"},"headers":[],"relativePath":"api/mp_math/mp_math_typing.md","filePath":"api/mp_math/mp_math_typing.md"}'),n={name:"api/mp_math/mp_math_typing.md"},i=l('

var RealNumber: TypeAlias = int | float

var Number: TypeAlias = RealNumber | complex

var SingleVar = TypeVar('SingleVar', bound=Number)

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

var Var: TypeAlias = SingleVar | ArrayVar

var OneSingleVarFunc: TypeAlias = Callable[[SingleVar], SingleVar]

var OneArrayFunc: TypeAlias = Callable[[ArrayVar], ArrayVar]

var OneVarFunc: TypeAlias = OneSingleVarFunc | OneArrayFunc

var TwoSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar], SingleVar]

var TwoArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar], ArrayVar]

var TwoVarsFunc: TypeAlias = TwoSingleVarsFunc | TwoArraysFunc

var ThreeSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar, SingleVar], SingleVar]

var ThreeArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar, ArrayVar], ArrayVar]

var ThreeVarsFunc: TypeAlias = ThreeSingleVarsFunc | ThreeArraysFunc

var MultiSingleVarsFunc: TypeAlias = Callable[..., SingleVar]

var MultiArraysFunc: TypeAlias = Callable[..., ArrayVar]

var MultiVarsFunc: TypeAlias = MultiSingleVarsFunc | MultiArraysFunc

',17),s=[i];function t(o,c,u,y,v,g){return e(),r("div",null,s)}const d=a(n,[["render",t]]);export{m as __pageData,d as default}; diff --git a/assets/api_mp_math_mp_math_typing.md.BHJOAxTl.lean.js b/assets/api_mp_math_mp_math_typing.md.BHJOAxTl.lean.js new file mode 100644 index 0000000..c657b53 --- /dev/null +++ b/assets/api_mp_math_mp_math_typing.md.BHJOAxTl.lean.js @@ -0,0 +1 @@ +import{_ as a,c as r,o as e,a2 as l}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.mp_math.mp_math_typing","description":"","frontmatter":{"title":"mbcp.mp_math.mp_math_typing"},"headers":[],"relativePath":"api/mp_math/mp_math_typing.md","filePath":"api/mp_math/mp_math_typing.md"}'),n={name:"api/mp_math/mp_math_typing.md"},i=l("",17),s=[i];function t(o,c,u,y,v,g){return e(),r("div",null,s)}const d=a(n,[["render",t]]);export{m as __pageData,d as default}; diff --git a/assets/api_mp_math_mp_math_typing.md.DXaadYgy.js b/assets/api_mp_math_mp_math_typing.md.DXaadYgy.js deleted file mode 100644 index 3796359..0000000 --- a/assets/api_mp_math_mp_math_typing.md.DXaadYgy.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as a,c as r,o as e,a2 as t}from"./chunks/framework.BV61Qrc0.js";const b=JSON.parse('{"title":"mbcp.mp\\\\nmath.mp\\\\nmath\\\\ntyping","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.mp\\\\nmath\\\\ntyping","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/mp_math_typing.md","filePath":"api/mp_math/mp_math_typing.md"}'),n={name:"api/mp_math/mp_math_typing.md"},o=t('

var SingleVar = TypeVar('SingleVar', bound=Number)

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

',2),m=[o];function p(i,_,d,s,c,l){return e(),r("div",null,m)}const u=a(n,[["render",p]]);export{b as __pageData,u as default}; diff --git a/assets/api_mp_math_mp_math_typing.md.DXaadYgy.lean.js b/assets/api_mp_math_mp_math_typing.md.DXaadYgy.lean.js deleted file mode 100644 index ff2adae..0000000 --- a/assets/api_mp_math_mp_math_typing.md.DXaadYgy.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as a,c as r,o as e,a2 as t}from"./chunks/framework.BV61Qrc0.js";const b=JSON.parse('{"title":"mbcp.mp\\\\nmath.mp\\\\nmath\\\\ntyping","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.mp\\\\nmath\\\\ntyping","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/mp_math_typing.md","filePath":"api/mp_math/mp_math_typing.md"}'),n={name:"api/mp_math/mp_math_typing.md"},o=t("",2),m=[o];function p(i,_,d,s,c,l){return e(),r("div",null,m)}const u=a(n,[["render",p]]);export{b as __pageData,u as default}; diff --git a/assets/api_mp_math_plane.md.B7Mh7SKE.js b/assets/api_mp_math_plane.md.B7Mh7SKE.js new file mode 100644 index 0000000..a583ba8 --- /dev/null +++ b/assets/api_mp_math_plane.md.B7Mh7SKE.js @@ -0,0 +1,208 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"api/mp_math/plane.md","filePath":"api/mp_math/plane.md"}'),l={name:"api/mp_math/plane.md"},h=n(`

var k = other.a / self.a

var A = np.array([[self.b, self.c], [other.b, other.c]])

var B = np.array([-self.d, -other.d])

var v2 = l2.get_point(1) - l1.point

var k = other.b / self.b

var A = np.array([[self.a, self.c], [other.a, other.c]])

var B = np.array([-self.d, -other.d])

var k = other.c / self.c

var A = np.array([[self.a, self.b], [other.a, other.b]])

var B = np.array([-self.d, -other.d])

class Plane3

  • def __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

参数:

a:

b:

c:

d:

源码
python
def __init__(self, a: float, b: float, c: float, d: float):
+    """
+        平面方程:ax + by + cz + d = 0
+        Args:
+            a:
+            b:
+            c:
+            d:
+        """
+    self.a = a
+    self.b = b
+    self.c = c
+    self.d = d
  • def approx(self, other: 'Plane3')

判断两个平面是否近似相等。

参数:

other:

源码
python
def approx(self, other: 'Plane3') -> bool:
+    """
+        判断两个平面是否近似相等。
+        Args:
+            other:
+
+        Returns:
+            是否近似相等
+        """
+    if self.a != 0:
+        k = other.a / self.a
+        return approx(other.b, self.b * k) and approx(other.c, self.c * k) and approx(other.d, self.d * k)
+    elif self.b != 0:
+        k = other.b / self.b
+        return approx(other.a, self.a * k) and approx(other.c, self.c * k) and approx(other.d, self.d * k)
+    elif self.c != 0:
+        k = other.c / self.c
+        return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
+    else:
+        return False
  • def cal_angle(self, other: 'Line3 | Plane3')

计算平面与平面之间的夹角。

参数:

other: 另一个平面

源码
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+    """
+        计算平面与平面之间的夹角。
+        Args:
+            other: 另一个平面
+        Returns:
+            夹角弧度
+        Raises:
+            TypeError: 不支持的类型
+        """
+    if isinstance(other, Line3):
+        return self.normal.cal_angle(other.direction).complementary
+    elif isinstance(other, Plane3):
+        return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
+    else:
+        raise TypeError(f'Unsupported type: {type(other)}')
  • def cal_distance(self, other: 'Plane3 | Point3')

计算平面与平面或点之间的距离。

参数:

other: 另一个平面或点

源码
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+    """
+        计算平面与平面或点之间的距离。
+        Args:
+            other: 另一个平面或点
+        Returns:
+            距离
+        Raises:
+            TypeError: 不支持的类型
+        """
+    if isinstance(other, Plane3):
+        return 0
+    elif isinstance(other, Point3):
+        return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
+    else:
+        raise TypeError(f'Unsupported type: {type(other)}')
  • def cal_intersection_line3(self, other: 'Plane3')

计算两平面的交线。该方法有问题,待修复。

参数:

other: 另一个平面

源码
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+    """
+        计算两平面的交线。该方法有问题,待修复。
+        Args:
+            other: 另一个平面
+        Returns:
+            交线
+        Raises:
+        """
+    if self.normal.is_parallel(other.normal):
+        raise ValueError('Planes are parallel and have no intersection.')
+    direction = self.normal.cross(other.normal)
+    x, y, z = (0, 0, 0)
+    if self.a != 0 and other.a != 0:
+        A = np.array([[self.b, self.c], [other.b, other.c]])
+        B = np.array([-self.d, -other.d])
+        y, z = np.linalg.solve(A, B)
+    elif self.b != 0 and other.b != 0:
+        A = np.array([[self.a, self.c], [other.a, other.c]])
+        B = np.array([-self.d, -other.d])
+        x, z = np.linalg.solve(A, B)
+    elif self.c != 0 and other.c != 0:
+        A = np.array([[self.a, self.b], [other.a, other.b]])
+        B = np.array([-self.d, -other.d])
+        x, y = np.linalg.solve(A, B)
+    return Line3(Point3(x, y, z), direction)
  • def cal_intersection_point3(self, other: 'Line3')

计算平面与直线的交点。

参数:

other: 不与平面平行或在平面上的直线

源码
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    """
+        计算平面与直线的交点。
+        Args:
+            other: 不与平面平行或在平面上的直线
+        Returns:
+            交点
+        Raises:
+            ValueError: 平面与直线平行或重合
+        """
+    if self.normal @ other.direction == 0:
+        raise ValueError('The plane and the line are parallel or coincident.')
+    x, y, z = other.get_parametric_equations()
+    t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
+    return Point3(x(t), y(t), z(t))
  • def cal_parallel_plane3(self, point: 'Point3')

计算平行于该平面且过指定点的平面。

参数:

point: 指定点

源码
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    """
+        计算平行于该平面且过指定点的平面。
+        Args:
+            point: 指定点
+        Returns:
+            平面
+        """
+    return Plane3.from_point_and_normal(point, self.normal)
  • def is_parallel(self, other: 'Plane3')

判断两个平面是否平行。

参数:

other: 另一个平面

源码
python
def is_parallel(self, other: 'Plane3') -> bool:
+    """
+        判断两个平面是否平行。
+        Args:
+            other: 另一个平面
+        Returns:
+            是否平行
+        """
+    return self.normal.is_parallel(other.normal)
  • @property

  • def normal(self)

平面的法向量。

返回:

法向量

源码
python
@property
+def normal(self) -> 'Vector3':
+    """
+        平面的法向量。
+        Returns:
+            法向量
+        """
+    return Vector3(self.a, self.b, self.c)
  • @classmethod

  • def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3')

工厂函数 由点和法向量构造平面(点法式构造)。

参数:

point: 平面上的一点

normal: 法向量

源码
python
@classmethod
+def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
+    """
+        工厂函数 由点和法向量构造平面(点法式构造)。
+        Args:
+            point: 平面上的一点
+            normal: 法向量
+        Returns:
+            平面
+        """
+    a, b, c = (normal.x, normal.y, normal.z)
+    d = -a * point.x - b * point.y - c * point.z
+    return cls(a, b, c, d)
  • @classmethod

  • def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3')

工厂函数 由三点构造平面。

参数:

p1: 点1

p2: 点2

p3: 点3

源码
python
@classmethod
+def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
+    """
+        工厂函数 由三点构造平面。
+        Args:
+            p1: 点1
+            p2: 点2
+            p3: 点3
+        Returns:
+            平面
+        """
+    v1 = p2 - p1
+    v2 = p3 - p1
+    normal = v1.cross(v2)
+    return cls.from_point_and_normal(p1, normal)
  • @classmethod

  • def from_two_lines(cls, l1: 'Line3', l2: 'Line3')

工厂函数 由两直线构造平面。

参数:

l1: 直线1

l2: 直线2

源码
python
@classmethod
+def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
+    """
+        工厂函数 由两直线构造平面。
+        Args:
+            l1: 直线1
+            l2: 直线2
+        Returns:
+            平面
+        """
+    v1 = l1.direction
+    v2 = l2.point - l1.point
+    if v2 == zero_vector3:
+        v2 = l2.get_point(1) - l1.point
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))
  • @classmethod

  • def from_point_and_line(cls, point: 'Point3', line: 'Line3')

工厂函数 由点和直线构造平面。

参数:

point: 面上一点

line: 面上直线,不包含点

源码
python
@classmethod
+def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
+    """
+        工厂函数 由点和直线构造平面。
+        Args:
+            point: 面上一点
+            line: 面上直线,不包含点
+        Returns:
+            平面
+        """
+    return cls.from_point_and_normal(point, line.direction)
源码
python
def __repr__(self):
+    return f'Plane3({self.a}, {self.b}, {self.c}, {self.d})'
源码
python
def __str__(self):
+    s = 'Plane3: '
+    if self.a != 0:
+        s += f'{sign(self.a, only_neg=True)}{abs(self.a)}x'
+    if self.b != 0:
+        s += f' {sign(self.b)} {abs(self.b)}y'
+    if self.c != 0:
+        s += f' {sign(self.c)} {abs(self.c)}z'
+    if self.d != 0:
+        s += f' {sign(self.d)} {abs(self.d)}'
+    return s + ' = 0'
  • @overload

  • def __and__(self, other: 'Line3')

源码
python
@overload
+def __and__(self, other: 'Line3') -> 'Point3 | None':
+    ...
  • @overload

  • def __and__(self, other: 'Plane3')

源码
python
@overload
+def __and__(self, other: 'Plane3') -> 'Line3 | None':
+    ...
  • def __and__(self, other)

取两平面的交集(人话:交线)

参数:

other:

源码
python
def __and__(self, other):
+    """
+        取两平面的交集(人话:交线)
+        Args:
+            other:
+        Returns:
+            不平行平面的交线,平面平行返回None
+        """
+    if isinstance(other, Plane3):
+        if self.normal.is_parallel(other.normal):
+            return None
+        return self.cal_intersection_line3(other)
+    elif isinstance(other, Line3):
+        if self.normal @ other.direction == 0:
+            return None
+        return self.cal_intersection_point3(other)
+    else:
+        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")
  • def __eq__(self, other)

源码
python
def __eq__(self, other) -> bool:
+    return self.approx(other)
  • def __rand__(self, other: 'Line3')

源码
python
def __rand__(self, other: 'Line3') -> 'Point3':
+    return self.cal_intersection_point3(other)
`,115),t=[h];function e(p,k,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",e]]);export{g as __pageData,y as default}; diff --git a/assets/api_mp_math_plane.md.B7Mh7SKE.lean.js b/assets/api_mp_math_plane.md.B7Mh7SKE.lean.js new file mode 100644 index 0000000..b35c9ea --- /dev/null +++ b/assets/api_mp_math_plane.md.B7Mh7SKE.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"api/mp_math/plane.md","filePath":"api/mp_math/plane.md"}'),l={name:"api/mp_math/plane.md"},h=n("",115),t=[h];function e(p,k,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",e]]);export{g as __pageData,y as default}; diff --git a/assets/api_mp_math_plane.md.Cdj0PlKB.lean.js b/assets/api_mp_math_plane.md.Cdj0PlKB.lean.js deleted file mode 100644 index ba3f172..0000000 --- a/assets/api_mp_math_plane.md.Cdj0PlKB.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp\\\\nmath.plane","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.plane","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/plane.md","filePath":"api/mp_math/plane.md"}'),l={name:"api/mp_math/plane.md"},h=n("",119),t=[h];function e(p,k,r,d,o,E){return a(),i("div",null,t)}const F=s(l,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/api_mp_math_point.md.BhIb1HeT.js b/assets/api_mp_math_point.md.BhIb1HeT.js new file mode 100644 index 0000000..b8a33c2 --- /dev/null +++ b/assets/api_mp_math_point.md.BhIb1HeT.js @@ -0,0 +1,41 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"api/mp_math/point.md","filePath":"api/mp_math/point.md"}'),t={name:"api/mp_math/point.md"},n=l(`

class Point3

  • def __init__(self, x: float, y: float, z: float)

笛卡尔坐标系中的点。

参数:

x: x 坐标

y: y 坐标

z: z 坐标

源码
python
def __init__(self, x: float, y: float, z: float):
+    """
+        笛卡尔坐标系中的点。
+        Args:
+            x: x 坐标
+            y: y 坐标
+            z: z 坐标
+        """
+    self.x = x
+    self.y = y
+    self.z = z
  • def approx(self, other: 'Point3', epsilon: float = APPROX)

判断两个点是否近似相等。

参数:

other:

epsilon:

源码
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个点是否近似相等。
+        Args:
+            other:
+            epsilon:
+
+        Returns:
+            是否近似相等
+        """
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
源码
python
def __str__(self):
+    return f'Point3({self.x}, {self.y}, {self.z})'
  • @overload

  • def __add__(self, other: 'Vector3')

源码
python
@overload
+def __add__(self, other: 'Vector3') -> 'Point3':
+    ...
  • @overload

  • def __add__(self, other: 'Point3')

源码
python
@overload
+def __add__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __add__(self, other)

P + V -> P P + P -> P

参数:

other:

源码
python
def __add__(self, other):
+    """
+        P + V -> P
+        P + P -> P
+        Args:
+            other:
+        Returns:
+        """
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
  • def __eq__(self, other)

判断两个点是否相等。

参数:

other:

源码
python
def __eq__(self, other):
+    """
+        判断两个点是否相等。
+        Args:
+            other:
+        Returns:
+        """
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)
`,34),h=[n];function e(p,k,d,r,o,E){return a(),i("div",null,h)}const g=s(t,[["render",e]]);export{y as __pageData,g as default}; diff --git a/assets/api_mp_math_point.md.BhIb1HeT.lean.js b/assets/api_mp_math_point.md.BhIb1HeT.lean.js new file mode 100644 index 0000000..797587b --- /dev/null +++ b/assets/api_mp_math_point.md.BhIb1HeT.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"api/mp_math/point.md","filePath":"api/mp_math/point.md"}'),t={name:"api/mp_math/point.md"},n=l("",34),h=[n];function e(p,k,d,r,o,E){return a(),i("div",null,h)}const g=s(t,[["render",e]]);export{y as __pageData,g as default}; diff --git a/assets/api_mp_math_point.md.D3f-vzVt.js b/assets/api_mp_math_point.md.D3f-vzVt.js deleted file mode 100644 index 5d4d56f..0000000 --- a/assets/api_mp_math_point.md.D3f-vzVt.js +++ /dev/null @@ -1,30 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp\\\\nmath.point","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.point","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/point.md","filePath":"api/mp_math/point.md"}'),t={name:"api/mp_math/point.md"},l=n(`

class Point3

def __init__(self, x: float, y: float, z: float) -> None

 笛卡尔坐标系中的点。

Args:

x: x 坐标
-
-y: y 坐标
-
-z: z 坐标
-
源代码
python
def __init__(self, x: float, y: float, z: float):
-    """
-        笛卡尔坐标系中的点。
-        Args:
-            x: x 坐标
-            y: y 坐标
-            z: z 坐标
-        """
-    self.x = x
-    self.y = y
-    self.z = z

def approx(self, other: 'Point3', epsilon: float) -> bool

 判断两个点是否近似相等。

Args:

other:
-
-epsilon:
-

Returns:

是否近似相等
-
源代码
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
-    """
-        判断两个点是否近似相等。
-        Args:
-            other:
-            epsilon:
-
-        Returns:
-            是否近似相等
-        """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
`,13),p=[l];function h(e,k,o,r,d,E){return a(),i("div",null,p)}const F=s(t,[["render",h]]);export{y as __pageData,F as default}; diff --git a/assets/api_mp_math_point.md.D3f-vzVt.lean.js b/assets/api_mp_math_point.md.D3f-vzVt.lean.js deleted file mode 100644 index af38377..0000000 --- a/assets/api_mp_math_point.md.D3f-vzVt.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp\\\\nmath.point","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.point","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/point.md","filePath":"api/mp_math/point.md"}'),t={name:"api/mp_math/point.md"},l=n("",13),p=[l];function h(e,k,o,r,d,E){return a(),i("div",null,p)}const F=s(t,[["render",h]]);export{y as __pageData,F as default}; diff --git a/assets/api_mp_math_segment.md.BpLgqrZ6.js b/assets/api_mp_math_segment.md.BpLgqrZ6.js new file mode 100644 index 0000000..e27ab68 --- /dev/null +++ b/assets/api_mp_math_segment.md.BpLgqrZ6.js @@ -0,0 +1,16 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"api/mp_math/segment.md","filePath":"api/mp_math/segment.md"}'),h={name:"api/mp_math/segment.md"},t=n(`

class Segment3

  • def __init__(self, p1: 'Point3', p2: 'Point3')

三维空间中的线段。 :param p1: :param p2:

源码
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+    """
+        三维空间中的线段。
+        :param p1:
+        :param p2:
+        """
+    self.p1 = p1
+    self.p2 = p2
+    '方向向量'
+    self.direction = self.p2 - self.p1
+    '长度'
+    self.length = self.direction.length
+    '中心点'
+    self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
源码
python
def __repr__(self):
+    return f'Segment3({self.p1}, {self.p2})'
源码
python
def __str__(self):
+    return f'Segment3({self.p1} -> {self.p2})'
`,9),l=[t];function e(p,k,r,d,E,g){return a(),i("div",null,l)}const o=s(h,[["render",e]]);export{y as __pageData,o as default}; diff --git a/assets/api_mp_math_segment.md.BpLgqrZ6.lean.js b/assets/api_mp_math_segment.md.BpLgqrZ6.lean.js new file mode 100644 index 0000000..5d33d09 --- /dev/null +++ b/assets/api_mp_math_segment.md.BpLgqrZ6.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"api/mp_math/segment.md","filePath":"api/mp_math/segment.md"}'),h={name:"api/mp_math/segment.md"},t=n("",9),l=[t];function e(p,k,r,d,E,g){return a(),i("div",null,l)}const o=s(h,[["render",e]]);export{y as __pageData,o as default}; diff --git a/assets/api_mp_math_segment.md.DIViBThe.js b/assets/api_mp_math_segment.md.DIViBThe.js deleted file mode 100644 index 92632ee..0000000 --- a/assets/api_mp_math_segment.md.DIViBThe.js +++ /dev/null @@ -1,14 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp\\\\nmath.segment","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.segment","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/segment.md","filePath":"api/mp_math/segment.md"}'),t={name:"api/mp_math/segment.md"},p=n(`

class Segment3

def __init__(self, p1: 'Point3', p2: 'Point3') -> None

 三维空间中的线段。

:param p1:

:param p2:

源代码
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
-    """
-        三维空间中的线段。
-        :param p1:
-        :param p2:
-        """
-    self.p1 = p1
-    self.p2 = p2
-    '方向向量'
-    self.direction = self.p2 - self.p1
-    '长度'
-    self.length = self.direction.length
-    '中心点'
-    self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
`,6),h=[p];function l(e,k,r,d,E,g){return a(),i("div",null,h)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/api_mp_math_segment.md.DIViBThe.lean.js b/assets/api_mp_math_segment.md.DIViBThe.lean.js deleted file mode 100644 index 79b1fab..0000000 --- a/assets/api_mp_math_segment.md.DIViBThe.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp\\\\nmath.segment","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.segment","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/segment.md","filePath":"api/mp_math/segment.md"}'),t={name:"api/mp_math/segment.md"},p=n("",6),h=[p];function l(e,k,r,d,E,g){return a(),i("div",null,h)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/api_mp_math_utils.md.BgmONBdf.js b/assets/api_mp_math_utils.md.BgmONBdf.js new file mode 100644 index 0000000..2fbb1f3 --- /dev/null +++ b/assets/api_mp_math_utils.md.BgmONBdf.js @@ -0,0 +1,65 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"api/mp_math/utils.md","filePath":"api/mp_math/utils.md"}'),l={name:"api/mp_math/utils.md"},h=n(`

def clamp()

区间截断函数。

参数:

x:

min_:

max_:

源码
python
def clamp(x: float, min_: float, max_: float) -> float:
+    """
+    区间截断函数。
+    Args:
+        x:
+        min_:
+        max_:
+
+    Returns:
+        限制后的值
+    """
+    return max(min(x, max_), min_)

def approx(x: float = 0.0, y: float = APPROX)

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

参数:

x:

y:

epsilon:

源码
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    """
+    判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
+    Args:
+        x:
+        y:
+        epsilon:
+
+    Returns:
+        是否近似相等
+    """
+    return abs(x - y) < epsilon

def sign(x: float = False)

获取数的符号。

参数:

x: 数

only_neg: 是否只返回负数的符号

源码
python
def sign(x: float, only_neg: bool=False) -> str:
+    """获取数的符号。
+    Args:
+        x: 数
+        only_neg: 是否只返回负数的符号
+    Returns:
+        符号 + - ""
+    """
+    if x > 0:
+        return '+' if not only_neg else ''
+    elif x < 0:
+        return '-'
+    else:
+        return ''

def sign_format(x: float = False)

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

参数:

x: 数

only_neg: 是否只返回负数的符号

源码
python
def sign_format(x: float, only_neg: bool=False) -> str:
+    """格式化符号数
+    -1 -> -1
+    1 -> +1
+    0 -> ""
+    Args:
+        x: 数
+        only_neg: 是否只返回负数的符号
+    Returns:
+        符号 + - ""
+    """
+    if x > 0:
+        return f'+{x}' if not only_neg else f'{x}'
+    elif x < 0:
+        return f'-{abs(x)}'
+    else:
+        return ''

class Approx

  • def __init__(self, value: RealNumber)

源码
python
def __init__(self, value: RealNumber):
+    self.value = value
  • def __eq__(self, other)

源码
python
def __eq__(self, other):
+    if isinstance(self.value, (float, int)):
+        if isinstance(other, (float, int)):
+            return abs(self.value - other) < APPROX
+        else:
+            self.raise_type_error(other)
+    elif isinstance(self.value, Vector3):
+        if isinstance(other, (Vector3, Point3, Plane3, Line3)):
+            return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
+        else:
+            self.raise_type_error(other)
  • def raise_type_error(self, other)

源码
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')
  • def __ne__(self, other)

源码
python
def __ne__(self, other):
+    return not self.__eq__(other)
`,35),t=[h];function p(e,k,r,d,F,E){return a(),i("div",null,t)}const o=s(l,[["render",p]]);export{y as __pageData,o as default}; diff --git a/assets/api_mp_math_utils.md.BgmONBdf.lean.js b/assets/api_mp_math_utils.md.BgmONBdf.lean.js new file mode 100644 index 0000000..3eb15bf --- /dev/null +++ b/assets/api_mp_math_utils.md.BgmONBdf.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"api/mp_math/utils.md","filePath":"api/mp_math/utils.md"}'),l={name:"api/mp_math/utils.md"},h=n("",35),t=[h];function p(e,k,r,d,F,E){return a(),i("div",null,t)}const o=s(l,[["render",p]]);export{y as __pageData,o as default}; diff --git a/assets/api_mp_math_utils.md.CDwq4icO.js b/assets/api_mp_math_utils.md.CDwq4icO.js deleted file mode 100644 index 8bd265a..0000000 --- a/assets/api_mp_math_utils.md.CDwq4icO.js +++ /dev/null @@ -1,74 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp\\\\nmath.utils","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.utils","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/utils.md","filePath":"api/mp_math/utils.md"}'),t={name:"api/mp_math/utils.md"},l=n(`

def clamp(x: float, min_: float, max_: float) -> float

区间截断函数。

Args:

x:
-
-min_:
-
-max_:
-

Returns:

限制后的值
-
源代码
python
def clamp(x: float, min_: float, max_: float) -> float:
-    """
-    区间截断函数。
-    Args:
-        x:
-        min_:
-        max_:
-
-    Returns:
-        限制后的值
-    """
-    return max(min(x, max_), min_)

def approx(x: float, y: float, epsilon: float) -> bool

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

Args:

x:
-
-y:
-
-epsilon:
-

Returns:

是否近似相等
-
源代码
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
-    """
-    判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
-    Args:
-        x:
-        y:
-        epsilon:
-
-    Returns:
-        是否近似相等
-    """
-    return abs(x - y) < epsilon

def sign(x: float, only_neg: bool) -> str

获取数的符号。

Args:

x: 数
-
-only_neg: 是否只返回负数的符号
-

Returns:

符号 + - ""
-
源代码
python
def sign(x: float, only_neg: bool=False) -> str:
-    """获取数的符号。
-    Args:
-        x: 数
-        only_neg: 是否只返回负数的符号
-    Returns:
-        符号 + - ""
-    """
-    if x > 0:
-        return '+' if not only_neg else ''
-    elif x < 0:
-        return '-'
-    else:
-        return ''

def sign_format(x: float, only_neg: bool) -> str

格式化符号数

-1 -> -1

1 -> +1

0 -> ""

Args:

x: 数
-
-only_neg: 是否只返回负数的符号
-

Returns:

符号 + - ""
-
源代码
python
def sign_format(x: float, only_neg: bool=False) -> str:
-    """格式化符号数
-    -1 -> -1
-    1 -> +1
-    0 -> ""
-    Args:
-        x: 数
-        only_neg: 是否只返回负数的符号
-    Returns:
-        符号 + - ""
-    """
-    if x > 0:
-        return f'+{x}' if not only_neg else f'{x}'
-    elif x < 0:
-        return f'-{abs(x)}'
-    else:
-        return ''

class Approx

用于近似比较对象

已实现对象 实数 Vector3 Point3 Plane3 Line3

def __init__(self, value: RealNumber) -> None

源代码
python
def __init__(self, value: RealNumber):
-    self.value = value

def raise_type_error(self, other: Any) -> None

源代码
python
def raise_type_error(self, other):
-    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')
`,40),p=[l];function h(e,k,r,d,o,g){return a(),i("div",null,p)}const E=s(t,[["render",h]]);export{y as __pageData,E as default}; diff --git a/assets/api_mp_math_utils.md.CDwq4icO.lean.js b/assets/api_mp_math_utils.md.CDwq4icO.lean.js deleted file mode 100644 index f89f56a..0000000 --- a/assets/api_mp_math_utils.md.CDwq4icO.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp\\\\nmath.utils","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.utils","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/utils.md","filePath":"api/mp_math/utils.md"}'),t={name:"api/mp_math/utils.md"},l=n("",40),p=[l];function h(e,k,r,d,o,g){return a(),i("div",null,p)}const E=s(t,[["render",h]]);export{y as __pageData,E as default}; diff --git a/assets/api_mp_math_vector.md.BgK1TmFY.js b/assets/api_mp_math_vector.md.BgK1TmFY.js deleted file mode 100644 index a82fc7a..0000000 --- a/assets/api_mp_math_vector.md.BgK1TmFY.js +++ /dev/null @@ -1,116 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp\\\\nmath.vector","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.vector","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/vector.md","filePath":"api/mp_math/vector.md"}'),e={name:"api/mp_math/vector.md"},t=n(`

class Vector3

def __init__(self, x: float, y: float, z: float) -> None

 3维向量

Args:

x: x轴分量
-
-y: y轴分量
-
-z: z轴分量
-
源代码
python
def __init__(self, x: float, y: float, z: float):
-    """
-        3维向量
-        Args:
-            x: x轴分量
-            y: y轴分量
-            z: z轴分量
-        """
-    self.x = x
-    self.y = y
-    self.z = z

def approx(self, other: 'Vector3', epsilon: float) -> bool

 判断两个向量是否近似相等。

Args:

other:
-
-epsilon:
-

Returns:

是否近似相等
-
源代码
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
-    """
-        判断两个向量是否近似相等。
-        Args:
-            other:
-            epsilon:
-
-        Returns:
-            是否近似相等
-        """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

def cal_angle(self, other: 'Vector3') -> 'AnyAngle'

 计算两个向量之间的夹角。

Args:

other: 另一个向量
-

Returns:

夹角
-
源代码
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
-    """
-        计算两个向量之间的夹角。
-        Args:
-            other: 另一个向量
-        Returns:
-            夹角
-        """
-    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

def cross(self, other: 'Vector3') -> 'Vector3'

 向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。

其余结果的模为平行四边形的面积。

返回如下行列式的结果:

i j k

x1 y1 z1

x2 y2 z2

Args:

other:
-

Returns:

行列式的结果
-
源代码
python
def cross(self, other: 'Vector3') -> 'Vector3':
-    """
-        向量积 叉乘:v1 cross v2 -> v3
-
-        叉乘为0,则两向量平行。
-        其余结果的模为平行四边形的面积。
-
-        返回如下行列式的结果:
-
-        \`\`i  j  k\`\`
-
-        \`\`x1 y1 z1\`\`
-
-        \`\`x2 y2 z2\`\`
-
-        Args:
-            other:
-        Returns:
-            行列式的结果
-        """
-    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

def is_approx_parallel(self, other: 'Vector3', epsilon: float) -> bool

 判断两个向量是否近似平行。

Args:

other: 另一个向量
-
-epsilon: 允许的误差
-

Returns:

是否近似平行
-
源代码
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
-    """
-        判断两个向量是否近似平行。
-        Args:
-            other: 另一个向量
-            epsilon: 允许的误差
-        Returns:
-            是否近似平行
-        """
-    return self.cross(other).length < epsilon

def is_parallel(self, other: 'Vector3') -> bool

 判断两个向量是否平行。

Args:

other: 另一个向量
-

Returns:

是否平行
-
源代码
python
def is_parallel(self, other: 'Vector3') -> bool:
-    """
-        判断两个向量是否平行。
-        Args:
-            other: 另一个向量
-        Returns:
-            是否平行
-        """
-    return self.cross(other).approx(zero_vector3)

def normalize(self) -> None

 将向量归一化。

自体归一化,不返回值。

源代码
python
def normalize(self):
-    """
-        将向量归一化。
-
-        自体归一化,不返回值。
-        """
-    length = self.length
-    self.x /= length
-    self.y /= length
-    self.z /= length

@property

def np_array(self: Any) -> 'np.ndarray'

 返回numpy数组

Returns:

源代码
python
@property
-def np_array(self) -> 'np.ndarray':
-    """
-        返回numpy数组
-        Returns:
-        """
-    return np.array([self.x, self.y, self.z])

@property

def length(self: Any) -> float

 向量的模。

Returns:

模
-
源代码
python
@property
-def length(self) -> float:
-    """
-        向量的模。
-        Returns:
-
-        """
-    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

def unit(self: Any) -> 'Vector3'

 获取该向量的单位向量。

Returns:

单位向量
-
源代码
python
@property
-def unit(self) -> 'Vector3':
-    """
-        获取该向量的单位向量。
-        Returns:
-            单位向量
-        """
-    return self / self.length

var zero_vector3 = Vector3(0, 0, 0)

var x_axis = Vector3(1, 0, 0)

var y_axis = Vector3(0, 1, 0)

var z_axis = Vector3(0, 0, 1)

var length = self.length

`,73),l=[t];function p(h,k,r,o,d,g){return a(),i("div",null,l)}const F=s(e,[["render",p]]);export{y as __pageData,F as default}; diff --git a/assets/api_mp_math_vector.md.BgK1TmFY.lean.js b/assets/api_mp_math_vector.md.BgK1TmFY.lean.js deleted file mode 100644 index c02c385..0000000 --- a/assets/api_mp_math_vector.md.BgK1TmFY.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp\\\\nmath.vector","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.vector","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/vector.md","filePath":"api/mp_math/vector.md"}'),e={name:"api/mp_math/vector.md"},t=n("",73),l=[t];function p(h,k,r,o,d,g){return a(),i("div",null,l)}const F=s(e,[["render",p]]);export{y as __pageData,F as default}; diff --git a/assets/api_mp_math_vector.md.BxisUL7s.js b/assets/api_mp_math_vector.md.BxisUL7s.js new file mode 100644 index 0000000..834f3bf --- /dev/null +++ b/assets/api_mp_math_vector.md.BxisUL7s.js @@ -0,0 +1,189 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"api/mp_math/vector.md","filePath":"api/mp_math/vector.md"}'),h={name:"api/mp_math/vector.md"},n=l(`

var zero_vector3 = Vector3(0, 0, 0)

var x_axis = Vector3(1, 0, 0)

var y_axis = Vector3(0, 1, 0)

var z_axis = Vector3(0, 0, 1)

class Vector3

  • def __init__(self, x: float, y: float, z: float)

3维向量

参数:

x: x轴分量

y: y轴分量

z: z轴分量

源码
python
def __init__(self, x: float, y: float, z: float):
+    """
+        3维向量
+        Args:
+            x: x轴分量
+            y: y轴分量
+            z: z轴分量
+        """
+    self.x = x
+    self.y = y
+    self.z = z
  • def approx(self, other: 'Vector3', epsilon: float = APPROX)

判断两个向量是否近似相等。

参数:

other:

epsilon:

源码
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个向量是否近似相等。
+        Args:
+            other:
+            epsilon:
+
+        Returns:
+            是否近似相等
+        """
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
  • def cal_angle(self, other: 'Vector3')

计算两个向量之间的夹角。

参数:

other: 另一个向量

源码
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    """
+        计算两个向量之间的夹角。
+        Args:
+            other: 另一个向量
+        Returns:
+            夹角
+        """
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)
  • def cross(self, other: 'Vector3')

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

源码
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    """
+        向量积 叉乘:v1 cross v2 -> v3
+
+        叉乘为0,则两向量平行。
+        其余结果的模为平行四边形的面积。
+
+        返回如下行列式的结果:
+
+        \`\`i  j  k\`\`
+
+        \`\`x1 y1 z1\`\`
+
+        \`\`x2 y2 z2\`\`
+
+        Args:
+            other:
+        Returns:
+            行列式的结果
+        """
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)
  • def is_approx_parallel(self, other: 'Vector3', epsilon: float = APPROX)

判断两个向量是否近似平行。

参数:

other: 另一个向量

epsilon: 允许的误差

源码
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个向量是否近似平行。
+        Args:
+            other: 另一个向量
+            epsilon: 允许的误差
+        Returns:
+            是否近似平行
+        """
+    return self.cross(other).length < epsilon
  • def is_parallel(self, other: 'Vector3')

判断两个向量是否平行。

参数:

other: 另一个向量

源码
python
def is_parallel(self, other: 'Vector3') -> bool:
+    """
+        判断两个向量是否平行。
+        Args:
+            other: 另一个向量
+        Returns:
+            是否平行
+        """
+    return self.cross(other).approx(zero_vector3)
  • def normalize(self)

将向量归一化。

自体归一化,不返回值。

源码
python
def normalize(self):
+    """
+        将向量归一化。
+
+        自体归一化,不返回值。
+        """
+    length = self.length
+    self.x /= length
+    self.y /= length
+    self.z /= length
源码
python
@property
+def np_array(self) -> 'np.ndarray':
+    """
+        返回numpy数组
+        Returns:
+        """
+    return np.array([self.x, self.y, self.z])
  • @property

  • def length(self)

向量的模。

返回:

源码
python
@property
+def length(self) -> float:
+    """
+        向量的模。
+        Returns:
+
+        """
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)
  • @property

  • def unit(self)

获取该向量的单位向量。

返回:

单位向量

源码
python
@property
+def unit(self) -> 'Vector3':
+    """
+        获取该向量的单位向量。
+        Returns:
+            单位向量
+        """
+    return self / self.length
源码
python
def __abs__(self):
+    return self.length
  • @overload

  • def __add__(self, other: 'Vector3')

源码
python
@overload
+def __add__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __add__(self, other: 'Point3')

源码
python
@overload
+def __add__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __add__(self, other)

V + P -> P

V + V -> V

参数:

other:

源码
python
def __add__(self, other):
+    """
+        V + P -> P
+
+        V + V -> V
+        Args:
+            other:
+        Returns:
+
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x + other.x, self.y + other.y, self.z + other.z)
+    elif isinstance(other, Point3):
+        return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
+    else:
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")
  • def __eq__(self, other)

判断两个向量是否相等。

参数:

other:

源码
python
def __eq__(self, other):
+    """
+        判断两个向量是否相等。
+        Args:
+            other:
+        Returns:
+            是否相等
+        """
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)
  • def __radd__(self, other: 'Point3')

P + V -> P

别去点那边实现了。 :param other: :return:

源码
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    """
+        P + V -> P
+
+        别去点那边实现了。
+        :param other:
+        :return:
+        """
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
  • @overload

  • def __sub__(self, other: 'Vector3')

源码
python
@overload
+def __sub__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __sub__(self, other: 'Point3')

源码
python
@overload
+def __sub__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __sub__(self, other)

V - P -> P

V - V -> V

参数:

other:

源码
python
def __sub__(self, other):
+    """
+        V - P -> P
+
+        V - V -> V
+        Args:
+            other:
+        Returns:
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
+    elif isinstance(other, Point3):
+        return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
+    else:
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')
  • def __rsub__(self, other: 'Point3')

P - V -> P

参数:

other:

源码
python
def __rsub__(self, other: 'Point3'):
+    """
+        P - V -> P
+        Args:
+            other:
+        Returns:
+
+        """
+    if isinstance(other, Point3):
+        return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
+    else:
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")
  • @overload

  • def __mul__(self, other: 'Vector3')

源码
python
@overload
+def __mul__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __mul__(self, other: RealNumber)

源码
python
@overload
+def __mul__(self, other: RealNumber) -> 'Vector3':
+    ...
  • def __mul__(self, other: 'int | float | Vector3')

数组运算 非点乘。点乘使用@,叉乘使用cross。

参数:

other:

源码
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    """
+        数组运算 非点乘。点乘使用@,叉乘使用cross。
+        Args:
+            other:
+
+        Returns:
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x * other.x, self.y * other.y, self.z * other.z)
+    elif isinstance(other, (float, int)):
+        return Vector3(self.x * other, self.y * other, self.z * other)
+    else:
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")
  • def __rmul__(self, other: 'RealNumber')

源码
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)
  • def __matmul__(self, other: 'Vector3')

点乘。

参数:

other:

源码
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+    """
+        点乘。
+        Args:
+            other:
+        Returns:
+        """
+    return self.x * other.x + self.y * other.y + self.z * other.z
  • def __truediv__(self, other: RealNumber)

源码
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)
源码
python
def __neg__(self):
+    return Vector3(-self.x, -self.y, -self.z)
源码
python
def __repr__(self):
+    return f'Vector3({self.x}, {self.y}, {self.z})'
源码
python
def __str__(self):
+    return f'Vector3({self.x}, {self.y}, {self.z})'
`,130),e=[n];function t(p,k,r,d,o,E){return a(),i("div",null,e)}const F=s(h,[["render",t]]);export{g as __pageData,F as default}; diff --git a/assets/api_mp_math_vector.md.BxisUL7s.lean.js b/assets/api_mp_math_vector.md.BxisUL7s.lean.js new file mode 100644 index 0000000..61c6995 --- /dev/null +++ b/assets/api_mp_math_vector.md.BxisUL7s.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"api/mp_math/vector.md","filePath":"api/mp_math/vector.md"}'),h={name:"api/mp_math/vector.md"},n=l("",130),e=[n];function t(p,k,r,d,o,E){return a(),i("div",null,e)}const F=s(h,[["render",t]]);export{g as __pageData,F as default}; diff --git a/assets/api_particle_index.md.BRCSxC3e.js b/assets/api_particle_index.md.BRCSxC3e.js new file mode 100644 index 0000000..aee1a91 --- /dev/null +++ b/assets/api_particle_index.md.BRCSxC3e.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.particle","description":"","frontmatter":{"title":"mbcp.particle"},"headers":[],"relativePath":"api/particle/index.md","filePath":"api/particle/index.md"}'),i={name:"api/particle/index.md"};function r(c,p,n,o,s,d){return a(),t("div")}const _=e(i,[["render",r]]);export{m as __pageData,_ as default}; diff --git a/assets/api_particle_index.md.BRCSxC3e.lean.js b/assets/api_particle_index.md.BRCSxC3e.lean.js new file mode 100644 index 0000000..aee1a91 --- /dev/null +++ b/assets/api_particle_index.md.BRCSxC3e.lean.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.particle","description":"","frontmatter":{"title":"mbcp.particle"},"headers":[],"relativePath":"api/particle/index.md","filePath":"api/particle/index.md"}'),i={name:"api/particle/index.md"};function r(c,p,n,o,s,d){return a(),t("div")}const _=e(i,[["render",r]]);export{m as __pageData,_ as default}; diff --git a/assets/api_particle_index.md.BqH-w2FR.js b/assets/api_particle_index.md.BqH-w2FR.js deleted file mode 100644 index 46b9b1e..0000000 --- a/assets/api_particle_index.md.BqH-w2FR.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.particle.\\\\n\\\\ninit\\\\n\\\\n","description":"","frontmatter":{"title":"mbcp.particle.\\\\n\\\\ninit\\\\n\\\\n","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/particle/index.md","filePath":"api/particle/index.md"}'),n={name:"api/particle/index.md"};function i(r,c,p,o,d,s){return a(),t("div")}const _=e(n,[["render",i]]);export{m as __pageData,_ as default}; diff --git a/assets/api_particle_index.md.BqH-w2FR.lean.js b/assets/api_particle_index.md.BqH-w2FR.lean.js deleted file mode 100644 index 46b9b1e..0000000 --- a/assets/api_particle_index.md.BqH-w2FR.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.particle.\\\\n\\\\ninit\\\\n\\\\n","description":"","frontmatter":{"title":"mbcp.particle.\\\\n\\\\ninit\\\\n\\\\n","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/particle/index.md","filePath":"api/particle/index.md"}'),n={name:"api/particle/index.md"};function i(r,c,p,o,d,s){return a(),t("div")}const _=e(n,[["render",i]]);export{m as __pageData,_ as default}; diff --git a/assets/api_presets_index.md.CvgR5vOS.js b/assets/api_presets_index.md.CvgR5vOS.js deleted file mode 100644 index 4baa138..0000000 --- a/assets/api_presets_index.md.CvgR5vOS.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,c as t,o as n}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp.presets.\\\\n\\\\ninit\\\\n\\\\n","description":"","frontmatter":{"title":"mbcp.presets.\\\\n\\\\ninit\\\\n\\\\n","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/presets/index.md","filePath":"api/presets/index.md"}'),r={name:"api/presets/index.md"};function s(a,i,p,o,c,d){return n(),t("div")}const l=e(r,[["render",s]]);export{_ as __pageData,l as default}; diff --git a/assets/api_presets_index.md.CvgR5vOS.lean.js b/assets/api_presets_index.md.CvgR5vOS.lean.js deleted file mode 100644 index 4baa138..0000000 --- a/assets/api_presets_index.md.CvgR5vOS.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,c as t,o as n}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp.presets.\\\\n\\\\ninit\\\\n\\\\n","description":"","frontmatter":{"title":"mbcp.presets.\\\\n\\\\ninit\\\\n\\\\n","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/presets/index.md","filePath":"api/presets/index.md"}'),r={name:"api/presets/index.md"};function s(a,i,p,o,c,d){return n(),t("div")}const l=e(r,[["render",s]]);export{_ as __pageData,l as default}; diff --git a/assets/api_presets_index.md.Dl6Ss91J.js b/assets/api_presets_index.md.Dl6Ss91J.js new file mode 100644 index 0000000..638232d --- /dev/null +++ b/assets/api_presets_index.md.Dl6Ss91J.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as s}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp.presets","description":"","frontmatter":{"title":"mbcp.presets"},"headers":[],"relativePath":"api/presets/index.md","filePath":"api/presets/index.md"}'),a={name:"api/presets/index.md"};function r(p,n,i,c,o,d){return s(),t("div")}const f=e(a,[["render",r]]);export{_ as __pageData,f as default}; diff --git a/assets/api_presets_index.md.Dl6Ss91J.lean.js b/assets/api_presets_index.md.Dl6Ss91J.lean.js new file mode 100644 index 0000000..638232d --- /dev/null +++ b/assets/api_presets_index.md.Dl6Ss91J.lean.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as s}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp.presets","description":"","frontmatter":{"title":"mbcp.presets"},"headers":[],"relativePath":"api/presets/index.md","filePath":"api/presets/index.md"}'),a={name:"api/presets/index.md"};function r(p,n,i,c,o,d){return s(),t("div")}const f=e(a,[["render",r]]);export{_ as __pageData,f as default}; diff --git a/assets/api_presets_model_index.md.D1iZ1qEr.js b/assets/api_presets_model_index.md.D1iZ1qEr.js deleted file mode 100644 index b06171a..0000000 --- a/assets/api_presets_model_index.md.D1iZ1qEr.js +++ /dev/null @@ -1,43 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model.\\\\n\\\\ninit\\\\n\\\\n","description":"","frontmatter":{"title":"mbcp.presets.model.\\\\n\\\\ninit\\\\n\\\\n","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/presets/model/index.md","filePath":"api/presets/model/index.md"}'),t={name:"api/presets/model/index.md"},h=n(`

def sphere(radius: float, density: float) -> None

生成球体上的点集。

Args:

radius:
-
-density:
-

Returns:

List[Point3]: 球体上的点集。
-
源代码
python
@staticmethod
-def sphere(radius: float, density: float):
-    """
-        生成球体上的点集。
-        Args:
-            radius:
-            density:
-        Returns:
-            List[Point3]: 球体上的点集。
-        """
-    area = 4 * np.pi * radius ** 2
-    num = int(area * density)
-    phi_list = np.arccos([clamp(-1 + (2.0 * _ - 1.0) / num, -1, 1) for _ in range(num)])
-    theta_list = np.sqrt(num * np.pi) * phi_list
-    x_array = radius * np.sin(phi_list) * np.cos(theta_list)
-    y_array = radius * np.sin(phi_list) * np.sin(theta_list)
-    z_array = radius * np.cos(phi_list)
-    return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]

class GeometricModels

@staticmethod

def sphere(radius: float, density: float) -> None

 生成球体上的点集。

Args:

radius:
-
-density:
-

Returns:

List[Point3]: 球体上的点集。
-
源代码
python
@staticmethod
-def sphere(radius: float, density: float):
-    """
-        生成球体上的点集。
-        Args:
-            radius:
-            density:
-        Returns:
-            List[Point3]: 球体上的点集。
-        """
-    area = 4 * np.pi * radius ** 2
-    num = int(area * density)
-    phi_list = np.arccos([clamp(-1 + (2.0 * _ - 1.0) / num, -1, 1) for _ in range(num)])
-    theta_list = np.sqrt(num * np.pi) * phi_list
-    x_array = radius * np.sin(phi_list) * np.cos(theta_list)
-    y_array = radius * np.sin(phi_list) * np.sin(theta_list)
-    z_array = radius * np.cos(phi_list)
-    return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]

var area = 4 * np.pi * radius ** 2

var num = int(area * density)

var phi_list = np.arccos([clamp(-1 + (2.0 * _ - 1.0) / num, -1, 1) for _ in range(num)])

var theta_list = np.sqrt(num * np.pi) * phi_list

var x_array = radius * np.sin(phi_list) * np.cos(theta_list)

var y_array = radius * np.sin(phi_list) * np.sin(theta_list)

var z_array = radius * np.cos(phi_list)

`,23),p=[h];function l(k,e,r,d,E,y){return a(),i("div",null,p)}const c=s(t,[["render",l]]);export{o as __pageData,c as default}; diff --git a/assets/api_presets_model_index.md.D1iZ1qEr.lean.js b/assets/api_presets_model_index.md.D1iZ1qEr.lean.js deleted file mode 100644 index 472d2ee..0000000 --- a/assets/api_presets_model_index.md.D1iZ1qEr.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model.\\\\n\\\\ninit\\\\n\\\\n","description":"","frontmatter":{"title":"mbcp.presets.model.\\\\n\\\\ninit\\\\n\\\\n","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/presets/model/index.md","filePath":"api/presets/model/index.md"}'),t={name:"api/presets/model/index.md"},h=n("",23),p=[h];function l(k,e,r,d,E,y){return a(),i("div",null,p)}const c=s(t,[["render",l]]);export{o as __pageData,c as default}; diff --git a/assets/api_presets_model_index.md.O3tM1JKS.js b/assets/api_presets_model_index.md.O3tM1JKS.js new file mode 100644 index 0000000..dbb802d --- /dev/null +++ b/assets/api_presets_model_index.md.O3tM1JKS.js @@ -0,0 +1,18 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"api/presets/model/index.md","filePath":"api/presets/model/index.md"}'),h={name:"api/presets/model/index.md"},t=n(`

class GeometricModels

  • @staticmethod

  • def sphere(radius: float, density: float)

生成球体上的点集。

参数:

radius:

density:

源码
python
@staticmethod
+def sphere(radius: float, density: float):
+    """
+        生成球体上的点集。
+        Args:
+            radius:
+            density:
+        Returns:
+            List[Point3]: 球体上的点集。
+        """
+    area = 4 * np.pi * radius ** 2
+    num = int(area * density)
+    phi_list = np.arccos([clamp(-1 + (2.0 * _ - 1.0) / num, -1, 1) for _ in range(num)])
+    theta_list = np.sqrt(num * np.pi) * phi_list
+    x_array = radius * np.sin(phi_list) * np.cos(theta_list)
+    y_array = radius * np.sin(phi_list) * np.sin(theta_list)
+    z_array = radius * np.cos(phi_list)
+    return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,8),l=[t];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(h,[["render",k]]);export{o as __pageData,F as default}; diff --git a/assets/api_presets_model_index.md.O3tM1JKS.lean.js b/assets/api_presets_model_index.md.O3tM1JKS.lean.js new file mode 100644 index 0000000..6d000b8 --- /dev/null +++ b/assets/api_presets_model_index.md.O3tM1JKS.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"api/presets/model/index.md","filePath":"api/presets/model/index.md"}'),h={name:"api/presets/model/index.md"},t=n("",8),l=[t];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(h,[["render",k]]);export{o as __pageData,F as default}; diff --git a/assets/en_api_index.md.Bgu-LD1B.js b/assets/en_api_index.md.Bgu-LD1B.js new file mode 100644 index 0000000..2792da6 --- /dev/null +++ b/assets/en_api_index.md.Bgu-LD1B.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp","description":"","frontmatter":{"title":"mbcp"},"headers":[],"relativePath":"en/api/index.md","filePath":"en/api/index.md"}'),n={name:"en/api/index.md"};function i(r,c,o,p,s,d){return a(),t("div")}const f=e(n,[["render",i]]);export{_ as __pageData,f as default}; diff --git a/assets/en_api_index.md.Bgu-LD1B.lean.js b/assets/en_api_index.md.Bgu-LD1B.lean.js new file mode 100644 index 0000000..2792da6 --- /dev/null +++ b/assets/en_api_index.md.Bgu-LD1B.lean.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp","description":"","frontmatter":{"title":"mbcp"},"headers":[],"relativePath":"en/api/index.md","filePath":"en/api/index.md"}'),n={name:"en/api/index.md"};function i(r,c,o,p,s,d){return a(),t("div")}const f=e(n,[["render",i]]);export{_ as __pageData,f as default}; diff --git a/assets/en_api_mp_math_angle.md.Cpkg14Nd.js b/assets/en_api_mp_math_angle.md.Cpkg14Nd.js new file mode 100644 index 0000000..877c4a6 --- /dev/null +++ b/assets/en_api_mp_math_angle.md.Cpkg14Nd.js @@ -0,0 +1,101 @@ +import{_ as s,c as i,o as a,a2 as e}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"en/api/mp_math/angle.md","filePath":"en/api/mp_math/angle.md"}'),l={name:"en/api/mp_math/angle.md"},n=e(`

class Angle

class AnyAngle

  • def __init__(self, value: float, is_radian: bool = False)

任意角度。

Args:

value: 角度或弧度值

is_radian: 是否为弧度,默认为否

Source code
python
def __init__(self, value: float, is_radian: bool=False):
+    """
+        任意角度。
+        Args:
+            value: 角度或弧度值
+            is_radian: 是否为弧度,默认为否
+        """
+    if is_radian:
+        self.radian = value
+    else:
+        self.radian = value * PI / 180
  • @property

  • def complementary(self)

余角:两角的和为90°。

Return:

余角

Source code
python
@property
+def complementary(self) -> 'AnyAngle':
+    """
+        余角:两角的和为90°。
+        Returns:
+            余角
+        """
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)
  • @property

  • def supplementary(self)

补角:两角的和为180°。

Return:

补角

Source code
python
@property
+def supplementary(self) -> 'AnyAngle':
+    """
+        补角:两角的和为180°。
+        Returns:
+            补角
+        """
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)
  • @property

  • def degree(self)

角度。

Return:

弧度

Source code
python
@property
+def degree(self) -> float:
+    """
+        角度。
+        Returns:
+            弧度
+        """
+    return self.radian * 180 / PI
  • @property

  • def minimum_positive(self)

最小正角。

Return:

最小正角度

Source code
python
@property
+def minimum_positive(self) -> 'AnyAngle':
+    """
+        最小正角。
+        Returns:
+            最小正角度
+        """
+    return AnyAngle(self.radian % (2 * PI))
  • @property

  • def maximum_negative(self)

最大负角。

Return:

最大负角度

Source code
python
@property
+def maximum_negative(self) -> 'AnyAngle':
+    """
+        最大负角。
+        Returns:
+            最大负角度
+        """
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)
  • @property

  • def sin(self)

正弦值。

Return:

正弦值

Source code
python
@property
+def sin(self) -> float:
+    """
+        正弦值。
+        Returns:
+            正弦值
+        """
+    return math.sin(self.radian)
  • @property

  • def cos(self)

余弦值。

Return:

余弦值

Source code
python
@property
+def cos(self) -> float:
+    """
+        余弦值。
+        Returns:
+            余弦值
+        """
+    return math.cos(self.radian)
  • @property

  • def tan(self)

正切值。

Return:

正切值

Source code
python
@property
+def tan(self) -> float:
+    """
+        正切值。
+        Returns:
+            正切值
+        """
+    return math.tan(self.radian)
  • @property

  • def cot(self)

余切值。

Return:

余切值

Source code
python
@property
+def cot(self) -> float:
+    """
+        余切值。
+        Returns:
+            余切值
+        """
+    return 1 / math.tan(self.radian)
  • @property

  • def sec(self)

正割值。

Return:

正割值

Source code
python
@property
+def sec(self) -> float:
+    """
+        正割值。
+        Returns:
+            正割值
+        """
+    return 1 / math.cos(self.radian)
  • @property

  • def csc(self)

余割值。

Return:

余割值

Source code
python
@property
+def csc(self) -> float:
+    """
+        余割值。
+        Returns:
+            余割值
+        """
+    return 1 / math.sin(self.radian)
  • def __add__(self, other: 'AnyAngle')

Source code
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)
  • def __eq__(self, other)

Source code
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)
  • def __sub__(self, other: 'AnyAngle')

Source code
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)
  • def __mul__(self, other: float)

Source code
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)
Source code
python
def __repr__(self):
+    return f'AnyAngle({self.radian}, is_radian=True)'
Source code
python
def __str__(self):
+    return f'AnyAngle({self.degree}° or {self.radian} rad)'
  • @overload

  • def __truediv__(self, other: float)

Source code
python
@overload
+def __truediv__(self, other: float) -> 'AnyAngle':
+    ...
  • @overload

  • def __truediv__(self, other: 'AnyAngle')

Source code
python
@overload
+def __truediv__(self, other: 'AnyAngle') -> float:
+    ...
  • def __truediv__(self, other)

Source code
python
def __truediv__(self, other):
+    if isinstance(other, AnyAngle):
+        return self.radian / other.radian
+    return AnyAngle(self.radian / other, is_radian=True)
`,93),t=[n];function h(p,k,r,d,o,y){return a(),i("div",null,t)}const F=s(l,[["render",h]]);export{g as __pageData,F as default}; diff --git a/assets/en_api_mp_math_angle.md.Cpkg14Nd.lean.js b/assets/en_api_mp_math_angle.md.Cpkg14Nd.lean.js new file mode 100644 index 0000000..f5c4657 --- /dev/null +++ b/assets/en_api_mp_math_angle.md.Cpkg14Nd.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as e}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"en/api/mp_math/angle.md","filePath":"en/api/mp_math/angle.md"}'),l={name:"en/api/mp_math/angle.md"},n=e("",93),t=[n];function h(p,k,r,d,o,y){return a(),i("div",null,t)}const F=s(l,[["render",h]]);export{g as __pageData,F as default}; diff --git a/assets/en_api_mp_math_const.md.DfcWuGeV.js b/assets/en_api_mp_math_const.md.DfcWuGeV.js new file mode 100644 index 0000000..b1cbd9e --- /dev/null +++ b/assets/en_api_mp_math_const.md.DfcWuGeV.js @@ -0,0 +1 @@ +import{_ as a,c as e,o as t,a2 as r}from"./chunks/framework.BV61Qrc0.js";const v=JSON.parse('{"title":"mbcp.mp_math.const","description":"","frontmatter":{"title":"mbcp.mp_math.const"},"headers":[],"relativePath":"en/api/mp_math/const.md","filePath":"en/api/mp_math/const.md"}'),o={name:"en/api/mp_math/const.md"},n=r('

var PI = math.pi

var E = math.e

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

var GAMMA = 0.5772156649015329

var EPSILON = 0.0001

var APPROX = 0.001

',6),s=[n];function m(h,c,i,d,l,_){return t(),e("div",null,s)}const P=a(o,[["render",m]]);export{v as __pageData,P as default}; diff --git a/assets/en_api_mp_math_const.md.DfcWuGeV.lean.js b/assets/en_api_mp_math_const.md.DfcWuGeV.lean.js new file mode 100644 index 0000000..10a095f --- /dev/null +++ b/assets/en_api_mp_math_const.md.DfcWuGeV.lean.js @@ -0,0 +1 @@ +import{_ as a,c as e,o as t,a2 as r}from"./chunks/framework.BV61Qrc0.js";const v=JSON.parse('{"title":"mbcp.mp_math.const","description":"","frontmatter":{"title":"mbcp.mp_math.const"},"headers":[],"relativePath":"en/api/mp_math/const.md","filePath":"en/api/mp_math/const.md"}'),o={name:"en/api/mp_math/const.md"},n=r("",6),s=[n];function m(h,c,i,d,l,_){return t(),e("div",null,s)}const P=a(o,[["render",m]]);export{v as __pageData,P as default}; diff --git a/assets/api_mp_math_equation.md.xiyFVY1c.js b/assets/en_api_mp_math_equation.md.BEubflOs.js similarity index 52% rename from assets/api_mp_math_equation.md.xiyFVY1c.js rename to assets/en_api_mp_math_equation.md.BEubflOs.js index ed33888..0b4ff44 100644 --- a/assets/api_mp_math_equation.md.xiyFVY1c.js +++ b/assets/en_api_mp_math_equation.md.BEubflOs.js @@ -1,11 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const u=JSON.parse('{"title":"mbcp.mp\\\\nmath.equation","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.equation","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/equation.md","filePath":"api/mp_math/equation.md"}'),t={name:"api/mp_math/equation.md"},l=n(`

def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number) -> MultiVarsFunc

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

Args:

func: 函数
-
-var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
-
-epsilon: 偏移量
-

Returns:

偏导函数
-

Raises:

ValueError: 无效变量类型
-
源代码
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"en/api/mp_math/equation.md","filePath":"en/api/mp_math/equation.md"}'),l={name:"en/api/mp_math/equation.md"},t=n(`

var result_func = get_partial_derivative_func(result_func, v, epsilon)

def get_partial_derivative_func(func: MultiVarsFunc = EPSILON)

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

Args:

func: 函数

var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

epsilon: 偏移量

Source code
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
     """
     求N元函数一阶偏导函数。这玩意不太稳定,慎用。
     Args:
@@ -35,22 +28,36 @@ epsilon: 偏移量
             return result_func(*args)
         return high_order_partial_derivative_func
     else:
-        raise ValueError('Invalid var type')

def partial_derivative_func() -> Var

源代码
python
def partial_derivative_func(*args: Var) -> Var:
+        raise ValueError('Invalid var type')

def partial_derivative_func()

Source code
python
def partial_derivative_func(*args: Var) -> Var:
     args_list_plus = list(args)
     args_list_plus[var] += epsilon
     args_list_minus = list(args)
     args_list_minus[var] -= epsilon
-    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

def high_order_partial_derivative_func() -> Var

源代码
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

def high_order_partial_derivative_func()

Source code
python
def high_order_partial_derivative_func(*args: Var) -> Var:
     result_func = func
     for v in var:
         result_func = get_partial_derivative_func(result_func, v, epsilon)
-    return result_func(*args)

class CurveEquation

def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc) -> None

 曲线方程。

:param x_func:

:param y_func:

:param z_func:

源代码
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    return result_func(*args)

class CurveEquation

  • def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

Args:

x_func: x函数

y_func: y函数

z_func: z函数

Source code
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
     """
         曲线方程。
-        :param x_func:
-        :param y_func:
-        :param z_func:
+        Args:
+            x_func: x函数
+            y_func: y函数
+            z_func: z函数
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

var args_list_plus = list(args)

var args_list_minus = list(args)

var result_func = func

var result_func = get_partial_derivative_func(result_func, v, epsilon)

`,24),e=[l];function h(p,k,r,d,E,g){return a(),i("div",null,e)}const o=s(t,[["render",h]]);export{u as __pageData,o as default}; + self.z_func = z_func
  • def __call__(self)

计算曲线上的点。

Args:

*t:

参数:

Source code
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    """
+        计算曲线上的点。
+        Args:
+            *t:
+                参数
+        Returns:
+
+        """
+    if len(t) == 1:
+        return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
+    else:
+        return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
Source code
python
def __str__(self):
+    return 'CurveEquation()'
`,30),h=[t];function p(e,k,r,d,E,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{u as __pageData,y as default}; diff --git a/assets/en_api_mp_math_equation.md.BEubflOs.lean.js b/assets/en_api_mp_math_equation.md.BEubflOs.lean.js new file mode 100644 index 0000000..89524f3 --- /dev/null +++ b/assets/en_api_mp_math_equation.md.BEubflOs.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"en/api/mp_math/equation.md","filePath":"en/api/mp_math/equation.md"}'),l={name:"en/api/mp_math/equation.md"},t=n("",30),h=[t];function p(e,k,r,d,E,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{u as __pageData,y as default}; diff --git a/assets/en_api_mp_math_index.md.DrjDUYBY.js b/assets/en_api_mp_math_index.md.DrjDUYBY.js new file mode 100644 index 0000000..42ab20b --- /dev/null +++ b/assets/en_api_mp_math_index.md.DrjDUYBY.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const d=JSON.parse('{"title":"mbcp.mp_math","description":"","frontmatter":{"title":"mbcp.mp_math"},"headers":[],"relativePath":"en/api/mp_math/index.md","filePath":"en/api/mp_math/index.md"}'),n={name:"en/api/mp_math/index.md"};function m(p,i,r,c,o,s){return a(),t("div")}const h=e(n,[["render",m]]);export{d as __pageData,h as default}; diff --git a/assets/en_api_mp_math_index.md.DrjDUYBY.lean.js b/assets/en_api_mp_math_index.md.DrjDUYBY.lean.js new file mode 100644 index 0000000..42ab20b --- /dev/null +++ b/assets/en_api_mp_math_index.md.DrjDUYBY.lean.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const d=JSON.parse('{"title":"mbcp.mp_math","description":"","frontmatter":{"title":"mbcp.mp_math"},"headers":[],"relativePath":"en/api/mp_math/index.md","filePath":"en/api/mp_math/index.md"}'),n={name:"en/api/mp_math/index.md"};function m(p,i,r,c,o,s){return a(),t("div")}const h=e(n,[["render",m]]);export{d as __pageData,h as default}; diff --git a/assets/en_api_mp_math_line.md.JAqG1sD6.js b/assets/en_api_mp_math_line.md.JAqG1sD6.js new file mode 100644 index 0000000..e2f8661 --- /dev/null +++ b/assets/en_api_mp_math_line.md.JAqG1sD6.js @@ -0,0 +1,192 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"en/api/mp_math/line.md","filePath":"en/api/mp_math/line.md"}'),l={name:"en/api/mp_math/line.md"},h=n(`

class Line3

  • def __init__(self, point: 'Point3', direction: 'Vector3')

三维空间中的直线。由一个点和一个方向向量确定。

Args:

point: 直线上的一点

direction: 直线的方向向量

Source code
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    """
+        三维空间中的直线。由一个点和一个方向向量确定。
+        Args:
+            point: 直线上的一点
+            direction: 直线的方向向量
+        """
+    self.point = point
+    self.direction = direction
  • def approx(self, other: 'Line3', epsilon: float = APPROX)

判断两条直线是否近似相等。

Args:

other: 另一条直线

epsilon: 误差

Source code
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    """
+        判断两条直线是否近似相等。
+        Args:
+            other: 另一条直线
+            epsilon: 误差
+        Returns:
+            是否近似相等
+        """
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)
  • def cal_angle(self, other: 'Line3')

计算直线和直线之间的夹角。

Args:

other: 另一条直线

Source code
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    """
+        计算直线和直线之间的夹角。
+        Args:
+            other: 另一条直线
+        Returns:
+            夹角弧度
+        Raises:
+            TypeError: 不支持的类型
+        """
+    return self.direction.cal_angle(other.direction)
  • def cal_distance(self, other: 'Line3 | Point3')

计算直线和直线或点之间的距离。

Args:

other: 平行直线或点

Source code
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    """
+        计算直线和直线或点之间的距离。
+        Args:
+            other: 平行直线或点
+
+        Returns:
+            距离
+        Raises:
+            TypeError: 不支持的类型
+        """
+    if isinstance(other, Line3):
+        if self == other:
+            return 0
+        elif self.is_parallel(other):
+            return (other.point - self.point).cross(self.direction).length / self.direction.length
+        elif not self.is_coplanar(other):
+            return abs(self.direction.cross(other.direction) @ (self.point - other.point) / self.direction.cross(other.direction).length)
+        else:
+            return 0
+    elif isinstance(other, Point3):
+        return (other - self.point).cross(self.direction).length / self.direction.length
+    else:
+        raise TypeError('Unsupported type.')
  • def cal_intersection(self, other: 'Line3')

计算两条直线的交点。

Args:

other: 另一条直线

Source code
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+    """
+        计算两条直线的交点。
+        Args:
+            other: 另一条直线
+        Returns:
+            交点
+        Raises:
+            ValueError: 直线平行
+            ValueError: 直线不共面
+        """
+    if self.is_parallel(other):
+        raise ValueError('Lines are parallel and do not intersect.')
+    if not self.is_coplanar(other):
+        raise ValueError('Lines are not coplanar and do not intersect.')
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction
  • def cal_perpendicular(self, point: 'Point3')

计算直线经过指定点p的垂线。

Args:

point: 指定点

Source code
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    """
+        计算直线经过指定点p的垂线。
+        Args:
+            point: 指定点
+        Returns:
+            垂线
+        """
+    return Line3(point, self.direction.cross(point - self.point))
  • def get_point(self, t: RealNumber)

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

Args:

t: 参数t

Source code
python
def get_point(self, t: RealNumber) -> 'Point3':
+    """
+        获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
+        Args:
+            t: 参数t
+        Returns:
+
+        """
+    return self.point + t * self.direction
  • def get_parametric_equations(self)

获取直线的参数方程。

Return:

x(t), y(t), z(t)

Source code
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    """
+        获取直线的参数方程。
+        Returns:
+            x(t), y(t), z(t)
+        """
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)
  • def is_approx_parallel(self, other: 'Line3', epsilon: float = 1e-06)

判断两条直线是否近似平行。

Args:

other: 另一条直线

epsilon: 误差

Source code
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    """
+        判断两条直线是否近似平行。
+        Args:
+            other: 另一条直线
+            epsilon: 误差
+        Returns:
+            是否近似平行
+        """
+    return self.direction.is_approx_parallel(other.direction, epsilon)
  • def is_parallel(self, other: 'Line3')

判断两条直线是否平行。

Args:

other: 另一条直线

Source code
python
def is_parallel(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否平行。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否平行
+        """
+    return self.direction.is_parallel(other.direction)
  • def is_collinear(self, other: 'Line3')

判断两条直线是否共线。

Args:

other: 另一条直线

Source code
python
def is_collinear(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否共线。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否共线
+        """
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)
  • def is_point_on(self, point: 'Point3')

判断点是否在直线上。

Args:

point: 点

Source code
python
def is_point_on(self, point: 'Point3') -> bool:
+    """
+        判断点是否在直线上。
+        Args:
+            point: 点
+        Returns:
+            是否在直线上
+        """
+    return (point - self.point).is_parallel(self.direction)
  • def is_coplanar(self, other: 'Line3')

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

Args:

other: 另一条直线

Source code
python
def is_coplanar(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否共面。
+        充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否共面
+        """
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0
  • def simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

Source code
python
def simplify(self):
+    """
+        简化直线方程,等价相等。
+        自体简化,不返回值。
+
+        按照可行性一次对x y z 化 0 处理,并对向量单位化
+        """
+    self.direction.normalize()
+    if self.direction.x == 0:
+        self.point.x = 0
+    if self.direction.y == 0:
+        self.point.y = 0
+    if self.direction.z == 0:
+        self.point.z = 0
  • @classmethod

  • def from_two_points(cls, p1: 'Point3', p2: 'Point3')

工厂函数 由两点构造直线。

Args:

p1: 点1

p2: 点2

Source code
python
@classmethod
+def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
+    """
+        工厂函数 由两点构造直线。
+        Args:
+            p1: 点1
+            p2: 点2
+        Returns:
+            直线
+        """
+    direction = p2 - p1
+    return cls(p1, direction)
  • def __and__(self, other: 'Line3')

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

Args:

other: 另一条直线

Source code
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    """
+        计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
+        Args:
+            other: 另一条直线
+        Returns:
+            交点
+        """
+    if self.is_collinear(other):
+        return self
+    elif self.is_parallel(other) or not self.is_coplanar(other):
+        return None
+    else:
+        return self.cal_intersection(other)
  • def __eq__(self, other)

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

Args:

other:

Source code
python
def __eq__(self, other) -> bool:
+    """
+        判断两条直线是否等价。
+
+        v1 // v2 ∧ (p1 - p2) // v1
+        Args:
+            other:
+
+        Returns:
+
+        """
+    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
Source code
python
def __str__(self):
+    """
+        返回点向式(x-x0)
+        Returns:
+
+        """
+    s = 'Line3: '
+    if self.direction.x != 0:
+        s += f'(x{sign_format(-self.point.x)})/{self.direction.x}'
+    if self.direction.y != 0:
+        s += f' = (y{sign_format(-self.point.y)})/{self.direction.y}'
+    if self.direction.z != 0:
+        s += f' = (z{sign_format(-self.point.z)})/{self.direction.z}'
+    return s
Source code
python
def __repr__(self):
+    return f'Line3({self.point}, {self.direction})'
`,111),t=[h];function e(p,k,r,d,o,F){return a(),i("div",null,t)}const y=s(l,[["render",e]]);export{g as __pageData,y as default}; diff --git a/assets/en_api_mp_math_line.md.JAqG1sD6.lean.js b/assets/en_api_mp_math_line.md.JAqG1sD6.lean.js new file mode 100644 index 0000000..bfb1e17 --- /dev/null +++ b/assets/en_api_mp_math_line.md.JAqG1sD6.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"en/api/mp_math/line.md","filePath":"en/api/mp_math/line.md"}'),l={name:"en/api/mp_math/line.md"},h=n("",111),t=[h];function e(p,k,r,d,o,F){return a(),i("div",null,t)}const y=s(l,[["render",e]]);export{g as __pageData,y as default}; diff --git a/assets/en_api_mp_math_mp_math_typing.md.Dh1by9kw.js b/assets/en_api_mp_math_mp_math_typing.md.Dh1by9kw.js new file mode 100644 index 0000000..05df201 --- /dev/null +++ b/assets/en_api_mp_math_mp_math_typing.md.Dh1by9kw.js @@ -0,0 +1 @@ +import{_ as a,c as r,o as e,a2 as l}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.mp_math.mp_math_typing","description":"","frontmatter":{"title":"mbcp.mp_math.mp_math_typing"},"headers":[],"relativePath":"en/api/mp_math/mp_math_typing.md","filePath":"en/api/mp_math/mp_math_typing.md"}'),n={name:"en/api/mp_math/mp_math_typing.md"},i=l('

var RealNumber: TypeAlias = int | float

var Number: TypeAlias = RealNumber | complex

var SingleVar = TypeVar('SingleVar', bound=Number)

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

var Var: TypeAlias = SingleVar | ArrayVar

var OneSingleVarFunc: TypeAlias = Callable[[SingleVar], SingleVar]

var OneArrayFunc: TypeAlias = Callable[[ArrayVar], ArrayVar]

var OneVarFunc: TypeAlias = OneSingleVarFunc | OneArrayFunc

var TwoSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar], SingleVar]

var TwoArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar], ArrayVar]

var TwoVarsFunc: TypeAlias = TwoSingleVarsFunc | TwoArraysFunc

var ThreeSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar, SingleVar], SingleVar]

var ThreeArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar, ArrayVar], ArrayVar]

var ThreeVarsFunc: TypeAlias = ThreeSingleVarsFunc | ThreeArraysFunc

var MultiSingleVarsFunc: TypeAlias = Callable[..., SingleVar]

var MultiArraysFunc: TypeAlias = Callable[..., ArrayVar]

var MultiVarsFunc: TypeAlias = MultiSingleVarsFunc | MultiArraysFunc

',17),s=[i];function t(o,c,u,y,v,g){return e(),r("div",null,s)}const d=a(n,[["render",t]]);export{m as __pageData,d as default}; diff --git a/assets/en_api_mp_math_mp_math_typing.md.Dh1by9kw.lean.js b/assets/en_api_mp_math_mp_math_typing.md.Dh1by9kw.lean.js new file mode 100644 index 0000000..d129413 --- /dev/null +++ b/assets/en_api_mp_math_mp_math_typing.md.Dh1by9kw.lean.js @@ -0,0 +1 @@ +import{_ as a,c as r,o as e,a2 as l}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.mp_math.mp_math_typing","description":"","frontmatter":{"title":"mbcp.mp_math.mp_math_typing"},"headers":[],"relativePath":"en/api/mp_math/mp_math_typing.md","filePath":"en/api/mp_math/mp_math_typing.md"}'),n={name:"en/api/mp_math/mp_math_typing.md"},i=l("",17),s=[i];function t(o,c,u,y,v,g){return e(),r("div",null,s)}const d=a(n,[["render",t]]);export{m as __pageData,d as default}; diff --git a/assets/api_mp_math_plane.md.Cdj0PlKB.js b/assets/en_api_mp_math_plane.md.BRPMklJt.js similarity index 55% rename from assets/api_mp_math_plane.md.Cdj0PlKB.js rename to assets/en_api_mp_math_plane.md.BRPMklJt.js index cb489f6..8c9bac1 100644 --- a/assets/api_mp_math_plane.md.Cdj0PlKB.js +++ b/assets/en_api_mp_math_plane.md.BRPMklJt.js @@ -1,11 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp\\\\nmath.plane","description":"","frontmatter":{"title":"mbcp.mp\\\\nmath.plane","order":1,"icon":"laptop-code","category":"API"},"headers":[],"relativePath":"api/mp_math/plane.md","filePath":"api/mp_math/plane.md"}'),l={name:"api/mp_math/plane.md"},h=n(`

class Plane3

def __init__(self, a: float, b: float, c: float, d: float) -> None

 平面方程:ax + by + cz + d = 0

Args:

a:
-
-b:
-
-c:
-
-d:
-
源代码
python
def __init__(self, a: float, b: float, c: float, d: float):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"en/api/mp_math/plane.md","filePath":"en/api/mp_math/plane.md"}'),l={name:"en/api/mp_math/plane.md"},h=n(`

var k = other.a / self.a

var A = np.array([[self.b, self.c], [other.b, other.c]])

var B = np.array([-self.d, -other.d])

var v2 = l2.get_point(1) - l1.point

var k = other.b / self.b

var A = np.array([[self.a, self.c], [other.a, other.c]])

var B = np.array([-self.d, -other.d])

var k = other.c / self.c

var A = np.array([[self.a, self.b], [other.a, other.b]])

var B = np.array([-self.d, -other.d])

class Plane3

  • def __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

Args:

a:

b:

c:

d:

Source code
python
def __init__(self, a: float, b: float, c: float, d: float):
     """
         平面方程:ax + by + cz + d = 0
         Args:
@@ -17,16 +10,11 @@ d:
     self.a = a
     self.b = b
     self.c = c
-    self.d = d

def approx(self, other: 'Plane3', epsilon: float) -> bool

 判断两个平面是否近似相等。

Args:

other:
-
-epsilon:
-

Returns:

是否近似相等
-
源代码
python
def approx(self, other: 'Plane3', epsilon: float=APPROX) -> bool:
+    self.d = d
  • def approx(self, other: 'Plane3')

判断两个平面是否近似相等。

Args:

other:

Source code
python
def approx(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否近似相等。
         Args:
             other:
-            epsilon:
 
         Returns:
             是否近似相等
@@ -41,10 +29,7 @@ epsilon:
         k = other.c / self.c
         return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
     else:
-        return False

def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle'

 计算平面与平面之间的夹角。

Args:

other: 另一个平面
-

Returns:

夹角弧度
-

Raises:

TypeError: 不支持的类型
-
源代码
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+        return False
  • def cal_angle(self, other: 'Line3 | Plane3')

计算平面与平面之间的夹角。

Args:

other: 另一个平面

Source code
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
     """
         计算平面与平面之间的夹角。
         Args:
@@ -59,10 +44,7 @@ epsilon:
     elif isinstance(other, Plane3):
         return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

def cal_distance(self, other: 'Plane3 | Point3') -> float

 计算平面与平面或点之间的距离。

Args:

other: 另一个平面或点
-

Returns:

距离
-

Raises:

TypeError: 不支持的类型
-
源代码
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+        raise TypeError(f'Unsupported type: {type(other)}')
  • def cal_distance(self, other: 'Plane3 | Point3')

计算平面与平面或点之间的距离。

Args:

other: 另一个平面或点

Source code
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
     """
         计算平面与平面或点之间的距离。
         Args:
@@ -77,9 +59,7 @@ epsilon:
     elif isinstance(other, Point3):
         return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

def cal_intersection_line3(self, other: 'Plane3') -> 'Line3'

 计算两平面的交线。该方法有问题,待修复。

Args:

other: 另一个平面
-

Returns:

交线
-

Raises:

源代码
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+        raise TypeError(f'Unsupported type: {type(other)}')
  • def cal_intersection_line3(self, other: 'Plane3')

计算两平面的交线。该方法有问题,待修复。

Args:

other: 另一个平面

Source code
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
     """
         计算两平面的交线。该方法有问题,待修复。
         Args:
@@ -104,10 +84,7 @@ epsilon:
         A = np.array([[self.a, self.b], [other.a, other.b]])
         B = np.array([-self.d, -other.d])
         x, y = np.linalg.solve(A, B)
-    return Line3(Point3(x, y, z), direction)

def cal_intersection_point3(self, other: 'Line3') -> 'Point3'

 计算平面与直线的交点。

Args:

other: 不与平面平行或在平面上的直线
-

Returns:

交点
-

Raises:

ValueError: 平面与直线平行或重合
-
源代码
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    return Line3(Point3(x, y, z), direction)
  • def cal_intersection_point3(self, other: 'Line3')

计算平面与直线的交点。

Args:

other: 不与平面平行或在平面上的直线

Source code
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
     """
         计算平面与直线的交点。
         Args:
@@ -121,9 +98,7 @@ epsilon:
         raise ValueError('The plane and the line are parallel or coincident.')
     x, y, z = other.get_parametric_equations()
     t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
-    return Point3(x(t), y(t), z(t))

def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3'

 计算平行于该平面且过指定点的平面。

Args:

point: 指定点
-

Returns:

平面
-
源代码
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    return Point3(x(t), y(t), z(t))
  • def cal_parallel_plane3(self, point: 'Point3')

计算平行于该平面且过指定点的平面。

Args:

point: 指定点

Source code
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
     """
         计算平行于该平面且过指定点的平面。
         Args:
@@ -131,9 +106,7 @@ epsilon:
         Returns:
             平面
         """
-    return Plane3.from_point_and_normal(point, self.normal)

def is_parallel(self, other: 'Plane3') -> bool

 判断两个平面是否平行。

Args:

other: 另一个平面
-

Returns:

是否平行
-
源代码
python
def is_parallel(self, other: 'Plane3') -> bool:
+    return Plane3.from_point_and_normal(point, self.normal)
  • def is_parallel(self, other: 'Plane3')

判断两个平面是否平行。

Args:

other: 另一个平面

Source code
python
def is_parallel(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否平行。
         Args:
@@ -141,19 +114,14 @@ epsilon:
         Returns:
             是否平行
         """
-    return self.normal.is_parallel(other.normal)

@property

def normal(self: Any) -> 'Vector3'

 平面的法向量。

Returns:

法向量
-
源代码
python
@property
+    return self.normal.is_parallel(other.normal)
  • @property

  • def normal(self)

平面的法向量。

Return:

法向量

Source code
python
@property
 def normal(self) -> 'Vector3':
     """
         平面的法向量。
         Returns:
             法向量
         """
-    return Vector3(self.a, self.b, self.c)

@classmethod

def from_point_and_normal(cls: Any, point: 'Point3', normal: 'Vector3') -> 'Plane3'

 工厂函数 由点和法向量构造平面(点法式构造)。

Args:

point: 平面上的一点
-
-normal: 法向量
-

Returns:

平面
-
源代码
python
@classmethod
+    return Vector3(self.a, self.b, self.c)
  • @classmethod

  • def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3')

工厂函数 由点和法向量构造平面(点法式构造)。

Args:

point: 平面上的一点

normal: 法向量

Source code
python
@classmethod
 def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
     """
         工厂函数 由点和法向量构造平面(点法式构造)。
@@ -165,13 +133,7 @@ normal: 法向量
         """
     a, b, c = (normal.x, normal.y, normal.z)
     d = -a * point.x - b * point.y - c * point.z
-    return cls(a, b, c, d)

@classmethod

def from_three_points(cls: Any, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3'

 工厂函数 由三点构造平面。

Args:

p1: 点1
-
-p2: 点2
-
-p3: 点3
-

Returns:

平面
-
源代码
python
@classmethod
+    return cls(a, b, c, d)
  • @classmethod

  • def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3')

工厂函数 由三点构造平面。

Args:

p1: 点1

p2: 点2

p3: 点3

Source code
python
@classmethod
 def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
     """
         工厂函数 由三点构造平面。
@@ -185,11 +147,7 @@ p3: 点3
     v1 = p2 - p1
     v2 = p3 - p1
     normal = v1.cross(v2)
-    return cls.from_point_and_normal(p1, normal)

@classmethod

def from_two_lines(cls: Any, l1: 'Line3', l2: 'Line3') -> 'Plane3'

 工厂函数 由两直线构造平面。

Args:

l1: 直线1
-
-l2: 直线2
-

Returns:

平面
-
源代码
python
@classmethod
+    return cls.from_point_and_normal(p1, normal)
  • @classmethod

  • def from_two_lines(cls, l1: 'Line3', l2: 'Line3')

工厂函数 由两直线构造平面。

Args:

l1: 直线1

l2: 直线2

Source code
python
@classmethod
 def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
     """
         工厂函数 由两直线构造平面。
@@ -203,11 +161,7 @@ l2: 直线2
     v2 = l2.point - l1.point
     if v2 == zero_vector3:
         v2 = l2.get_point(1) - l1.point
-    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

def from_point_and_line(cls: Any, point: 'Point3', line: 'Line3') -> 'Plane3'

 工厂函数 由点和直线构造平面。

Args:

point: 面上一点
-
-line: 面上直线,不包含点
-

Returns:

平面
-
源代码
python
@classmethod
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))
  • @classmethod

  • def from_point_and_line(cls, point: 'Point3', line: 'Line3')

工厂函数 由点和直线构造平面。

Args:

point: 面上一点

line: 面上直线,不包含点

Source code
python
@classmethod
 def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
     """
         工厂函数 由点和直线构造平面。
@@ -217,4 +171,38 @@ line: 面上直线,不包含点
         Returns:
             平面
         """
-    return cls.from_point_and_normal(point, line.direction)

var direction = self.normal.cross(other.normal)

var t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)

var d = -a * point.x - b * point.y - c * point.z

var v1 = p2 - p1

var v2 = p3 - p1

var normal = v1.cross(v2)

var v1 = l1.direction

var v2 = l2.point - l1.point

var s = 'Plane3: '

var k = other.a / self.a

var A = np.array([[self.b, self.c], [other.b, other.c]])

var B = np.array([-self.d, -other.d])

var v2 = l2.get_point(1) - l1.point

var k = other.b / self.b

var A = np.array([[self.a, self.c], [other.a, other.c]])

var B = np.array([-self.d, -other.d])

var k = other.c / self.c

var A = np.array([[self.a, self.b], [other.a, other.b]])

var B = np.array([-self.d, -other.d])

`,119),t=[h];function e(p,k,r,d,o,E){return a(),i("div",null,t)}const F=s(l,[["render",e]]);export{y as __pageData,F as default}; + return cls.from_point_and_normal(point, line.direction)
Source code
python
def __repr__(self):
+    return f'Plane3({self.a}, {self.b}, {self.c}, {self.d})'
Source code
python
def __str__(self):
+    s = 'Plane3: '
+    if self.a != 0:
+        s += f'{sign(self.a, only_neg=True)}{abs(self.a)}x'
+    if self.b != 0:
+        s += f' {sign(self.b)} {abs(self.b)}y'
+    if self.c != 0:
+        s += f' {sign(self.c)} {abs(self.c)}z'
+    if self.d != 0:
+        s += f' {sign(self.d)} {abs(self.d)}'
+    return s + ' = 0'
  • @overload

  • def __and__(self, other: 'Line3')

Source code
python
@overload
+def __and__(self, other: 'Line3') -> 'Point3 | None':
+    ...
  • @overload

  • def __and__(self, other: 'Plane3')

Source code
python
@overload
+def __and__(self, other: 'Plane3') -> 'Line3 | None':
+    ...
  • def __and__(self, other)

取两平面的交集(人话:交线)

Args:

other:

Source code
python
def __and__(self, other):
+    """
+        取两平面的交集(人话:交线)
+        Args:
+            other:
+        Returns:
+            不平行平面的交线,平面平行返回None
+        """
+    if isinstance(other, Plane3):
+        if self.normal.is_parallel(other.normal):
+            return None
+        return self.cal_intersection_line3(other)
+    elif isinstance(other, Line3):
+        if self.normal @ other.direction == 0:
+            return None
+        return self.cal_intersection_point3(other)
+    else:
+        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")
  • def __eq__(self, other)

Source code
python
def __eq__(self, other) -> bool:
+    return self.approx(other)
  • def __rand__(self, other: 'Line3')

Source code
python
def __rand__(self, other: 'Line3') -> 'Point3':
+    return self.cal_intersection_point3(other)
`,115),t=[h];function e(p,k,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",e]]);export{g as __pageData,y as default}; diff --git a/assets/en_api_mp_math_plane.md.BRPMklJt.lean.js b/assets/en_api_mp_math_plane.md.BRPMklJt.lean.js new file mode 100644 index 0000000..034f614 --- /dev/null +++ b/assets/en_api_mp_math_plane.md.BRPMklJt.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"en/api/mp_math/plane.md","filePath":"en/api/mp_math/plane.md"}'),l={name:"en/api/mp_math/plane.md"},h=n("",115),t=[h];function e(p,k,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",e]]);export{g as __pageData,y as default}; diff --git a/assets/en_api_mp_math_point.md.D_AsGf3x.js b/assets/en_api_mp_math_point.md.D_AsGf3x.js new file mode 100644 index 0000000..b9b055e --- /dev/null +++ b/assets/en_api_mp_math_point.md.D_AsGf3x.js @@ -0,0 +1,41 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"en/api/mp_math/point.md","filePath":"en/api/mp_math/point.md"}'),t={name:"en/api/mp_math/point.md"},n=l(`

class Point3

  • def __init__(self, x: float, y: float, z: float)

笛卡尔坐标系中的点。

Args:

x: x 坐标

y: y 坐标

z: z 坐标

Source code
python
def __init__(self, x: float, y: float, z: float):
+    """
+        笛卡尔坐标系中的点。
+        Args:
+            x: x 坐标
+            y: y 坐标
+            z: z 坐标
+        """
+    self.x = x
+    self.y = y
+    self.z = z
  • def approx(self, other: 'Point3', epsilon: float = APPROX)

判断两个点是否近似相等。

Args:

other:

epsilon:

Source code
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个点是否近似相等。
+        Args:
+            other:
+            epsilon:
+
+        Returns:
+            是否近似相等
+        """
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
Source code
python
def __str__(self):
+    return f'Point3({self.x}, {self.y}, {self.z})'
  • @overload

  • def __add__(self, other: 'Vector3')

Source code
python
@overload
+def __add__(self, other: 'Vector3') -> 'Point3':
+    ...
  • @overload

  • def __add__(self, other: 'Point3')

Source code
python
@overload
+def __add__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __add__(self, other)

P + V -> P P + P -> P

Args:

other:

Source code
python
def __add__(self, other):
+    """
+        P + V -> P
+        P + P -> P
+        Args:
+            other:
+        Returns:
+        """
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
  • def __eq__(self, other)

判断两个点是否相等。

Args:

other:

Source code
python
def __eq__(self, other):
+    """
+        判断两个点是否相等。
+        Args:
+            other:
+        Returns:
+        """
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)
`,34),h=[n];function e(p,k,d,r,o,E){return a(),i("div",null,h)}const y=s(t,[["render",e]]);export{g as __pageData,y as default}; diff --git a/assets/en_api_mp_math_point.md.D_AsGf3x.lean.js b/assets/en_api_mp_math_point.md.D_AsGf3x.lean.js new file mode 100644 index 0000000..c76158e --- /dev/null +++ b/assets/en_api_mp_math_point.md.D_AsGf3x.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"en/api/mp_math/point.md","filePath":"en/api/mp_math/point.md"}'),t={name:"en/api/mp_math/point.md"},n=l("",34),h=[n];function e(p,k,d,r,o,E){return a(),i("div",null,h)}const y=s(t,[["render",e]]);export{g as __pageData,y as default}; diff --git a/assets/en_api_mp_math_segment.md.CRs1-Itg.js b/assets/en_api_mp_math_segment.md.CRs1-Itg.js new file mode 100644 index 0000000..00a7777 --- /dev/null +++ b/assets/en_api_mp_math_segment.md.CRs1-Itg.js @@ -0,0 +1,16 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"en/api/mp_math/segment.md","filePath":"en/api/mp_math/segment.md"}'),h={name:"en/api/mp_math/segment.md"},t=n(`

class Segment3

  • def __init__(self, p1: 'Point3', p2: 'Point3')

三维空间中的线段。 :param p1: :param p2:

Source code
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+    """
+        三维空间中的线段。
+        :param p1:
+        :param p2:
+        """
+    self.p1 = p1
+    self.p2 = p2
+    '方向向量'
+    self.direction = self.p2 - self.p1
+    '长度'
+    self.length = self.direction.length
+    '中心点'
+    self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
Source code
python
def __repr__(self):
+    return f'Segment3({self.p1}, {self.p2})'
Source code
python
def __str__(self):
+    return f'Segment3({self.p1} -> {self.p2})'
`,9),l=[t];function e(p,k,r,d,E,g){return a(),i("div",null,l)}const y=s(h,[["render",e]]);export{o as __pageData,y as default}; diff --git a/assets/en_api_mp_math_segment.md.CRs1-Itg.lean.js b/assets/en_api_mp_math_segment.md.CRs1-Itg.lean.js new file mode 100644 index 0000000..8f15e17 --- /dev/null +++ b/assets/en_api_mp_math_segment.md.CRs1-Itg.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"en/api/mp_math/segment.md","filePath":"en/api/mp_math/segment.md"}'),h={name:"en/api/mp_math/segment.md"},t=n("",9),l=[t];function e(p,k,r,d,E,g){return a(),i("div",null,l)}const y=s(h,[["render",e]]);export{o as __pageData,y as default}; diff --git a/assets/en_api_mp_math_utils.md.CoXbSyss.js b/assets/en_api_mp_math_utils.md.CoXbSyss.js new file mode 100644 index 0000000..912aa02 --- /dev/null +++ b/assets/en_api_mp_math_utils.md.CoXbSyss.js @@ -0,0 +1,65 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"en/api/mp_math/utils.md","filePath":"en/api/mp_math/utils.md"}'),l={name:"en/api/mp_math/utils.md"},h=n(`

def clamp()

区间截断函数。

Args:

x:

min_:

max_:

Source code
python
def clamp(x: float, min_: float, max_: float) -> float:
+    """
+    区间截断函数。
+    Args:
+        x:
+        min_:
+        max_:
+
+    Returns:
+        限制后的值
+    """
+    return max(min(x, max_), min_)

def approx(x: float = 0.0, y: float = APPROX)

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

Args:

x:

y:

epsilon:

Source code
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    """
+    判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
+    Args:
+        x:
+        y:
+        epsilon:
+
+    Returns:
+        是否近似相等
+    """
+    return abs(x - y) < epsilon

def sign(x: float = False)

获取数的符号。

Args:

x: 数

only_neg: 是否只返回负数的符号

Source code
python
def sign(x: float, only_neg: bool=False) -> str:
+    """获取数的符号。
+    Args:
+        x: 数
+        only_neg: 是否只返回负数的符号
+    Returns:
+        符号 + - ""
+    """
+    if x > 0:
+        return '+' if not only_neg else ''
+    elif x < 0:
+        return '-'
+    else:
+        return ''

def sign_format(x: float = False)

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

Args:

x: 数

only_neg: 是否只返回负数的符号

Source code
python
def sign_format(x: float, only_neg: bool=False) -> str:
+    """格式化符号数
+    -1 -> -1
+    1 -> +1
+    0 -> ""
+    Args:
+        x: 数
+        only_neg: 是否只返回负数的符号
+    Returns:
+        符号 + - ""
+    """
+    if x > 0:
+        return f'+{x}' if not only_neg else f'{x}'
+    elif x < 0:
+        return f'-{abs(x)}'
+    else:
+        return ''

class Approx

  • def __init__(self, value: RealNumber)

Source code
python
def __init__(self, value: RealNumber):
+    self.value = value
  • def __eq__(self, other)

Source code
python
def __eq__(self, other):
+    if isinstance(self.value, (float, int)):
+        if isinstance(other, (float, int)):
+            return abs(self.value - other) < APPROX
+        else:
+            self.raise_type_error(other)
+    elif isinstance(self.value, Vector3):
+        if isinstance(other, (Vector3, Point3, Plane3, Line3)):
+            return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
+        else:
+            self.raise_type_error(other)
  • def raise_type_error(self, other)

Source code
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')
  • def __ne__(self, other)

Source code
python
def __ne__(self, other):
+    return not self.__eq__(other)
`,35),t=[h];function e(p,k,r,d,F,E){return a(),i("div",null,t)}const y=s(l,[["render",e]]);export{o as __pageData,y as default}; diff --git a/assets/en_api_mp_math_utils.md.CoXbSyss.lean.js b/assets/en_api_mp_math_utils.md.CoXbSyss.lean.js new file mode 100644 index 0000000..71639ba --- /dev/null +++ b/assets/en_api_mp_math_utils.md.CoXbSyss.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"en/api/mp_math/utils.md","filePath":"en/api/mp_math/utils.md"}'),l={name:"en/api/mp_math/utils.md"},h=n("",35),t=[h];function e(p,k,r,d,F,E){return a(),i("div",null,t)}const y=s(l,[["render",e]]);export{o as __pageData,y as default}; diff --git a/assets/en_api_mp_math_vector.md.Dk4b7P4S.js b/assets/en_api_mp_math_vector.md.Dk4b7P4S.js new file mode 100644 index 0000000..cf37d28 --- /dev/null +++ b/assets/en_api_mp_math_vector.md.Dk4b7P4S.js @@ -0,0 +1,189 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"en/api/mp_math/vector.md","filePath":"en/api/mp_math/vector.md"}'),e={name:"en/api/mp_math/vector.md"},h=l(`

var zero_vector3 = Vector3(0, 0, 0)

var x_axis = Vector3(1, 0, 0)

var y_axis = Vector3(0, 1, 0)

var z_axis = Vector3(0, 0, 1)

class Vector3

  • def __init__(self, x: float, y: float, z: float)

3维向量

Args:

x: x轴分量

y: y轴分量

z: z轴分量

Source code
python
def __init__(self, x: float, y: float, z: float):
+    """
+        3维向量
+        Args:
+            x: x轴分量
+            y: y轴分量
+            z: z轴分量
+        """
+    self.x = x
+    self.y = y
+    self.z = z
  • def approx(self, other: 'Vector3', epsilon: float = APPROX)

判断两个向量是否近似相等。

Args:

other:

epsilon:

Source code
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个向量是否近似相等。
+        Args:
+            other:
+            epsilon:
+
+        Returns:
+            是否近似相等
+        """
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
  • def cal_angle(self, other: 'Vector3')

计算两个向量之间的夹角。

Args:

other: 另一个向量

Source code
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    """
+        计算两个向量之间的夹角。
+        Args:
+            other: 另一个向量
+        Returns:
+            夹角
+        """
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)
  • def cross(self, other: 'Vector3')

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

Source code
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    """
+        向量积 叉乘:v1 cross v2 -> v3
+
+        叉乘为0,则两向量平行。
+        其余结果的模为平行四边形的面积。
+
+        返回如下行列式的结果:
+
+        \`\`i  j  k\`\`
+
+        \`\`x1 y1 z1\`\`
+
+        \`\`x2 y2 z2\`\`
+
+        Args:
+            other:
+        Returns:
+            行列式的结果
+        """
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)
  • def is_approx_parallel(self, other: 'Vector3', epsilon: float = APPROX)

判断两个向量是否近似平行。

Args:

other: 另一个向量

epsilon: 允许的误差

Source code
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个向量是否近似平行。
+        Args:
+            other: 另一个向量
+            epsilon: 允许的误差
+        Returns:
+            是否近似平行
+        """
+    return self.cross(other).length < epsilon
  • def is_parallel(self, other: 'Vector3')

判断两个向量是否平行。

Args:

other: 另一个向量

Source code
python
def is_parallel(self, other: 'Vector3') -> bool:
+    """
+        判断两个向量是否平行。
+        Args:
+            other: 另一个向量
+        Returns:
+            是否平行
+        """
+    return self.cross(other).approx(zero_vector3)
  • def normalize(self)

将向量归一化。

自体归一化,不返回值。

Source code
python
def normalize(self):
+    """
+        将向量归一化。
+
+        自体归一化,不返回值。
+        """
+    length = self.length
+    self.x /= length
+    self.y /= length
+    self.z /= length
Source code
python
@property
+def np_array(self) -> 'np.ndarray':
+    """
+        返回numpy数组
+        Returns:
+        """
+    return np.array([self.x, self.y, self.z])
  • @property

  • def length(self)

向量的模。

Return:

Source code
python
@property
+def length(self) -> float:
+    """
+        向量的模。
+        Returns:
+
+        """
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)
  • @property

  • def unit(self)

获取该向量的单位向量。

Return:

单位向量

Source code
python
@property
+def unit(self) -> 'Vector3':
+    """
+        获取该向量的单位向量。
+        Returns:
+            单位向量
+        """
+    return self / self.length
Source code
python
def __abs__(self):
+    return self.length
  • @overload

  • def __add__(self, other: 'Vector3')

Source code
python
@overload
+def __add__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __add__(self, other: 'Point3')

Source code
python
@overload
+def __add__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __add__(self, other)

V + P -> P

V + V -> V

Args:

other:

Source code
python
def __add__(self, other):
+    """
+        V + P -> P
+
+        V + V -> V
+        Args:
+            other:
+        Returns:
+
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x + other.x, self.y + other.y, self.z + other.z)
+    elif isinstance(other, Point3):
+        return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
+    else:
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")
  • def __eq__(self, other)

判断两个向量是否相等。

Args:

other:

Source code
python
def __eq__(self, other):
+    """
+        判断两个向量是否相等。
+        Args:
+            other:
+        Returns:
+            是否相等
+        """
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)
  • def __radd__(self, other: 'Point3')

P + V -> P

别去点那边实现了。 :param other: :return:

Source code
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    """
+        P + V -> P
+
+        别去点那边实现了。
+        :param other:
+        :return:
+        """
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
  • @overload

  • def __sub__(self, other: 'Vector3')

Source code
python
@overload
+def __sub__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __sub__(self, other: 'Point3')

Source code
python
@overload
+def __sub__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __sub__(self, other)

V - P -> P

V - V -> V

Args:

other:

Source code
python
def __sub__(self, other):
+    """
+        V - P -> P
+
+        V - V -> V
+        Args:
+            other:
+        Returns:
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
+    elif isinstance(other, Point3):
+        return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
+    else:
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')
  • def __rsub__(self, other: 'Point3')

P - V -> P

Args:

other:

Source code
python
def __rsub__(self, other: 'Point3'):
+    """
+        P - V -> P
+        Args:
+            other:
+        Returns:
+
+        """
+    if isinstance(other, Point3):
+        return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
+    else:
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")
  • @overload

  • def __mul__(self, other: 'Vector3')

Source code
python
@overload
+def __mul__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __mul__(self, other: RealNumber)

Source code
python
@overload
+def __mul__(self, other: RealNumber) -> 'Vector3':
+    ...
  • def __mul__(self, other: 'int | float | Vector3')

数组运算 非点乘。点乘使用@,叉乘使用cross。

Args:

other:

Source code
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    """
+        数组运算 非点乘。点乘使用@,叉乘使用cross。
+        Args:
+            other:
+
+        Returns:
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x * other.x, self.y * other.y, self.z * other.z)
+    elif isinstance(other, (float, int)):
+        return Vector3(self.x * other, self.y * other, self.z * other)
+    else:
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")
  • def __rmul__(self, other: 'RealNumber')

Source code
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)
  • def __matmul__(self, other: 'Vector3')

点乘。

Args:

other:

Source code
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+    """
+        点乘。
+        Args:
+            other:
+        Returns:
+        """
+    return self.x * other.x + self.y * other.y + self.z * other.z
  • def __truediv__(self, other: RealNumber)

Source code
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)
Source code
python
def __neg__(self):
+    return Vector3(-self.x, -self.y, -self.z)
Source code
python
def __repr__(self):
+    return f'Vector3({self.x}, {self.y}, {self.z})'
Source code
python
def __str__(self):
+    return f'Vector3({self.x}, {self.y}, {self.z})'
`,130),n=[h];function t(p,k,r,d,o,E){return a(),i("div",null,n)}const F=s(e,[["render",t]]);export{y as __pageData,F as default}; diff --git a/assets/en_api_mp_math_vector.md.Dk4b7P4S.lean.js b/assets/en_api_mp_math_vector.md.Dk4b7P4S.lean.js new file mode 100644 index 0000000..d09bf07 --- /dev/null +++ b/assets/en_api_mp_math_vector.md.Dk4b7P4S.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"en/api/mp_math/vector.md","filePath":"en/api/mp_math/vector.md"}'),e={name:"en/api/mp_math/vector.md"},h=l("",130),n=[h];function t(p,k,r,d,o,E){return a(),i("div",null,n)}const F=s(e,[["render",t]]);export{y as __pageData,F as default}; diff --git a/assets/en_api_particle_index.md.CmC1QX5o.js b/assets/en_api_particle_index.md.CmC1QX5o.js new file mode 100644 index 0000000..94f89ef --- /dev/null +++ b/assets/en_api_particle_index.md.CmC1QX5o.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.particle","description":"","frontmatter":{"title":"mbcp.particle"},"headers":[],"relativePath":"en/api/particle/index.md","filePath":"en/api/particle/index.md"}'),i={name:"en/api/particle/index.md"};function r(c,n,p,o,s,d){return a(),t("div")}const _=e(i,[["render",r]]);export{m as __pageData,_ as default}; diff --git a/assets/en_api_particle_index.md.CmC1QX5o.lean.js b/assets/en_api_particle_index.md.CmC1QX5o.lean.js new file mode 100644 index 0000000..94f89ef --- /dev/null +++ b/assets/en_api_particle_index.md.CmC1QX5o.lean.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.particle","description":"","frontmatter":{"title":"mbcp.particle"},"headers":[],"relativePath":"en/api/particle/index.md","filePath":"en/api/particle/index.md"}'),i={name:"en/api/particle/index.md"};function r(c,n,p,o,s,d){return a(),t("div")}const _=e(i,[["render",r]]);export{m as __pageData,_ as default}; diff --git a/assets/en_api_presets_index.md.CZ5hl_7D.js b/assets/en_api_presets_index.md.CZ5hl_7D.js new file mode 100644 index 0000000..920047e --- /dev/null +++ b/assets/en_api_presets_index.md.CZ5hl_7D.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as s}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp.presets","description":"","frontmatter":{"title":"mbcp.presets"},"headers":[],"relativePath":"en/api/presets/index.md","filePath":"en/api/presets/index.md"}'),a={name:"en/api/presets/index.md"};function r(n,p,i,c,o,d){return s(),t("div")}const f=e(a,[["render",r]]);export{_ as __pageData,f as default}; diff --git a/assets/en_api_presets_index.md.CZ5hl_7D.lean.js b/assets/en_api_presets_index.md.CZ5hl_7D.lean.js new file mode 100644 index 0000000..920047e --- /dev/null +++ b/assets/en_api_presets_index.md.CZ5hl_7D.lean.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as s}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp.presets","description":"","frontmatter":{"title":"mbcp.presets"},"headers":[],"relativePath":"en/api/presets/index.md","filePath":"en/api/presets/index.md"}'),a={name:"en/api/presets/index.md"};function r(n,p,i,c,o,d){return s(),t("div")}const f=e(a,[["render",r]]);export{_ as __pageData,f as default}; diff --git a/assets/en_api_presets_model_index.md.DD5WCYA0.js b/assets/en_api_presets_model_index.md.DD5WCYA0.js new file mode 100644 index 0000000..5b2b39f --- /dev/null +++ b/assets/en_api_presets_model_index.md.DD5WCYA0.js @@ -0,0 +1,18 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"en/api/presets/model/index.md","filePath":"en/api/presets/model/index.md"}'),h={name:"en/api/presets/model/index.md"},t=n(`

class GeometricModels

  • @staticmethod

  • def sphere(radius: float, density: float)

生成球体上的点集。

Args:

radius:

density:

Source code
python
@staticmethod
+def sphere(radius: float, density: float):
+    """
+        生成球体上的点集。
+        Args:
+            radius:
+            density:
+        Returns:
+            List[Point3]: 球体上的点集。
+        """
+    area = 4 * np.pi * radius ** 2
+    num = int(area * density)
+    phi_list = np.arccos([clamp(-1 + (2.0 * _ - 1.0) / num, -1, 1) for _ in range(num)])
+    theta_list = np.sqrt(num * np.pi) * phi_list
+    x_array = radius * np.sin(phi_list) * np.cos(theta_list)
+    y_array = radius * np.sin(phi_list) * np.sin(theta_list)
+    z_array = radius * np.cos(phi_list)
+    return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,8),l=[t];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(h,[["render",k]]);export{o as __pageData,F as default}; diff --git a/assets/en_api_presets_model_index.md.DD5WCYA0.lean.js b/assets/en_api_presets_model_index.md.DD5WCYA0.lean.js new file mode 100644 index 0000000..951e976 --- /dev/null +++ b/assets/en_api_presets_model_index.md.DD5WCYA0.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"en/api/presets/model/index.md","filePath":"en/api/presets/model/index.md"}'),h={name:"en/api/presets/model/index.md"},t=n("",8),l=[t];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(h,[["render",k]]);export{o as __pageData,F as default}; diff --git a/assets/ja_api_index.md.4BnflFIm.js b/assets/ja_api_index.md.4BnflFIm.js new file mode 100644 index 0000000..2f8ab8e --- /dev/null +++ b/assets/ja_api_index.md.4BnflFIm.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp","description":"","frontmatter":{"title":"mbcp"},"headers":[],"relativePath":"ja/api/index.md","filePath":"ja/api/index.md"}'),n={name:"ja/api/index.md"};function i(r,c,o,p,s,d){return a(),t("div")}const f=e(n,[["render",i]]);export{_ as __pageData,f as default}; diff --git a/assets/ja_api_index.md.4BnflFIm.lean.js b/assets/ja_api_index.md.4BnflFIm.lean.js new file mode 100644 index 0000000..2f8ab8e --- /dev/null +++ b/assets/ja_api_index.md.4BnflFIm.lean.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp","description":"","frontmatter":{"title":"mbcp"},"headers":[],"relativePath":"ja/api/index.md","filePath":"ja/api/index.md"}'),n={name:"ja/api/index.md"};function i(r,c,o,p,s,d){return a(),t("div")}const f=e(n,[["render",i]]);export{_ as __pageData,f as default}; diff --git a/assets/ja_api_mp_math_angle.md.B0vK-3H7.js b/assets/ja_api_mp_math_angle.md.B0vK-3H7.js new file mode 100644 index 0000000..cec49b1 --- /dev/null +++ b/assets/ja_api_mp_math_angle.md.B0vK-3H7.js @@ -0,0 +1,101 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const c=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"ja/api/mp_math/angle.md","filePath":"ja/api/mp_math/angle.md"}'),e={name:"ja/api/mp_math/angle.md"},n=l(`

class Angle

class AnyAngle

  • def __init__(self, value: float, is_radian: bool = False)

任意角度。

引数:

value: 角度或弧度值

is_radian: 是否为弧度,默认为否

ソースコード
python
def __init__(self, value: float, is_radian: bool=False):
+    """
+        任意角度。
+        Args:
+            value: 角度或弧度值
+            is_radian: 是否为弧度,默认为否
+        """
+    if is_radian:
+        self.radian = value
+    else:
+        self.radian = value * PI / 180
  • @property

  • def complementary(self)

余角:两角的和为90°。

戻り値:

余角

ソースコード
python
@property
+def complementary(self) -> 'AnyAngle':
+    """
+        余角:两角的和为90°。
+        Returns:
+            余角
+        """
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)
  • @property

  • def supplementary(self)

补角:两角的和为180°。

戻り値:

补角

ソースコード
python
@property
+def supplementary(self) -> 'AnyAngle':
+    """
+        补角:两角的和为180°。
+        Returns:
+            补角
+        """
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)
  • @property

  • def degree(self)

角度。

戻り値:

弧度

ソースコード
python
@property
+def degree(self) -> float:
+    """
+        角度。
+        Returns:
+            弧度
+        """
+    return self.radian * 180 / PI
  • @property

  • def minimum_positive(self)

最小正角。

戻り値:

最小正角度

ソースコード
python
@property
+def minimum_positive(self) -> 'AnyAngle':
+    """
+        最小正角。
+        Returns:
+            最小正角度
+        """
+    return AnyAngle(self.radian % (2 * PI))
  • @property

  • def maximum_negative(self)

最大负角。

戻り値:

最大负角度

ソースコード
python
@property
+def maximum_negative(self) -> 'AnyAngle':
+    """
+        最大负角。
+        Returns:
+            最大负角度
+        """
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)
  • @property

  • def sin(self)

正弦值。

戻り値:

正弦值

ソースコード
python
@property
+def sin(self) -> float:
+    """
+        正弦值。
+        Returns:
+            正弦值
+        """
+    return math.sin(self.radian)
  • @property

  • def cos(self)

余弦值。

戻り値:

余弦值

ソースコード
python
@property
+def cos(self) -> float:
+    """
+        余弦值。
+        Returns:
+            余弦值
+        """
+    return math.cos(self.radian)
  • @property

  • def tan(self)

正切值。

戻り値:

正切值

ソースコード
python
@property
+def tan(self) -> float:
+    """
+        正切值。
+        Returns:
+            正切值
+        """
+    return math.tan(self.radian)
  • @property

  • def cot(self)

余切值。

戻り値:

余切值

ソースコード
python
@property
+def cot(self) -> float:
+    """
+        余切值。
+        Returns:
+            余切值
+        """
+    return 1 / math.tan(self.radian)
  • @property

  • def sec(self)

正割值。

戻り値:

正割值

ソースコード
python
@property
+def sec(self) -> float:
+    """
+        正割值。
+        Returns:
+            正割值
+        """
+    return 1 / math.cos(self.radian)
  • @property

  • def csc(self)

余割值。

戻り値:

余割值

ソースコード
python
@property
+def csc(self) -> float:
+    """
+        余割值。
+        Returns:
+            余割值
+        """
+    return 1 / math.sin(self.radian)
  • def __add__(self, other: 'AnyAngle')

ソースコード
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)
  • def __eq__(self, other)

ソースコード
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)
  • def __sub__(self, other: 'AnyAngle')

ソースコード
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)
  • def __mul__(self, other: float)

ソースコード
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)
ソースコード
python
def __repr__(self):
+    return f'AnyAngle({self.radian}, is_radian=True)'
ソースコード
python
def __str__(self):
+    return f'AnyAngle({self.degree}° or {self.radian} rad)'
  • @overload

  • def __truediv__(self, other: float)

ソースコード
python
@overload
+def __truediv__(self, other: float) -> 'AnyAngle':
+    ...
  • @overload

  • def __truediv__(self, other: 'AnyAngle')

ソースコード
python
@overload
+def __truediv__(self, other: 'AnyAngle') -> float:
+    ...
  • def __truediv__(self, other)

ソースコード
python
def __truediv__(self, other):
+    if isinstance(other, AnyAngle):
+        return self.radian / other.radian
+    return AnyAngle(self.radian / other, is_radian=True)
`,93),t=[n];function h(p,k,r,d,o,y){return a(),i("div",null,t)}const F=s(e,[["render",h]]);export{c as __pageData,F as default}; diff --git a/assets/ja_api_mp_math_angle.md.B0vK-3H7.lean.js b/assets/ja_api_mp_math_angle.md.B0vK-3H7.lean.js new file mode 100644 index 0000000..b0fa464 --- /dev/null +++ b/assets/ja_api_mp_math_angle.md.B0vK-3H7.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const c=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"ja/api/mp_math/angle.md","filePath":"ja/api/mp_math/angle.md"}'),e={name:"ja/api/mp_math/angle.md"},n=l("",93),t=[n];function h(p,k,r,d,o,y){return a(),i("div",null,t)}const F=s(e,[["render",h]]);export{c as __pageData,F as default}; diff --git a/assets/ja_api_mp_math_const.md.CQY-Qdbh.js b/assets/ja_api_mp_math_const.md.CQY-Qdbh.js new file mode 100644 index 0000000..b18014b --- /dev/null +++ b/assets/ja_api_mp_math_const.md.CQY-Qdbh.js @@ -0,0 +1 @@ +import{_ as a,c as e,o as t,a2 as r}from"./chunks/framework.BV61Qrc0.js";const v=JSON.parse('{"title":"mbcp.mp_math.const","description":"","frontmatter":{"title":"mbcp.mp_math.const"},"headers":[],"relativePath":"ja/api/mp_math/const.md","filePath":"ja/api/mp_math/const.md"}'),o={name:"ja/api/mp_math/const.md"},n=r('

var PI = math.pi

var E = math.e

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

var GAMMA = 0.5772156649015329

var EPSILON = 0.0001

var APPROX = 0.001

',6),s=[n];function m(h,c,i,d,l,_){return t(),e("div",null,s)}const P=a(o,[["render",m]]);export{v as __pageData,P as default}; diff --git a/assets/ja_api_mp_math_const.md.CQY-Qdbh.lean.js b/assets/ja_api_mp_math_const.md.CQY-Qdbh.lean.js new file mode 100644 index 0000000..69d79c5 --- /dev/null +++ b/assets/ja_api_mp_math_const.md.CQY-Qdbh.lean.js @@ -0,0 +1 @@ +import{_ as a,c as e,o as t,a2 as r}from"./chunks/framework.BV61Qrc0.js";const v=JSON.parse('{"title":"mbcp.mp_math.const","description":"","frontmatter":{"title":"mbcp.mp_math.const"},"headers":[],"relativePath":"ja/api/mp_math/const.md","filePath":"ja/api/mp_math/const.md"}'),o={name:"ja/api/mp_math/const.md"},n=r("",6),s=[n];function m(h,c,i,d,l,_){return t(),e("div",null,s)}const P=a(o,[["render",m]]);export{v as __pageData,P as default}; diff --git a/assets/ja_api_mp_math_equation.md.CxOZG3Ck.js b/assets/ja_api_mp_math_equation.md.CxOZG3Ck.js new file mode 100644 index 0000000..e66b89b --- /dev/null +++ b/assets/ja_api_mp_math_equation.md.CxOZG3Ck.js @@ -0,0 +1,63 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"ja/api/mp_math/equation.md","filePath":"ja/api/mp_math/equation.md"}'),l={name:"ja/api/mp_math/equation.md"},t=n(`

var result_func = get_partial_derivative_func(result_func, v, epsilon)

def get_partial_derivative_func(func: MultiVarsFunc = EPSILON)

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

引数:

func: 函数

var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

epsilon: 偏移量

ソースコード
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+    """
+    求N元函数一阶偏导函数。这玩意不太稳定,慎用。
+    Args:
+        func: 函数
+        var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
+        epsilon: 偏移量
+    Returns:
+        偏导函数
+    Raises:
+        ValueError: 无效变量类型
+    """
+    if isinstance(var, int):
+
+        def partial_derivative_func(*args: Var) -> Var:
+            args_list_plus = list(args)
+            args_list_plus[var] += epsilon
+            args_list_minus = list(args)
+            args_list_minus[var] -= epsilon
+            return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)
+        return partial_derivative_func
+    elif isinstance(var, tuple):
+
+        def high_order_partial_derivative_func(*args: Var) -> Var:
+            result_func = func
+            for v in var:
+                result_func = get_partial_derivative_func(result_func, v, epsilon)
+            return result_func(*args)
+        return high_order_partial_derivative_func
+    else:
+        raise ValueError('Invalid var type')

def partial_derivative_func()

ソースコード
python
def partial_derivative_func(*args: Var) -> Var:
+    args_list_plus = list(args)
+    args_list_plus[var] += epsilon
+    args_list_minus = list(args)
+    args_list_minus[var] -= epsilon
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

def high_order_partial_derivative_func()

ソースコード
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    result_func = func
+    for v in var:
+        result_func = get_partial_derivative_func(result_func, v, epsilon)
+    return result_func(*args)

class CurveEquation

  • def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

引数:

x_func: x函数

y_func: y函数

z_func: z函数

ソースコード
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    """
+        曲线方程。
+        Args:
+            x_func: x函数
+            y_func: y函数
+            z_func: z函数
+        """
+    self.x_func = x_func
+    self.y_func = y_func
+    self.z_func = z_func
  • def __call__(self)

计算曲线上的点。

引数:

*t:

参数:

ソースコード
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    """
+        计算曲线上的点。
+        Args:
+            *t:
+                参数
+        Returns:
+
+        """
+    if len(t) == 1:
+        return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
+    else:
+        return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
ソースコード
python
def __str__(self):
+    return 'CurveEquation()'
`,30),h=[t];function p(e,k,r,d,E,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; diff --git a/assets/ja_api_mp_math_equation.md.CxOZG3Ck.lean.js b/assets/ja_api_mp_math_equation.md.CxOZG3Ck.lean.js new file mode 100644 index 0000000..7cdc0ef --- /dev/null +++ b/assets/ja_api_mp_math_equation.md.CxOZG3Ck.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"ja/api/mp_math/equation.md","filePath":"ja/api/mp_math/equation.md"}'),l={name:"ja/api/mp_math/equation.md"},t=n("",30),h=[t];function p(e,k,r,d,E,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; diff --git a/assets/ja_api_mp_math_index.md.CSAMHYsB.js b/assets/ja_api_mp_math_index.md.CSAMHYsB.js new file mode 100644 index 0000000..dfaa4b1 --- /dev/null +++ b/assets/ja_api_mp_math_index.md.CSAMHYsB.js @@ -0,0 +1 @@ +import{_ as t,c as a,o as e}from"./chunks/framework.BV61Qrc0.js";const d=JSON.parse('{"title":"mbcp.mp_math","description":"","frontmatter":{"title":"mbcp.mp_math"},"headers":[],"relativePath":"ja/api/mp_math/index.md","filePath":"ja/api/mp_math/index.md"}'),m={name:"ja/api/mp_math/index.md"};function p(n,i,r,c,o,s){return e(),a("div")}const h=t(m,[["render",p]]);export{d as __pageData,h as default}; diff --git a/assets/ja_api_mp_math_index.md.CSAMHYsB.lean.js b/assets/ja_api_mp_math_index.md.CSAMHYsB.lean.js new file mode 100644 index 0000000..dfaa4b1 --- /dev/null +++ b/assets/ja_api_mp_math_index.md.CSAMHYsB.lean.js @@ -0,0 +1 @@ +import{_ as t,c as a,o as e}from"./chunks/framework.BV61Qrc0.js";const d=JSON.parse('{"title":"mbcp.mp_math","description":"","frontmatter":{"title":"mbcp.mp_math"},"headers":[],"relativePath":"ja/api/mp_math/index.md","filePath":"ja/api/mp_math/index.md"}'),m={name:"ja/api/mp_math/index.md"};function p(n,i,r,c,o,s){return e(),a("div")}const h=t(m,[["render",p]]);export{d as __pageData,h as default}; diff --git a/assets/ja_api_mp_math_line.md.B_sNS7i2.js b/assets/ja_api_mp_math_line.md.B_sNS7i2.js new file mode 100644 index 0000000..ae66185 --- /dev/null +++ b/assets/ja_api_mp_math_line.md.B_sNS7i2.js @@ -0,0 +1,192 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"ja/api/mp_math/line.md","filePath":"ja/api/mp_math/line.md"}'),l={name:"ja/api/mp_math/line.md"},h=n(`

class Line3

  • def __init__(self, point: 'Point3', direction: 'Vector3')

三维空间中的直线。由一个点和一个方向向量确定。

引数:

point: 直线上的一点

direction: 直线的方向向量

ソースコード
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    """
+        三维空间中的直线。由一个点和一个方向向量确定。
+        Args:
+            point: 直线上的一点
+            direction: 直线的方向向量
+        """
+    self.point = point
+    self.direction = direction
  • def approx(self, other: 'Line3', epsilon: float = APPROX)

判断两条直线是否近似相等。

引数:

other: 另一条直线

epsilon: 误差

ソースコード
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    """
+        判断两条直线是否近似相等。
+        Args:
+            other: 另一条直线
+            epsilon: 误差
+        Returns:
+            是否近似相等
+        """
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)
  • def cal_angle(self, other: 'Line3')

计算直线和直线之间的夹角。

引数:

other: 另一条直线

ソースコード
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    """
+        计算直线和直线之间的夹角。
+        Args:
+            other: 另一条直线
+        Returns:
+            夹角弧度
+        Raises:
+            TypeError: 不支持的类型
+        """
+    return self.direction.cal_angle(other.direction)
  • def cal_distance(self, other: 'Line3 | Point3')

计算直线和直线或点之间的距离。

引数:

other: 平行直线或点

ソースコード
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    """
+        计算直线和直线或点之间的距离。
+        Args:
+            other: 平行直线或点
+
+        Returns:
+            距离
+        Raises:
+            TypeError: 不支持的类型
+        """
+    if isinstance(other, Line3):
+        if self == other:
+            return 0
+        elif self.is_parallel(other):
+            return (other.point - self.point).cross(self.direction).length / self.direction.length
+        elif not self.is_coplanar(other):
+            return abs(self.direction.cross(other.direction) @ (self.point - other.point) / self.direction.cross(other.direction).length)
+        else:
+            return 0
+    elif isinstance(other, Point3):
+        return (other - self.point).cross(self.direction).length / self.direction.length
+    else:
+        raise TypeError('Unsupported type.')
  • def cal_intersection(self, other: 'Line3')

计算两条直线的交点。

引数:

other: 另一条直线

ソースコード
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+    """
+        计算两条直线的交点。
+        Args:
+            other: 另一条直线
+        Returns:
+            交点
+        Raises:
+            ValueError: 直线平行
+            ValueError: 直线不共面
+        """
+    if self.is_parallel(other):
+        raise ValueError('Lines are parallel and do not intersect.')
+    if not self.is_coplanar(other):
+        raise ValueError('Lines are not coplanar and do not intersect.')
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction
  • def cal_perpendicular(self, point: 'Point3')

计算直线经过指定点p的垂线。

引数:

point: 指定点

ソースコード
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    """
+        计算直线经过指定点p的垂线。
+        Args:
+            point: 指定点
+        Returns:
+            垂线
+        """
+    return Line3(point, self.direction.cross(point - self.point))
  • def get_point(self, t: RealNumber)

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

引数:

t: 参数t

ソースコード
python
def get_point(self, t: RealNumber) -> 'Point3':
+    """
+        获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
+        Args:
+            t: 参数t
+        Returns:
+
+        """
+    return self.point + t * self.direction
  • def get_parametric_equations(self)

获取直线的参数方程。

戻り値:

x(t), y(t), z(t)

ソースコード
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    """
+        获取直线的参数方程。
+        Returns:
+            x(t), y(t), z(t)
+        """
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)
  • def is_approx_parallel(self, other: 'Line3', epsilon: float = 1e-06)

判断两条直线是否近似平行。

引数:

other: 另一条直线

epsilon: 误差

ソースコード
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    """
+        判断两条直线是否近似平行。
+        Args:
+            other: 另一条直线
+            epsilon: 误差
+        Returns:
+            是否近似平行
+        """
+    return self.direction.is_approx_parallel(other.direction, epsilon)
  • def is_parallel(self, other: 'Line3')

判断两条直线是否平行。

引数:

other: 另一条直线

ソースコード
python
def is_parallel(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否平行。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否平行
+        """
+    return self.direction.is_parallel(other.direction)
  • def is_collinear(self, other: 'Line3')

判断两条直线是否共线。

引数:

other: 另一条直线

ソースコード
python
def is_collinear(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否共线。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否共线
+        """
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)
  • def is_point_on(self, point: 'Point3')

判断点是否在直线上。

引数:

point: 点

ソースコード
python
def is_point_on(self, point: 'Point3') -> bool:
+    """
+        判断点是否在直线上。
+        Args:
+            point: 点
+        Returns:
+            是否在直线上
+        """
+    return (point - self.point).is_parallel(self.direction)
  • def is_coplanar(self, other: 'Line3')

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

引数:

other: 另一条直线

ソースコード
python
def is_coplanar(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否共面。
+        充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否共面
+        """
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0
  • def simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

ソースコード
python
def simplify(self):
+    """
+        简化直线方程,等价相等。
+        自体简化,不返回值。
+
+        按照可行性一次对x y z 化 0 处理,并对向量单位化
+        """
+    self.direction.normalize()
+    if self.direction.x == 0:
+        self.point.x = 0
+    if self.direction.y == 0:
+        self.point.y = 0
+    if self.direction.z == 0:
+        self.point.z = 0
  • @classmethod

  • def from_two_points(cls, p1: 'Point3', p2: 'Point3')

工厂函数 由两点构造直线。

引数:

p1: 点1

p2: 点2

ソースコード
python
@classmethod
+def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
+    """
+        工厂函数 由两点构造直线。
+        Args:
+            p1: 点1
+            p2: 点2
+        Returns:
+            直线
+        """
+    direction = p2 - p1
+    return cls(p1, direction)
  • def __and__(self, other: 'Line3')

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

引数:

other: 另一条直线

ソースコード
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    """
+        计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
+        Args:
+            other: 另一条直线
+        Returns:
+            交点
+        """
+    if self.is_collinear(other):
+        return self
+    elif self.is_parallel(other) or not self.is_coplanar(other):
+        return None
+    else:
+        return self.cal_intersection(other)
  • def __eq__(self, other)

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

引数:

other:

ソースコード
python
def __eq__(self, other) -> bool:
+    """
+        判断两条直线是否等价。
+
+        v1 // v2 ∧ (p1 - p2) // v1
+        Args:
+            other:
+
+        Returns:
+
+        """
+    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
ソースコード
python
def __str__(self):
+    """
+        返回点向式(x-x0)
+        Returns:
+
+        """
+    s = 'Line3: '
+    if self.direction.x != 0:
+        s += f'(x{sign_format(-self.point.x)})/{self.direction.x}'
+    if self.direction.y != 0:
+        s += f' = (y{sign_format(-self.point.y)})/{self.direction.y}'
+    if self.direction.z != 0:
+        s += f' = (z{sign_format(-self.point.z)})/{self.direction.z}'
+    return s
ソースコード
python
def __repr__(self):
+    return f'Line3({self.point}, {self.direction})'
`,111),t=[h];function p(e,k,r,d,o,F){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{g as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_line.md.B_sNS7i2.lean.js b/assets/ja_api_mp_math_line.md.B_sNS7i2.lean.js new file mode 100644 index 0000000..5f01760 --- /dev/null +++ b/assets/ja_api_mp_math_line.md.B_sNS7i2.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"ja/api/mp_math/line.md","filePath":"ja/api/mp_math/line.md"}'),l={name:"ja/api/mp_math/line.md"},h=n("",111),t=[h];function p(e,k,r,d,o,F){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{g as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_mp_math_typing.md.CeASNaiE.js b/assets/ja_api_mp_math_mp_math_typing.md.CeASNaiE.js new file mode 100644 index 0000000..d95316e --- /dev/null +++ b/assets/ja_api_mp_math_mp_math_typing.md.CeASNaiE.js @@ -0,0 +1 @@ +import{_ as a,c as r,o as e,a2 as l}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.mp_math.mp_math_typing","description":"","frontmatter":{"title":"mbcp.mp_math.mp_math_typing"},"headers":[],"relativePath":"ja/api/mp_math/mp_math_typing.md","filePath":"ja/api/mp_math/mp_math_typing.md"}'),n={name:"ja/api/mp_math/mp_math_typing.md"},i=l('

var RealNumber: TypeAlias = int | float

var Number: TypeAlias = RealNumber | complex

var SingleVar = TypeVar('SingleVar', bound=Number)

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

var Var: TypeAlias = SingleVar | ArrayVar

var OneSingleVarFunc: TypeAlias = Callable[[SingleVar], SingleVar]

var OneArrayFunc: TypeAlias = Callable[[ArrayVar], ArrayVar]

var OneVarFunc: TypeAlias = OneSingleVarFunc | OneArrayFunc

var TwoSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar], SingleVar]

var TwoArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar], ArrayVar]

var TwoVarsFunc: TypeAlias = TwoSingleVarsFunc | TwoArraysFunc

var ThreeSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar, SingleVar], SingleVar]

var ThreeArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar, ArrayVar], ArrayVar]

var ThreeVarsFunc: TypeAlias = ThreeSingleVarsFunc | ThreeArraysFunc

var MultiSingleVarsFunc: TypeAlias = Callable[..., SingleVar]

var MultiArraysFunc: TypeAlias = Callable[..., ArrayVar]

var MultiVarsFunc: TypeAlias = MultiSingleVarsFunc | MultiArraysFunc

',17),s=[i];function t(o,c,u,y,v,g){return e(),r("div",null,s)}const d=a(n,[["render",t]]);export{m as __pageData,d as default}; diff --git a/assets/ja_api_mp_math_mp_math_typing.md.CeASNaiE.lean.js b/assets/ja_api_mp_math_mp_math_typing.md.CeASNaiE.lean.js new file mode 100644 index 0000000..eb78d6f --- /dev/null +++ b/assets/ja_api_mp_math_mp_math_typing.md.CeASNaiE.lean.js @@ -0,0 +1 @@ +import{_ as a,c as r,o as e,a2 as l}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.mp_math.mp_math_typing","description":"","frontmatter":{"title":"mbcp.mp_math.mp_math_typing"},"headers":[],"relativePath":"ja/api/mp_math/mp_math_typing.md","filePath":"ja/api/mp_math/mp_math_typing.md"}'),n={name:"ja/api/mp_math/mp_math_typing.md"},i=l("",17),s=[i];function t(o,c,u,y,v,g){return e(),r("div",null,s)}const d=a(n,[["render",t]]);export{m as __pageData,d as default}; diff --git a/assets/ja_api_mp_math_plane.md.DoFcs9On.js b/assets/ja_api_mp_math_plane.md.DoFcs9On.js new file mode 100644 index 0000000..cdea063 --- /dev/null +++ b/assets/ja_api_mp_math_plane.md.DoFcs9On.js @@ -0,0 +1,208 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"ja/api/mp_math/plane.md","filePath":"ja/api/mp_math/plane.md"}'),l={name:"ja/api/mp_math/plane.md"},h=n(`

var k = other.a / self.a

var A = np.array([[self.b, self.c], [other.b, other.c]])

var B = np.array([-self.d, -other.d])

var v2 = l2.get_point(1) - l1.point

var k = other.b / self.b

var A = np.array([[self.a, self.c], [other.a, other.c]])

var B = np.array([-self.d, -other.d])

var k = other.c / self.c

var A = np.array([[self.a, self.b], [other.a, other.b]])

var B = np.array([-self.d, -other.d])

class Plane3

  • def __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

引数:

a:

b:

c:

d:

ソースコード
python
def __init__(self, a: float, b: float, c: float, d: float):
+    """
+        平面方程:ax + by + cz + d = 0
+        Args:
+            a:
+            b:
+            c:
+            d:
+        """
+    self.a = a
+    self.b = b
+    self.c = c
+    self.d = d
  • def approx(self, other: 'Plane3')

判断两个平面是否近似相等。

引数:

other:

ソースコード
python
def approx(self, other: 'Plane3') -> bool:
+    """
+        判断两个平面是否近似相等。
+        Args:
+            other:
+
+        Returns:
+            是否近似相等
+        """
+    if self.a != 0:
+        k = other.a / self.a
+        return approx(other.b, self.b * k) and approx(other.c, self.c * k) and approx(other.d, self.d * k)
+    elif self.b != 0:
+        k = other.b / self.b
+        return approx(other.a, self.a * k) and approx(other.c, self.c * k) and approx(other.d, self.d * k)
+    elif self.c != 0:
+        k = other.c / self.c
+        return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
+    else:
+        return False
  • def cal_angle(self, other: 'Line3 | Plane3')

计算平面与平面之间的夹角。

引数:

other: 另一个平面

ソースコード
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+    """
+        计算平面与平面之间的夹角。
+        Args:
+            other: 另一个平面
+        Returns:
+            夹角弧度
+        Raises:
+            TypeError: 不支持的类型
+        """
+    if isinstance(other, Line3):
+        return self.normal.cal_angle(other.direction).complementary
+    elif isinstance(other, Plane3):
+        return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
+    else:
+        raise TypeError(f'Unsupported type: {type(other)}')
  • def cal_distance(self, other: 'Plane3 | Point3')

计算平面与平面或点之间的距离。

引数:

other: 另一个平面或点

ソースコード
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+    """
+        计算平面与平面或点之间的距离。
+        Args:
+            other: 另一个平面或点
+        Returns:
+            距离
+        Raises:
+            TypeError: 不支持的类型
+        """
+    if isinstance(other, Plane3):
+        return 0
+    elif isinstance(other, Point3):
+        return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
+    else:
+        raise TypeError(f'Unsupported type: {type(other)}')
  • def cal_intersection_line3(self, other: 'Plane3')

计算两平面的交线。该方法有问题,待修复。

引数:

other: 另一个平面

ソースコード
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+    """
+        计算两平面的交线。该方法有问题,待修复。
+        Args:
+            other: 另一个平面
+        Returns:
+            交线
+        Raises:
+        """
+    if self.normal.is_parallel(other.normal):
+        raise ValueError('Planes are parallel and have no intersection.')
+    direction = self.normal.cross(other.normal)
+    x, y, z = (0, 0, 0)
+    if self.a != 0 and other.a != 0:
+        A = np.array([[self.b, self.c], [other.b, other.c]])
+        B = np.array([-self.d, -other.d])
+        y, z = np.linalg.solve(A, B)
+    elif self.b != 0 and other.b != 0:
+        A = np.array([[self.a, self.c], [other.a, other.c]])
+        B = np.array([-self.d, -other.d])
+        x, z = np.linalg.solve(A, B)
+    elif self.c != 0 and other.c != 0:
+        A = np.array([[self.a, self.b], [other.a, other.b]])
+        B = np.array([-self.d, -other.d])
+        x, y = np.linalg.solve(A, B)
+    return Line3(Point3(x, y, z), direction)
  • def cal_intersection_point3(self, other: 'Line3')

计算平面与直线的交点。

引数:

other: 不与平面平行或在平面上的直线

ソースコード
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    """
+        计算平面与直线的交点。
+        Args:
+            other: 不与平面平行或在平面上的直线
+        Returns:
+            交点
+        Raises:
+            ValueError: 平面与直线平行或重合
+        """
+    if self.normal @ other.direction == 0:
+        raise ValueError('The plane and the line are parallel or coincident.')
+    x, y, z = other.get_parametric_equations()
+    t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
+    return Point3(x(t), y(t), z(t))
  • def cal_parallel_plane3(self, point: 'Point3')

计算平行于该平面且过指定点的平面。

引数:

point: 指定点

ソースコード
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    """
+        计算平行于该平面且过指定点的平面。
+        Args:
+            point: 指定点
+        Returns:
+            平面
+        """
+    return Plane3.from_point_and_normal(point, self.normal)
  • def is_parallel(self, other: 'Plane3')

判断两个平面是否平行。

引数:

other: 另一个平面

ソースコード
python
def is_parallel(self, other: 'Plane3') -> bool:
+    """
+        判断两个平面是否平行。
+        Args:
+            other: 另一个平面
+        Returns:
+            是否平行
+        """
+    return self.normal.is_parallel(other.normal)
  • @property

  • def normal(self)

平面的法向量。

戻り値:

法向量

ソースコード
python
@property
+def normal(self) -> 'Vector3':
+    """
+        平面的法向量。
+        Returns:
+            法向量
+        """
+    return Vector3(self.a, self.b, self.c)
  • @classmethod

  • def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3')

工厂函数 由点和法向量构造平面(点法式构造)。

引数:

point: 平面上的一点

normal: 法向量

ソースコード
python
@classmethod
+def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
+    """
+        工厂函数 由点和法向量构造平面(点法式构造)。
+        Args:
+            point: 平面上的一点
+            normal: 法向量
+        Returns:
+            平面
+        """
+    a, b, c = (normal.x, normal.y, normal.z)
+    d = -a * point.x - b * point.y - c * point.z
+    return cls(a, b, c, d)
  • @classmethod

  • def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3')

工厂函数 由三点构造平面。

引数:

p1: 点1

p2: 点2

p3: 点3

ソースコード
python
@classmethod
+def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
+    """
+        工厂函数 由三点构造平面。
+        Args:
+            p1: 点1
+            p2: 点2
+            p3: 点3
+        Returns:
+            平面
+        """
+    v1 = p2 - p1
+    v2 = p3 - p1
+    normal = v1.cross(v2)
+    return cls.from_point_and_normal(p1, normal)
  • @classmethod

  • def from_two_lines(cls, l1: 'Line3', l2: 'Line3')

工厂函数 由两直线构造平面。

引数:

l1: 直线1

l2: 直线2

ソースコード
python
@classmethod
+def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
+    """
+        工厂函数 由两直线构造平面。
+        Args:
+            l1: 直线1
+            l2: 直线2
+        Returns:
+            平面
+        """
+    v1 = l1.direction
+    v2 = l2.point - l1.point
+    if v2 == zero_vector3:
+        v2 = l2.get_point(1) - l1.point
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))
  • @classmethod

  • def from_point_and_line(cls, point: 'Point3', line: 'Line3')

工厂函数 由点和直线构造平面。

引数:

point: 面上一点

line: 面上直线,不包含点

ソースコード
python
@classmethod
+def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
+    """
+        工厂函数 由点和直线构造平面。
+        Args:
+            point: 面上一点
+            line: 面上直线,不包含点
+        Returns:
+            平面
+        """
+    return cls.from_point_and_normal(point, line.direction)
ソースコード
python
def __repr__(self):
+    return f'Plane3({self.a}, {self.b}, {self.c}, {self.d})'
ソースコード
python
def __str__(self):
+    s = 'Plane3: '
+    if self.a != 0:
+        s += f'{sign(self.a, only_neg=True)}{abs(self.a)}x'
+    if self.b != 0:
+        s += f' {sign(self.b)} {abs(self.b)}y'
+    if self.c != 0:
+        s += f' {sign(self.c)} {abs(self.c)}z'
+    if self.d != 0:
+        s += f' {sign(self.d)} {abs(self.d)}'
+    return s + ' = 0'
  • @overload

  • def __and__(self, other: 'Line3')

ソースコード
python
@overload
+def __and__(self, other: 'Line3') -> 'Point3 | None':
+    ...
  • @overload

  • def __and__(self, other: 'Plane3')

ソースコード
python
@overload
+def __and__(self, other: 'Plane3') -> 'Line3 | None':
+    ...
  • def __and__(self, other)

取两平面的交集(人话:交线)

引数:

other:

ソースコード
python
def __and__(self, other):
+    """
+        取两平面的交集(人话:交线)
+        Args:
+            other:
+        Returns:
+            不平行平面的交线,平面平行返回None
+        """
+    if isinstance(other, Plane3):
+        if self.normal.is_parallel(other.normal):
+            return None
+        return self.cal_intersection_line3(other)
+    elif isinstance(other, Line3):
+        if self.normal @ other.direction == 0:
+            return None
+        return self.cal_intersection_point3(other)
+    else:
+        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")
  • def __eq__(self, other)

ソースコード
python
def __eq__(self, other) -> bool:
+    return self.approx(other)
  • def __rand__(self, other: 'Line3')

ソースコード
python
def __rand__(self, other: 'Line3') -> 'Point3':
+    return self.cal_intersection_point3(other)
`,115),t=[h];function e(p,k,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",e]]);export{g as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_plane.md.DoFcs9On.lean.js b/assets/ja_api_mp_math_plane.md.DoFcs9On.lean.js new file mode 100644 index 0000000..2af19c1 --- /dev/null +++ b/assets/ja_api_mp_math_plane.md.DoFcs9On.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"ja/api/mp_math/plane.md","filePath":"ja/api/mp_math/plane.md"}'),l={name:"ja/api/mp_math/plane.md"},h=n("",115),t=[h];function e(p,k,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",e]]);export{g as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_point.md.DsWUjRQD.js b/assets/ja_api_mp_math_point.md.DsWUjRQD.js new file mode 100644 index 0000000..e2b3a96 --- /dev/null +++ b/assets/ja_api_mp_math_point.md.DsWUjRQD.js @@ -0,0 +1,41 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"ja/api/mp_math/point.md","filePath":"ja/api/mp_math/point.md"}'),t={name:"ja/api/mp_math/point.md"},n=l(`

class Point3

  • def __init__(self, x: float, y: float, z: float)

笛卡尔坐标系中的点。

引数:

x: x 坐标

y: y 坐标

z: z 坐标

ソースコード
python
def __init__(self, x: float, y: float, z: float):
+    """
+        笛卡尔坐标系中的点。
+        Args:
+            x: x 坐标
+            y: y 坐标
+            z: z 坐标
+        """
+    self.x = x
+    self.y = y
+    self.z = z
  • def approx(self, other: 'Point3', epsilon: float = APPROX)

判断两个点是否近似相等。

引数:

other:

epsilon:

ソースコード
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个点是否近似相等。
+        Args:
+            other:
+            epsilon:
+
+        Returns:
+            是否近似相等
+        """
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
ソースコード
python
def __str__(self):
+    return f'Point3({self.x}, {self.y}, {self.z})'
  • @overload

  • def __add__(self, other: 'Vector3')

ソースコード
python
@overload
+def __add__(self, other: 'Vector3') -> 'Point3':
+    ...
  • @overload

  • def __add__(self, other: 'Point3')

ソースコード
python
@overload
+def __add__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __add__(self, other)

P + V -> P P + P -> P

引数:

other:

ソースコード
python
def __add__(self, other):
+    """
+        P + V -> P
+        P + P -> P
+        Args:
+            other:
+        Returns:
+        """
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
  • def __eq__(self, other)

判断两个点是否相等。

引数:

other:

ソースコード
python
def __eq__(self, other):
+    """
+        判断两个点是否相等。
+        Args:
+            other:
+        Returns:
+        """
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)
`,34),h=[n];function e(p,k,d,r,o,E){return a(),i("div",null,h)}const g=s(t,[["render",e]]);export{y as __pageData,g as default}; diff --git a/assets/ja_api_mp_math_point.md.DsWUjRQD.lean.js b/assets/ja_api_mp_math_point.md.DsWUjRQD.lean.js new file mode 100644 index 0000000..024986c --- /dev/null +++ b/assets/ja_api_mp_math_point.md.DsWUjRQD.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"ja/api/mp_math/point.md","filePath":"ja/api/mp_math/point.md"}'),t={name:"ja/api/mp_math/point.md"},n=l("",34),h=[n];function e(p,k,d,r,o,E){return a(),i("div",null,h)}const g=s(t,[["render",e]]);export{y as __pageData,g as default}; diff --git a/assets/ja_api_mp_math_segment.md.B3JRHboi.js b/assets/ja_api_mp_math_segment.md.B3JRHboi.js new file mode 100644 index 0000000..3339232 --- /dev/null +++ b/assets/ja_api_mp_math_segment.md.B3JRHboi.js @@ -0,0 +1,16 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"ja/api/mp_math/segment.md","filePath":"ja/api/mp_math/segment.md"}'),h={name:"ja/api/mp_math/segment.md"},t=n(`

class Segment3

  • def __init__(self, p1: 'Point3', p2: 'Point3')

三维空间中的线段。 :param p1: :param p2:

ソースコード
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+    """
+        三维空间中的线段。
+        :param p1:
+        :param p2:
+        """
+    self.p1 = p1
+    self.p2 = p2
+    '方向向量'
+    self.direction = self.p2 - self.p1
+    '长度'
+    self.length = self.direction.length
+    '中心点'
+    self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
ソースコード
python
def __repr__(self):
+    return f'Segment3({self.p1}, {self.p2})'
ソースコード
python
def __str__(self):
+    return f'Segment3({self.p1} -> {self.p2})'
`,9),l=[t];function e(p,k,r,d,E,g){return a(),i("div",null,l)}const o=s(h,[["render",e]]);export{y as __pageData,o as default}; diff --git a/assets/ja_api_mp_math_segment.md.B3JRHboi.lean.js b/assets/ja_api_mp_math_segment.md.B3JRHboi.lean.js new file mode 100644 index 0000000..dff63b7 --- /dev/null +++ b/assets/ja_api_mp_math_segment.md.B3JRHboi.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"ja/api/mp_math/segment.md","filePath":"ja/api/mp_math/segment.md"}'),h={name:"ja/api/mp_math/segment.md"},t=n("",9),l=[t];function e(p,k,r,d,E,g){return a(),i("div",null,l)}const o=s(h,[["render",e]]);export{y as __pageData,o as default}; diff --git a/assets/ja_api_mp_math_utils.md.CMaGJtHQ.js b/assets/ja_api_mp_math_utils.md.CMaGJtHQ.js new file mode 100644 index 0000000..7c9c23b --- /dev/null +++ b/assets/ja_api_mp_math_utils.md.CMaGJtHQ.js @@ -0,0 +1,65 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"ja/api/mp_math/utils.md","filePath":"ja/api/mp_math/utils.md"}'),l={name:"ja/api/mp_math/utils.md"},h=n(`

def clamp()

区间截断函数。

引数:

x:

min_:

max_:

ソースコード
python
def clamp(x: float, min_: float, max_: float) -> float:
+    """
+    区间截断函数。
+    Args:
+        x:
+        min_:
+        max_:
+
+    Returns:
+        限制后的值
+    """
+    return max(min(x, max_), min_)

def approx(x: float = 0.0, y: float = APPROX)

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

引数:

x:

y:

epsilon:

ソースコード
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    """
+    判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
+    Args:
+        x:
+        y:
+        epsilon:
+
+    Returns:
+        是否近似相等
+    """
+    return abs(x - y) < epsilon

def sign(x: float = False)

获取数的符号。

引数:

x: 数

only_neg: 是否只返回负数的符号

ソースコード
python
def sign(x: float, only_neg: bool=False) -> str:
+    """获取数的符号。
+    Args:
+        x: 数
+        only_neg: 是否只返回负数的符号
+    Returns:
+        符号 + - ""
+    """
+    if x > 0:
+        return '+' if not only_neg else ''
+    elif x < 0:
+        return '-'
+    else:
+        return ''

def sign_format(x: float = False)

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

引数:

x: 数

only_neg: 是否只返回负数的符号

ソースコード
python
def sign_format(x: float, only_neg: bool=False) -> str:
+    """格式化符号数
+    -1 -> -1
+    1 -> +1
+    0 -> ""
+    Args:
+        x: 数
+        only_neg: 是否只返回负数的符号
+    Returns:
+        符号 + - ""
+    """
+    if x > 0:
+        return f'+{x}' if not only_neg else f'{x}'
+    elif x < 0:
+        return f'-{abs(x)}'
+    else:
+        return ''

class Approx

  • def __init__(self, value: RealNumber)

ソースコード
python
def __init__(self, value: RealNumber):
+    self.value = value
  • def __eq__(self, other)

ソースコード
python
def __eq__(self, other):
+    if isinstance(self.value, (float, int)):
+        if isinstance(other, (float, int)):
+            return abs(self.value - other) < APPROX
+        else:
+            self.raise_type_error(other)
+    elif isinstance(self.value, Vector3):
+        if isinstance(other, (Vector3, Point3, Plane3, Line3)):
+            return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
+        else:
+            self.raise_type_error(other)
  • def raise_type_error(self, other)

ソースコード
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')
  • def __ne__(self, other)

ソースコード
python
def __ne__(self, other):
+    return not self.__eq__(other)
`,35),t=[h];function p(e,k,r,d,F,E){return a(),i("div",null,t)}const o=s(l,[["render",p]]);export{y as __pageData,o as default}; diff --git a/assets/ja_api_mp_math_utils.md.CMaGJtHQ.lean.js b/assets/ja_api_mp_math_utils.md.CMaGJtHQ.lean.js new file mode 100644 index 0000000..fd6dddd --- /dev/null +++ b/assets/ja_api_mp_math_utils.md.CMaGJtHQ.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"ja/api/mp_math/utils.md","filePath":"ja/api/mp_math/utils.md"}'),l={name:"ja/api/mp_math/utils.md"},h=n("",35),t=[h];function p(e,k,r,d,F,E){return a(),i("div",null,t)}const o=s(l,[["render",p]]);export{y as __pageData,o as default}; diff --git a/assets/ja_api_mp_math_vector.md.BaQ1gWXc.js b/assets/ja_api_mp_math_vector.md.BaQ1gWXc.js new file mode 100644 index 0000000..2dbde1a --- /dev/null +++ b/assets/ja_api_mp_math_vector.md.BaQ1gWXc.js @@ -0,0 +1,189 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"ja/api/mp_math/vector.md","filePath":"ja/api/mp_math/vector.md"}'),h={name:"ja/api/mp_math/vector.md"},n=l(`

var zero_vector3 = Vector3(0, 0, 0)

var x_axis = Vector3(1, 0, 0)

var y_axis = Vector3(0, 1, 0)

var z_axis = Vector3(0, 0, 1)

class Vector3

  • def __init__(self, x: float, y: float, z: float)

3维向量

引数:

x: x轴分量

y: y轴分量

z: z轴分量

ソースコード
python
def __init__(self, x: float, y: float, z: float):
+    """
+        3维向量
+        Args:
+            x: x轴分量
+            y: y轴分量
+            z: z轴分量
+        """
+    self.x = x
+    self.y = y
+    self.z = z
  • def approx(self, other: 'Vector3', epsilon: float = APPROX)

判断两个向量是否近似相等。

引数:

other:

epsilon:

ソースコード
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个向量是否近似相等。
+        Args:
+            other:
+            epsilon:
+
+        Returns:
+            是否近似相等
+        """
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
  • def cal_angle(self, other: 'Vector3')

计算两个向量之间的夹角。

引数:

other: 另一个向量

ソースコード
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    """
+        计算两个向量之间的夹角。
+        Args:
+            other: 另一个向量
+        Returns:
+            夹角
+        """
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)
  • def cross(self, other: 'Vector3')

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

ソースコード
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    """
+        向量积 叉乘:v1 cross v2 -> v3
+
+        叉乘为0,则两向量平行。
+        其余结果的模为平行四边形的面积。
+
+        返回如下行列式的结果:
+
+        \`\`i  j  k\`\`
+
+        \`\`x1 y1 z1\`\`
+
+        \`\`x2 y2 z2\`\`
+
+        Args:
+            other:
+        Returns:
+            行列式的结果
+        """
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)
  • def is_approx_parallel(self, other: 'Vector3', epsilon: float = APPROX)

判断两个向量是否近似平行。

引数:

other: 另一个向量

epsilon: 允许的误差

ソースコード
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个向量是否近似平行。
+        Args:
+            other: 另一个向量
+            epsilon: 允许的误差
+        Returns:
+            是否近似平行
+        """
+    return self.cross(other).length < epsilon
  • def is_parallel(self, other: 'Vector3')

判断两个向量是否平行。

引数:

other: 另一个向量

ソースコード
python
def is_parallel(self, other: 'Vector3') -> bool:
+    """
+        判断两个向量是否平行。
+        Args:
+            other: 另一个向量
+        Returns:
+            是否平行
+        """
+    return self.cross(other).approx(zero_vector3)
  • def normalize(self)

将向量归一化。

自体归一化,不返回值。

ソースコード
python
def normalize(self):
+    """
+        将向量归一化。
+
+        自体归一化,不返回值。
+        """
+    length = self.length
+    self.x /= length
+    self.y /= length
+    self.z /= length
ソースコード
python
@property
+def np_array(self) -> 'np.ndarray':
+    """
+        返回numpy数组
+        Returns:
+        """
+    return np.array([self.x, self.y, self.z])
  • @property

  • def length(self)

向量的模。

戻り値:

ソースコード
python
@property
+def length(self) -> float:
+    """
+        向量的模。
+        Returns:
+
+        """
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)
  • @property

  • def unit(self)

获取该向量的单位向量。

戻り値:

单位向量

ソースコード
python
@property
+def unit(self) -> 'Vector3':
+    """
+        获取该向量的单位向量。
+        Returns:
+            单位向量
+        """
+    return self / self.length
ソースコード
python
def __abs__(self):
+    return self.length
  • @overload

  • def __add__(self, other: 'Vector3')

ソースコード
python
@overload
+def __add__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __add__(self, other: 'Point3')

ソースコード
python
@overload
+def __add__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __add__(self, other)

V + P -> P

V + V -> V

引数:

other:

ソースコード
python
def __add__(self, other):
+    """
+        V + P -> P
+
+        V + V -> V
+        Args:
+            other:
+        Returns:
+
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x + other.x, self.y + other.y, self.z + other.z)
+    elif isinstance(other, Point3):
+        return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
+    else:
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")
  • def __eq__(self, other)

判断两个向量是否相等。

引数:

other:

ソースコード
python
def __eq__(self, other):
+    """
+        判断两个向量是否相等。
+        Args:
+            other:
+        Returns:
+            是否相等
+        """
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)
  • def __radd__(self, other: 'Point3')

P + V -> P

别去点那边实现了。 :param other: :return:

ソースコード
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    """
+        P + V -> P
+
+        别去点那边实现了。
+        :param other:
+        :return:
+        """
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
  • @overload

  • def __sub__(self, other: 'Vector3')

ソースコード
python
@overload
+def __sub__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __sub__(self, other: 'Point3')

ソースコード
python
@overload
+def __sub__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __sub__(self, other)

V - P -> P

V - V -> V

引数:

other:

ソースコード
python
def __sub__(self, other):
+    """
+        V - P -> P
+
+        V - V -> V
+        Args:
+            other:
+        Returns:
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
+    elif isinstance(other, Point3):
+        return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
+    else:
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')
  • def __rsub__(self, other: 'Point3')

P - V -> P

引数:

other:

ソースコード
python
def __rsub__(self, other: 'Point3'):
+    """
+        P - V -> P
+        Args:
+            other:
+        Returns:
+
+        """
+    if isinstance(other, Point3):
+        return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
+    else:
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")
  • @overload

  • def __mul__(self, other: 'Vector3')

ソースコード
python
@overload
+def __mul__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __mul__(self, other: RealNumber)

ソースコード
python
@overload
+def __mul__(self, other: RealNumber) -> 'Vector3':
+    ...
  • def __mul__(self, other: 'int | float | Vector3')

数组运算 非点乘。点乘使用@,叉乘使用cross。

引数:

other:

ソースコード
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    """
+        数组运算 非点乘。点乘使用@,叉乘使用cross。
+        Args:
+            other:
+
+        Returns:
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x * other.x, self.y * other.y, self.z * other.z)
+    elif isinstance(other, (float, int)):
+        return Vector3(self.x * other, self.y * other, self.z * other)
+    else:
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")
  • def __rmul__(self, other: 'RealNumber')

ソースコード
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)
  • def __matmul__(self, other: 'Vector3')

点乘。

引数:

other:

ソースコード
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+    """
+        点乘。
+        Args:
+            other:
+        Returns:
+        """
+    return self.x * other.x + self.y * other.y + self.z * other.z
  • def __truediv__(self, other: RealNumber)

ソースコード
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)
ソースコード
python
def __neg__(self):
+    return Vector3(-self.x, -self.y, -self.z)
ソースコード
python
def __repr__(self):
+    return f'Vector3({self.x}, {self.y}, {self.z})'
ソースコード
python
def __str__(self):
+    return f'Vector3({self.x}, {self.y}, {self.z})'
`,130),e=[n];function t(p,k,r,d,o,E){return a(),i("div",null,e)}const F=s(h,[["render",t]]);export{g as __pageData,F as default}; diff --git a/assets/ja_api_mp_math_vector.md.BaQ1gWXc.lean.js b/assets/ja_api_mp_math_vector.md.BaQ1gWXc.lean.js new file mode 100644 index 0000000..396f99e --- /dev/null +++ b/assets/ja_api_mp_math_vector.md.BaQ1gWXc.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as l}from"./chunks/framework.BV61Qrc0.js";const g=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"ja/api/mp_math/vector.md","filePath":"ja/api/mp_math/vector.md"}'),h={name:"ja/api/mp_math/vector.md"},n=l("",130),e=[n];function t(p,k,r,d,o,E){return a(),i("div",null,e)}const F=s(h,[["render",t]]);export{g as __pageData,F as default}; diff --git a/assets/ja_api_particle_index.md.E2YnH7EN.js b/assets/ja_api_particle_index.md.E2YnH7EN.js new file mode 100644 index 0000000..e479d57 --- /dev/null +++ b/assets/ja_api_particle_index.md.E2YnH7EN.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.particle","description":"","frontmatter":{"title":"mbcp.particle"},"headers":[],"relativePath":"ja/api/particle/index.md","filePath":"ja/api/particle/index.md"}'),i={name:"ja/api/particle/index.md"};function r(c,p,n,o,s,d){return a(),t("div")}const _=e(i,[["render",r]]);export{m as __pageData,_ as default}; diff --git a/assets/ja_api_particle_index.md.E2YnH7EN.lean.js b/assets/ja_api_particle_index.md.E2YnH7EN.lean.js new file mode 100644 index 0000000..e479d57 --- /dev/null +++ b/assets/ja_api_particle_index.md.E2YnH7EN.lean.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const m=JSON.parse('{"title":"mbcp.particle","description":"","frontmatter":{"title":"mbcp.particle"},"headers":[],"relativePath":"ja/api/particle/index.md","filePath":"ja/api/particle/index.md"}'),i={name:"ja/api/particle/index.md"};function r(c,p,n,o,s,d){return a(),t("div")}const _=e(i,[["render",r]]);export{m as __pageData,_ as default}; diff --git a/assets/ja_api_presets_index.md.ATGcHt9d.js b/assets/ja_api_presets_index.md.ATGcHt9d.js new file mode 100644 index 0000000..ae5922f --- /dev/null +++ b/assets/ja_api_presets_index.md.ATGcHt9d.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp.presets","description":"","frontmatter":{"title":"mbcp.presets"},"headers":[],"relativePath":"ja/api/presets/index.md","filePath":"ja/api/presets/index.md"}'),s={name:"ja/api/presets/index.md"};function r(p,n,i,c,o,d){return a(),t("div")}const f=e(s,[["render",r]]);export{_ as __pageData,f as default}; diff --git a/assets/ja_api_presets_index.md.ATGcHt9d.lean.js b/assets/ja_api_presets_index.md.ATGcHt9d.lean.js new file mode 100644 index 0000000..ae5922f --- /dev/null +++ b/assets/ja_api_presets_index.md.ATGcHt9d.lean.js @@ -0,0 +1 @@ +import{_ as e,c as t,o as a}from"./chunks/framework.BV61Qrc0.js";const _=JSON.parse('{"title":"mbcp.presets","description":"","frontmatter":{"title":"mbcp.presets"},"headers":[],"relativePath":"ja/api/presets/index.md","filePath":"ja/api/presets/index.md"}'),s={name:"ja/api/presets/index.md"};function r(p,n,i,c,o,d){return a(),t("div")}const f=e(s,[["render",r]]);export{_ as __pageData,f as default}; diff --git a/assets/ja_api_presets_model_index.md.D4BAOCXn.js b/assets/ja_api_presets_model_index.md.D4BAOCXn.js new file mode 100644 index 0000000..880ff0e --- /dev/null +++ b/assets/ja_api_presets_model_index.md.D4BAOCXn.js @@ -0,0 +1,18 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"ja/api/presets/model/index.md","filePath":"ja/api/presets/model/index.md"}'),h={name:"ja/api/presets/model/index.md"},t=n(`

class GeometricModels

  • @staticmethod

  • def sphere(radius: float, density: float)

生成球体上的点集。

引数:

radius:

density:

ソースコード
python
@staticmethod
+def sphere(radius: float, density: float):
+    """
+        生成球体上的点集。
+        Args:
+            radius:
+            density:
+        Returns:
+            List[Point3]: 球体上的点集。
+        """
+    area = 4 * np.pi * radius ** 2
+    num = int(area * density)
+    phi_list = np.arccos([clamp(-1 + (2.0 * _ - 1.0) / num, -1, 1) for _ in range(num)])
+    theta_list = np.sqrt(num * np.pi) * phi_list
+    x_array = radius * np.sin(phi_list) * np.cos(theta_list)
+    y_array = radius * np.sin(phi_list) * np.sin(theta_list)
+    z_array = radius * np.cos(phi_list)
+    return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,8),l=[t];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(h,[["render",k]]);export{o as __pageData,F as default}; diff --git a/assets/ja_api_presets_model_index.md.D4BAOCXn.lean.js b/assets/ja_api_presets_model_index.md.D4BAOCXn.lean.js new file mode 100644 index 0000000..c43a674 --- /dev/null +++ b/assets/ja_api_presets_model_index.md.D4BAOCXn.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"ja/api/presets/model/index.md","filePath":"ja/api/presets/model/index.md"}'),h={name:"ja/api/presets/model/index.md"},t=n("",8),l=[t];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(h,[["render",k]]);export{o as __pageData,F as default}; diff --git a/en/api/index.html b/en/api/index.html new file mode 100644 index 0000000..e1295bd --- /dev/null +++ b/en/api/index.html @@ -0,0 +1,24 @@ + + + + + + mbcp | MBCP docs + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/en/api/mp_math/angle.html b/en/api/mp_math/angle.html new file mode 100644 index 0000000..73ec6fa --- /dev/null +++ b/en/api/mp_math/angle.html @@ -0,0 +1,124 @@ + + + + + + mbcp.mp_math.angle | MBCP docs + + + + + + + + + + + + + +
Skip to content

class Angle

class AnyAngle

  • def __init__(self, value: float, is_radian: bool = False)

任意角度。

Args:

value: 角度或弧度值

is_radian: 是否为弧度,默认为否

Source code
python
def __init__(self, value: float, is_radian: bool=False):
+    """
+        任意角度。
+        Args:
+            value: 角度或弧度值
+            is_radian: 是否为弧度,默认为否
+        """
+    if is_radian:
+        self.radian = value
+    else:
+        self.radian = value * PI / 180
  • @property

  • def complementary(self)

余角:两角的和为90°。

Return:

余角

Source code
python
@property
+def complementary(self) -> 'AnyAngle':
+    """
+        余角:两角的和为90°。
+        Returns:
+            余角
+        """
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)
  • @property

  • def supplementary(self)

补角:两角的和为180°。

Return:

补角

Source code
python
@property
+def supplementary(self) -> 'AnyAngle':
+    """
+        补角:两角的和为180°。
+        Returns:
+            补角
+        """
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)
  • @property

  • def degree(self)

角度。

Return:

弧度

Source code
python
@property
+def degree(self) -> float:
+    """
+        角度。
+        Returns:
+            弧度
+        """
+    return self.radian * 180 / PI
  • @property

  • def minimum_positive(self)

最小正角。

Return:

最小正角度

Source code
python
@property
+def minimum_positive(self) -> 'AnyAngle':
+    """
+        最小正角。
+        Returns:
+            最小正角度
+        """
+    return AnyAngle(self.radian % (2 * PI))
  • @property

  • def maximum_negative(self)

最大负角。

Return:

最大负角度

Source code
python
@property
+def maximum_negative(self) -> 'AnyAngle':
+    """
+        最大负角。
+        Returns:
+            最大负角度
+        """
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)
  • @property

  • def sin(self)

正弦值。

Return:

正弦值

Source code
python
@property
+def sin(self) -> float:
+    """
+        正弦值。
+        Returns:
+            正弦值
+        """
+    return math.sin(self.radian)
  • @property

  • def cos(self)

余弦值。

Return:

余弦值

Source code
python
@property
+def cos(self) -> float:
+    """
+        余弦值。
+        Returns:
+            余弦值
+        """
+    return math.cos(self.radian)
  • @property

  • def tan(self)

正切值。

Return:

正切值

Source code
python
@property
+def tan(self) -> float:
+    """
+        正切值。
+        Returns:
+            正切值
+        """
+    return math.tan(self.radian)
  • @property

  • def cot(self)

余切值。

Return:

余切值

Source code
python
@property
+def cot(self) -> float:
+    """
+        余切值。
+        Returns:
+            余切值
+        """
+    return 1 / math.tan(self.radian)
  • @property

  • def sec(self)

正割值。

Return:

正割值

Source code
python
@property
+def sec(self) -> float:
+    """
+        正割值。
+        Returns:
+            正割值
+        """
+    return 1 / math.cos(self.radian)
  • @property

  • def csc(self)

余割值。

Return:

余割值

Source code
python
@property
+def csc(self) -> float:
+    """
+        余割值。
+        Returns:
+            余割值
+        """
+    return 1 / math.sin(self.radian)
  • def __add__(self, other: 'AnyAngle')

Source code
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)
  • def __eq__(self, other)

Source code
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)
  • def __sub__(self, other: 'AnyAngle')

Source code
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)
  • def __mul__(self, other: float)

Source code
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)
Source code
python
def __repr__(self):
+    return f'AnyAngle({self.radian}, is_radian=True)'
Source code
python
def __str__(self):
+    return f'AnyAngle({self.degree}° or {self.radian} rad)'
  • @overload

  • def __truediv__(self, other: float)

Source code
python
@overload
+def __truediv__(self, other: float) -> 'AnyAngle':
+    ...
  • @overload

  • def __truediv__(self, other: 'AnyAngle')

Source code
python
@overload
+def __truediv__(self, other: 'AnyAngle') -> float:
+    ...
  • def __truediv__(self, other)

Source code
python
def __truediv__(self, other):
+    if isinstance(other, AnyAngle):
+        return self.radian / other.radian
+    return AnyAngle(self.radian / other, is_radian=True)
+ + + + \ No newline at end of file diff --git a/en/api/mp_math/const.html b/en/api/mp_math/const.html new file mode 100644 index 0000000..36f5882 --- /dev/null +++ b/en/api/mp_math/const.html @@ -0,0 +1,24 @@ + + + + + + mbcp.mp_math.const | MBCP docs + + + + + + + + + + + + + +
Skip to content

var PI = math.pi

var E = math.e

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

var GAMMA = 0.5772156649015329

var EPSILON = 0.0001

var APPROX = 0.001

+ + + + \ No newline at end of file diff --git a/en/api/mp_math/equation.html b/en/api/mp_math/equation.html new file mode 100644 index 0000000..2f8c0bc --- /dev/null +++ b/en/api/mp_math/equation.html @@ -0,0 +1,86 @@ + + + + + + mbcp.mp_math.equation | MBCP docs + + + + + + + + + + + + + +
Skip to content

var result_func = get_partial_derivative_func(result_func, v, epsilon)

def get_partial_derivative_func(func: MultiVarsFunc = EPSILON)

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

Args:

func: 函数

var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

epsilon: 偏移量

Source code
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+    """
+    求N元函数一阶偏导函数。这玩意不太稳定,慎用。
+    Args:
+        func: 函数
+        var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
+        epsilon: 偏移量
+    Returns:
+        偏导函数
+    Raises:
+        ValueError: 无效变量类型
+    """
+    if isinstance(var, int):
+
+        def partial_derivative_func(*args: Var) -> Var:
+            args_list_plus = list(args)
+            args_list_plus[var] += epsilon
+            args_list_minus = list(args)
+            args_list_minus[var] -= epsilon
+            return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)
+        return partial_derivative_func
+    elif isinstance(var, tuple):
+
+        def high_order_partial_derivative_func(*args: Var) -> Var:
+            result_func = func
+            for v in var:
+                result_func = get_partial_derivative_func(result_func, v, epsilon)
+            return result_func(*args)
+        return high_order_partial_derivative_func
+    else:
+        raise ValueError('Invalid var type')

def partial_derivative_func()

Source code
python
def partial_derivative_func(*args: Var) -> Var:
+    args_list_plus = list(args)
+    args_list_plus[var] += epsilon
+    args_list_minus = list(args)
+    args_list_minus[var] -= epsilon
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

def high_order_partial_derivative_func()

Source code
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    result_func = func
+    for v in var:
+        result_func = get_partial_derivative_func(result_func, v, epsilon)
+    return result_func(*args)

class CurveEquation

  • def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

Args:

x_func: x函数

y_func: y函数

z_func: z函数

Source code
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    """
+        曲线方程。
+        Args:
+            x_func: x函数
+            y_func: y函数
+            z_func: z函数
+        """
+    self.x_func = x_func
+    self.y_func = y_func
+    self.z_func = z_func
  • def __call__(self)

计算曲线上的点。

Args:

*t:

参数:

Source code
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    """
+        计算曲线上的点。
+        Args:
+            *t:
+                参数
+        Returns:
+
+        """
+    if len(t) == 1:
+        return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
+    else:
+        return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
Source code
python
def __str__(self):
+    return 'CurveEquation()'
+ + + + \ No newline at end of file diff --git a/en/api/mp_math/index.html b/en/api/mp_math/index.html new file mode 100644 index 0000000..66ade17 --- /dev/null +++ b/en/api/mp_math/index.html @@ -0,0 +1,24 @@ + + + + + + mbcp.mp_math | MBCP docs + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/en/api/mp_math/line.html b/en/api/mp_math/line.html new file mode 100644 index 0000000..a7b9148 --- /dev/null +++ b/en/api/mp_math/line.html @@ -0,0 +1,215 @@ + + + + + + mbcp.mp_math.line | MBCP docs + + + + + + + + + + + + + +
Skip to content

class Line3

  • def __init__(self, point: 'Point3', direction: 'Vector3')

三维空间中的直线。由一个点和一个方向向量确定。

Args:

point: 直线上的一点

direction: 直线的方向向量

Source code
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    """
+        三维空间中的直线。由一个点和一个方向向量确定。
+        Args:
+            point: 直线上的一点
+            direction: 直线的方向向量
+        """
+    self.point = point
+    self.direction = direction
  • def approx(self, other: 'Line3', epsilon: float = APPROX)

判断两条直线是否近似相等。

Args:

other: 另一条直线

epsilon: 误差

Source code
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    """
+        判断两条直线是否近似相等。
+        Args:
+            other: 另一条直线
+            epsilon: 误差
+        Returns:
+            是否近似相等
+        """
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)
  • def cal_angle(self, other: 'Line3')

计算直线和直线之间的夹角。

Args:

other: 另一条直线

Source code
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    """
+        计算直线和直线之间的夹角。
+        Args:
+            other: 另一条直线
+        Returns:
+            夹角弧度
+        Raises:
+            TypeError: 不支持的类型
+        """
+    return self.direction.cal_angle(other.direction)
  • def cal_distance(self, other: 'Line3 | Point3')

计算直线和直线或点之间的距离。

Args:

other: 平行直线或点

Source code
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    """
+        计算直线和直线或点之间的距离。
+        Args:
+            other: 平行直线或点
+
+        Returns:
+            距离
+        Raises:
+            TypeError: 不支持的类型
+        """
+    if isinstance(other, Line3):
+        if self == other:
+            return 0
+        elif self.is_parallel(other):
+            return (other.point - self.point).cross(self.direction).length / self.direction.length
+        elif not self.is_coplanar(other):
+            return abs(self.direction.cross(other.direction) @ (self.point - other.point) / self.direction.cross(other.direction).length)
+        else:
+            return 0
+    elif isinstance(other, Point3):
+        return (other - self.point).cross(self.direction).length / self.direction.length
+    else:
+        raise TypeError('Unsupported type.')
  • def cal_intersection(self, other: 'Line3')

计算两条直线的交点。

Args:

other: 另一条直线

Source code
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+    """
+        计算两条直线的交点。
+        Args:
+            other: 另一条直线
+        Returns:
+            交点
+        Raises:
+            ValueError: 直线平行
+            ValueError: 直线不共面
+        """
+    if self.is_parallel(other):
+        raise ValueError('Lines are parallel and do not intersect.')
+    if not self.is_coplanar(other):
+        raise ValueError('Lines are not coplanar and do not intersect.')
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction
  • def cal_perpendicular(self, point: 'Point3')

计算直线经过指定点p的垂线。

Args:

point: 指定点

Source code
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    """
+        计算直线经过指定点p的垂线。
+        Args:
+            point: 指定点
+        Returns:
+            垂线
+        """
+    return Line3(point, self.direction.cross(point - self.point))
  • def get_point(self, t: RealNumber)

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

Args:

t: 参数t

Source code
python
def get_point(self, t: RealNumber) -> 'Point3':
+    """
+        获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
+        Args:
+            t: 参数t
+        Returns:
+
+        """
+    return self.point + t * self.direction
  • def get_parametric_equations(self)

获取直线的参数方程。

Return:

x(t), y(t), z(t)

Source code
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    """
+        获取直线的参数方程。
+        Returns:
+            x(t), y(t), z(t)
+        """
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)
  • def is_approx_parallel(self, other: 'Line3', epsilon: float = 1e-06)

判断两条直线是否近似平行。

Args:

other: 另一条直线

epsilon: 误差

Source code
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    """
+        判断两条直线是否近似平行。
+        Args:
+            other: 另一条直线
+            epsilon: 误差
+        Returns:
+            是否近似平行
+        """
+    return self.direction.is_approx_parallel(other.direction, epsilon)
  • def is_parallel(self, other: 'Line3')

判断两条直线是否平行。

Args:

other: 另一条直线

Source code
python
def is_parallel(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否平行。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否平行
+        """
+    return self.direction.is_parallel(other.direction)
  • def is_collinear(self, other: 'Line3')

判断两条直线是否共线。

Args:

other: 另一条直线

Source code
python
def is_collinear(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否共线。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否共线
+        """
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)
  • def is_point_on(self, point: 'Point3')

判断点是否在直线上。

Args:

point: 点

Source code
python
def is_point_on(self, point: 'Point3') -> bool:
+    """
+        判断点是否在直线上。
+        Args:
+            point: 点
+        Returns:
+            是否在直线上
+        """
+    return (point - self.point).is_parallel(self.direction)
  • def is_coplanar(self, other: 'Line3')

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

Args:

other: 另一条直线

Source code
python
def is_coplanar(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否共面。
+        充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否共面
+        """
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0
  • def simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

Source code
python
def simplify(self):
+    """
+        简化直线方程,等价相等。
+        自体简化,不返回值。
+
+        按照可行性一次对x y z 化 0 处理,并对向量单位化
+        """
+    self.direction.normalize()
+    if self.direction.x == 0:
+        self.point.x = 0
+    if self.direction.y == 0:
+        self.point.y = 0
+    if self.direction.z == 0:
+        self.point.z = 0
  • @classmethod

  • def from_two_points(cls, p1: 'Point3', p2: 'Point3')

工厂函数 由两点构造直线。

Args:

p1: 点1

p2: 点2

Source code
python
@classmethod
+def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
+    """
+        工厂函数 由两点构造直线。
+        Args:
+            p1: 点1
+            p2: 点2
+        Returns:
+            直线
+        """
+    direction = p2 - p1
+    return cls(p1, direction)
  • def __and__(self, other: 'Line3')

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

Args:

other: 另一条直线

Source code
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    """
+        计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
+        Args:
+            other: 另一条直线
+        Returns:
+            交点
+        """
+    if self.is_collinear(other):
+        return self
+    elif self.is_parallel(other) or not self.is_coplanar(other):
+        return None
+    else:
+        return self.cal_intersection(other)
  • def __eq__(self, other)

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

Args:

other:

Source code
python
def __eq__(self, other) -> bool:
+    """
+        判断两条直线是否等价。
+
+        v1 // v2 ∧ (p1 - p2) // v1
+        Args:
+            other:
+
+        Returns:
+
+        """
+    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
Source code
python
def __str__(self):
+    """
+        返回点向式(x-x0)
+        Returns:
+
+        """
+    s = 'Line3: '
+    if self.direction.x != 0:
+        s += f'(x{sign_format(-self.point.x)})/{self.direction.x}'
+    if self.direction.y != 0:
+        s += f' = (y{sign_format(-self.point.y)})/{self.direction.y}'
+    if self.direction.z != 0:
+        s += f' = (z{sign_format(-self.point.z)})/{self.direction.z}'
+    return s
Source code
python
def __repr__(self):
+    return f'Line3({self.point}, {self.direction})'
+ + + + \ No newline at end of file diff --git a/en/api/mp_math/mp_math_typing.html b/en/api/mp_math/mp_math_typing.html new file mode 100644 index 0000000..da44311 --- /dev/null +++ b/en/api/mp_math/mp_math_typing.html @@ -0,0 +1,24 @@ + + + + + + mbcp.mp_math.mp_math_typing | MBCP docs + + + + + + + + + + + + + +
Skip to content

var RealNumber: TypeAlias = int | float

var Number: TypeAlias = RealNumber | complex

var SingleVar = TypeVar('SingleVar', bound=Number)

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

var Var: TypeAlias = SingleVar | ArrayVar

var OneSingleVarFunc: TypeAlias = Callable[[SingleVar], SingleVar]

var OneArrayFunc: TypeAlias = Callable[[ArrayVar], ArrayVar]

var OneVarFunc: TypeAlias = OneSingleVarFunc | OneArrayFunc

var TwoSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar], SingleVar]

var TwoArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar], ArrayVar]

var TwoVarsFunc: TypeAlias = TwoSingleVarsFunc | TwoArraysFunc

var ThreeSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar, SingleVar], SingleVar]

var ThreeArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar, ArrayVar], ArrayVar]

var ThreeVarsFunc: TypeAlias = ThreeSingleVarsFunc | ThreeArraysFunc

var MultiSingleVarsFunc: TypeAlias = Callable[..., SingleVar]

var MultiArraysFunc: TypeAlias = Callable[..., ArrayVar]

var MultiVarsFunc: TypeAlias = MultiSingleVarsFunc | MultiArraysFunc

+ + + + \ No newline at end of file diff --git a/en/api/mp_math/plane.html b/en/api/mp_math/plane.html new file mode 100644 index 0000000..5546560 --- /dev/null +++ b/en/api/mp_math/plane.html @@ -0,0 +1,231 @@ + + + + + + mbcp.mp_math.plane | MBCP docs + + + + + + + + + + + + + +
Skip to content

var k = other.a / self.a

var A = np.array([[self.b, self.c], [other.b, other.c]])

var B = np.array([-self.d, -other.d])

var v2 = l2.get_point(1) - l1.point

var k = other.b / self.b

var A = np.array([[self.a, self.c], [other.a, other.c]])

var B = np.array([-self.d, -other.d])

var k = other.c / self.c

var A = np.array([[self.a, self.b], [other.a, other.b]])

var B = np.array([-self.d, -other.d])

class Plane3

  • def __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

Args:

a:

b:

c:

d:

Source code
python
def __init__(self, a: float, b: float, c: float, d: float):
+    """
+        平面方程:ax + by + cz + d = 0
+        Args:
+            a:
+            b:
+            c:
+            d:
+        """
+    self.a = a
+    self.b = b
+    self.c = c
+    self.d = d
  • def approx(self, other: 'Plane3')

判断两个平面是否近似相等。

Args:

other:

Source code
python
def approx(self, other: 'Plane3') -> bool:
+    """
+        判断两个平面是否近似相等。
+        Args:
+            other:
+
+        Returns:
+            是否近似相等
+        """
+    if self.a != 0:
+        k = other.a / self.a
+        return approx(other.b, self.b * k) and approx(other.c, self.c * k) and approx(other.d, self.d * k)
+    elif self.b != 0:
+        k = other.b / self.b
+        return approx(other.a, self.a * k) and approx(other.c, self.c * k) and approx(other.d, self.d * k)
+    elif self.c != 0:
+        k = other.c / self.c
+        return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
+    else:
+        return False
  • def cal_angle(self, other: 'Line3 | Plane3')

计算平面与平面之间的夹角。

Args:

other: 另一个平面

Source code
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+    """
+        计算平面与平面之间的夹角。
+        Args:
+            other: 另一个平面
+        Returns:
+            夹角弧度
+        Raises:
+            TypeError: 不支持的类型
+        """
+    if isinstance(other, Line3):
+        return self.normal.cal_angle(other.direction).complementary
+    elif isinstance(other, Plane3):
+        return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
+    else:
+        raise TypeError(f'Unsupported type: {type(other)}')
  • def cal_distance(self, other: 'Plane3 | Point3')

计算平面与平面或点之间的距离。

Args:

other: 另一个平面或点

Source code
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+    """
+        计算平面与平面或点之间的距离。
+        Args:
+            other: 另一个平面或点
+        Returns:
+            距离
+        Raises:
+            TypeError: 不支持的类型
+        """
+    if isinstance(other, Plane3):
+        return 0
+    elif isinstance(other, Point3):
+        return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
+    else:
+        raise TypeError(f'Unsupported type: {type(other)}')
  • def cal_intersection_line3(self, other: 'Plane3')

计算两平面的交线。该方法有问题,待修复。

Args:

other: 另一个平面

Source code
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+    """
+        计算两平面的交线。该方法有问题,待修复。
+        Args:
+            other: 另一个平面
+        Returns:
+            交线
+        Raises:
+        """
+    if self.normal.is_parallel(other.normal):
+        raise ValueError('Planes are parallel and have no intersection.')
+    direction = self.normal.cross(other.normal)
+    x, y, z = (0, 0, 0)
+    if self.a != 0 and other.a != 0:
+        A = np.array([[self.b, self.c], [other.b, other.c]])
+        B = np.array([-self.d, -other.d])
+        y, z = np.linalg.solve(A, B)
+    elif self.b != 0 and other.b != 0:
+        A = np.array([[self.a, self.c], [other.a, other.c]])
+        B = np.array([-self.d, -other.d])
+        x, z = np.linalg.solve(A, B)
+    elif self.c != 0 and other.c != 0:
+        A = np.array([[self.a, self.b], [other.a, other.b]])
+        B = np.array([-self.d, -other.d])
+        x, y = np.linalg.solve(A, B)
+    return Line3(Point3(x, y, z), direction)
  • def cal_intersection_point3(self, other: 'Line3')

计算平面与直线的交点。

Args:

other: 不与平面平行或在平面上的直线

Source code
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    """
+        计算平面与直线的交点。
+        Args:
+            other: 不与平面平行或在平面上的直线
+        Returns:
+            交点
+        Raises:
+            ValueError: 平面与直线平行或重合
+        """
+    if self.normal @ other.direction == 0:
+        raise ValueError('The plane and the line are parallel or coincident.')
+    x, y, z = other.get_parametric_equations()
+    t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
+    return Point3(x(t), y(t), z(t))
  • def cal_parallel_plane3(self, point: 'Point3')

计算平行于该平面且过指定点的平面。

Args:

point: 指定点

Source code
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    """
+        计算平行于该平面且过指定点的平面。
+        Args:
+            point: 指定点
+        Returns:
+            平面
+        """
+    return Plane3.from_point_and_normal(point, self.normal)
  • def is_parallel(self, other: 'Plane3')

判断两个平面是否平行。

Args:

other: 另一个平面

Source code
python
def is_parallel(self, other: 'Plane3') -> bool:
+    """
+        判断两个平面是否平行。
+        Args:
+            other: 另一个平面
+        Returns:
+            是否平行
+        """
+    return self.normal.is_parallel(other.normal)
  • @property

  • def normal(self)

平面的法向量。

Return:

法向量

Source code
python
@property
+def normal(self) -> 'Vector3':
+    """
+        平面的法向量。
+        Returns:
+            法向量
+        """
+    return Vector3(self.a, self.b, self.c)
  • @classmethod

  • def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3')

工厂函数 由点和法向量构造平面(点法式构造)。

Args:

point: 平面上的一点

normal: 法向量

Source code
python
@classmethod
+def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
+    """
+        工厂函数 由点和法向量构造平面(点法式构造)。
+        Args:
+            point: 平面上的一点
+            normal: 法向量
+        Returns:
+            平面
+        """
+    a, b, c = (normal.x, normal.y, normal.z)
+    d = -a * point.x - b * point.y - c * point.z
+    return cls(a, b, c, d)
  • @classmethod

  • def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3')

工厂函数 由三点构造平面。

Args:

p1: 点1

p2: 点2

p3: 点3

Source code
python
@classmethod
+def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
+    """
+        工厂函数 由三点构造平面。
+        Args:
+            p1: 点1
+            p2: 点2
+            p3: 点3
+        Returns:
+            平面
+        """
+    v1 = p2 - p1
+    v2 = p3 - p1
+    normal = v1.cross(v2)
+    return cls.from_point_and_normal(p1, normal)
  • @classmethod

  • def from_two_lines(cls, l1: 'Line3', l2: 'Line3')

工厂函数 由两直线构造平面。

Args:

l1: 直线1

l2: 直线2

Source code
python
@classmethod
+def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
+    """
+        工厂函数 由两直线构造平面。
+        Args:
+            l1: 直线1
+            l2: 直线2
+        Returns:
+            平面
+        """
+    v1 = l1.direction
+    v2 = l2.point - l1.point
+    if v2 == zero_vector3:
+        v2 = l2.get_point(1) - l1.point
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))
  • @classmethod

  • def from_point_and_line(cls, point: 'Point3', line: 'Line3')

工厂函数 由点和直线构造平面。

Args:

point: 面上一点

line: 面上直线,不包含点

Source code
python
@classmethod
+def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
+    """
+        工厂函数 由点和直线构造平面。
+        Args:
+            point: 面上一点
+            line: 面上直线,不包含点
+        Returns:
+            平面
+        """
+    return cls.from_point_and_normal(point, line.direction)
Source code
python
def __repr__(self):
+    return f'Plane3({self.a}, {self.b}, {self.c}, {self.d})'
Source code
python
def __str__(self):
+    s = 'Plane3: '
+    if self.a != 0:
+        s += f'{sign(self.a, only_neg=True)}{abs(self.a)}x'
+    if self.b != 0:
+        s += f' {sign(self.b)} {abs(self.b)}y'
+    if self.c != 0:
+        s += f' {sign(self.c)} {abs(self.c)}z'
+    if self.d != 0:
+        s += f' {sign(self.d)} {abs(self.d)}'
+    return s + ' = 0'
  • @overload

  • def __and__(self, other: 'Line3')

Source code
python
@overload
+def __and__(self, other: 'Line3') -> 'Point3 | None':
+    ...
  • @overload

  • def __and__(self, other: 'Plane3')

Source code
python
@overload
+def __and__(self, other: 'Plane3') -> 'Line3 | None':
+    ...
  • def __and__(self, other)

取两平面的交集(人话:交线)

Args:

other:

Source code
python
def __and__(self, other):
+    """
+        取两平面的交集(人话:交线)
+        Args:
+            other:
+        Returns:
+            不平行平面的交线,平面平行返回None
+        """
+    if isinstance(other, Plane3):
+        if self.normal.is_parallel(other.normal):
+            return None
+        return self.cal_intersection_line3(other)
+    elif isinstance(other, Line3):
+        if self.normal @ other.direction == 0:
+            return None
+        return self.cal_intersection_point3(other)
+    else:
+        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")
  • def __eq__(self, other)

Source code
python
def __eq__(self, other) -> bool:
+    return self.approx(other)
  • def __rand__(self, other: 'Line3')

Source code
python
def __rand__(self, other: 'Line3') -> 'Point3':
+    return self.cal_intersection_point3(other)
+ + + + \ No newline at end of file diff --git a/en/api/mp_math/point.html b/en/api/mp_math/point.html new file mode 100644 index 0000000..d3c2674 --- /dev/null +++ b/en/api/mp_math/point.html @@ -0,0 +1,64 @@ + + + + + + mbcp.mp_math.point | MBCP docs + + + + + + + + + + + + + +
Skip to content

class Point3

  • def __init__(self, x: float, y: float, z: float)

笛卡尔坐标系中的点。

Args:

x: x 坐标

y: y 坐标

z: z 坐标

Source code
python
def __init__(self, x: float, y: float, z: float):
+    """
+        笛卡尔坐标系中的点。
+        Args:
+            x: x 坐标
+            y: y 坐标
+            z: z 坐标
+        """
+    self.x = x
+    self.y = y
+    self.z = z
  • def approx(self, other: 'Point3', epsilon: float = APPROX)

判断两个点是否近似相等。

Args:

other:

epsilon:

Source code
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个点是否近似相等。
+        Args:
+            other:
+            epsilon:
+
+        Returns:
+            是否近似相等
+        """
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
Source code
python
def __str__(self):
+    return f'Point3({self.x}, {self.y}, {self.z})'
  • @overload

  • def __add__(self, other: 'Vector3')

Source code
python
@overload
+def __add__(self, other: 'Vector3') -> 'Point3':
+    ...
  • @overload

  • def __add__(self, other: 'Point3')

Source code
python
@overload
+def __add__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __add__(self, other)

P + V -> P P + P -> P

Args:

other:

Source code
python
def __add__(self, other):
+    """
+        P + V -> P
+        P + P -> P
+        Args:
+            other:
+        Returns:
+        """
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
  • def __eq__(self, other)

判断两个点是否相等。

Args:

other:

Source code
python
def __eq__(self, other):
+    """
+        判断两个点是否相等。
+        Args:
+            other:
+        Returns:
+        """
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)
+ + + + \ No newline at end of file diff --git a/en/api/mp_math/segment.html b/en/api/mp_math/segment.html new file mode 100644 index 0000000..128ade9 --- /dev/null +++ b/en/api/mp_math/segment.html @@ -0,0 +1,39 @@ + + + + + + mbcp.mp_math.segment | MBCP docs + + + + + + + + + + + + + +
Skip to content

class Segment3

  • def __init__(self, p1: 'Point3', p2: 'Point3')

三维空间中的线段。 :param p1: :param p2:

Source code
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+    """
+        三维空间中的线段。
+        :param p1:
+        :param p2:
+        """
+    self.p1 = p1
+    self.p2 = p2
+    '方向向量'
+    self.direction = self.p2 - self.p1
+    '长度'
+    self.length = self.direction.length
+    '中心点'
+    self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
Source code
python
def __repr__(self):
+    return f'Segment3({self.p1}, {self.p2})'
Source code
python
def __str__(self):
+    return f'Segment3({self.p1} -> {self.p2})'
+ + + + \ No newline at end of file diff --git a/en/api/mp_math/utils.html b/en/api/mp_math/utils.html new file mode 100644 index 0000000..fe684e7 --- /dev/null +++ b/en/api/mp_math/utils.html @@ -0,0 +1,88 @@ + + + + + + mbcp.mp_math.utils | MBCP docs + + + + + + + + + + + + + +
Skip to content

def clamp()

区间截断函数。

Args:

x:

min_:

max_:

Source code
python
def clamp(x: float, min_: float, max_: float) -> float:
+    """
+    区间截断函数。
+    Args:
+        x:
+        min_:
+        max_:
+
+    Returns:
+        限制后的值
+    """
+    return max(min(x, max_), min_)

def approx(x: float = 0.0, y: float = APPROX)

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

Args:

x:

y:

epsilon:

Source code
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    """
+    判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
+    Args:
+        x:
+        y:
+        epsilon:
+
+    Returns:
+        是否近似相等
+    """
+    return abs(x - y) < epsilon

def sign(x: float = False)

获取数的符号。

Args:

x: 数

only_neg: 是否只返回负数的符号

Source code
python
def sign(x: float, only_neg: bool=False) -> str:
+    """获取数的符号。
+    Args:
+        x: 数
+        only_neg: 是否只返回负数的符号
+    Returns:
+        符号 + - ""
+    """
+    if x > 0:
+        return '+' if not only_neg else ''
+    elif x < 0:
+        return '-'
+    else:
+        return ''

def sign_format(x: float = False)

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

Args:

x: 数

only_neg: 是否只返回负数的符号

Source code
python
def sign_format(x: float, only_neg: bool=False) -> str:
+    """格式化符号数
+    -1 -> -1
+    1 -> +1
+    0 -> ""
+    Args:
+        x: 数
+        only_neg: 是否只返回负数的符号
+    Returns:
+        符号 + - ""
+    """
+    if x > 0:
+        return f'+{x}' if not only_neg else f'{x}'
+    elif x < 0:
+        return f'-{abs(x)}'
+    else:
+        return ''

class Approx

  • def __init__(self, value: RealNumber)

Source code
python
def __init__(self, value: RealNumber):
+    self.value = value
  • def __eq__(self, other)

Source code
python
def __eq__(self, other):
+    if isinstance(self.value, (float, int)):
+        if isinstance(other, (float, int)):
+            return abs(self.value - other) < APPROX
+        else:
+            self.raise_type_error(other)
+    elif isinstance(self.value, Vector3):
+        if isinstance(other, (Vector3, Point3, Plane3, Line3)):
+            return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
+        else:
+            self.raise_type_error(other)
  • def raise_type_error(self, other)

Source code
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')
  • def __ne__(self, other)

Source code
python
def __ne__(self, other):
+    return not self.__eq__(other)
+ + + + \ No newline at end of file diff --git a/en/api/mp_math/vector.html b/en/api/mp_math/vector.html new file mode 100644 index 0000000..1650a99 --- /dev/null +++ b/en/api/mp_math/vector.html @@ -0,0 +1,212 @@ + + + + + + mbcp.mp_math.vector | MBCP docs + + + + + + + + + + + + + +
Skip to content

var zero_vector3 = Vector3(0, 0, 0)

var x_axis = Vector3(1, 0, 0)

var y_axis = Vector3(0, 1, 0)

var z_axis = Vector3(0, 0, 1)

class Vector3

  • def __init__(self, x: float, y: float, z: float)

3维向量

Args:

x: x轴分量

y: y轴分量

z: z轴分量

Source code
python
def __init__(self, x: float, y: float, z: float):
+    """
+        3维向量
+        Args:
+            x: x轴分量
+            y: y轴分量
+            z: z轴分量
+        """
+    self.x = x
+    self.y = y
+    self.z = z
  • def approx(self, other: 'Vector3', epsilon: float = APPROX)

判断两个向量是否近似相等。

Args:

other:

epsilon:

Source code
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个向量是否近似相等。
+        Args:
+            other:
+            epsilon:
+
+        Returns:
+            是否近似相等
+        """
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
  • def cal_angle(self, other: 'Vector3')

计算两个向量之间的夹角。

Args:

other: 另一个向量

Source code
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    """
+        计算两个向量之间的夹角。
+        Args:
+            other: 另一个向量
+        Returns:
+            夹角
+        """
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)
  • def cross(self, other: 'Vector3')

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

Source code
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    """
+        向量积 叉乘:v1 cross v2 -> v3
+
+        叉乘为0,则两向量平行。
+        其余结果的模为平行四边形的面积。
+
+        返回如下行列式的结果:
+
+        ``i  j  k``
+
+        ``x1 y1 z1``
+
+        ``x2 y2 z2``
+
+        Args:
+            other:
+        Returns:
+            行列式的结果
+        """
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)
  • def is_approx_parallel(self, other: 'Vector3', epsilon: float = APPROX)

判断两个向量是否近似平行。

Args:

other: 另一个向量

epsilon: 允许的误差

Source code
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个向量是否近似平行。
+        Args:
+            other: 另一个向量
+            epsilon: 允许的误差
+        Returns:
+            是否近似平行
+        """
+    return self.cross(other).length < epsilon
  • def is_parallel(self, other: 'Vector3')

判断两个向量是否平行。

Args:

other: 另一个向量

Source code
python
def is_parallel(self, other: 'Vector3') -> bool:
+    """
+        判断两个向量是否平行。
+        Args:
+            other: 另一个向量
+        Returns:
+            是否平行
+        """
+    return self.cross(other).approx(zero_vector3)
  • def normalize(self)

将向量归一化。

自体归一化,不返回值。

Source code
python
def normalize(self):
+    """
+        将向量归一化。
+
+        自体归一化,不返回值。
+        """
+    length = self.length
+    self.x /= length
+    self.y /= length
+    self.z /= length
Source code
python
@property
+def np_array(self) -> 'np.ndarray':
+    """
+        返回numpy数组
+        Returns:
+        """
+    return np.array([self.x, self.y, self.z])
  • @property

  • def length(self)

向量的模。

Return:

Source code
python
@property
+def length(self) -> float:
+    """
+        向量的模。
+        Returns:
+
+        """
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)
  • @property

  • def unit(self)

获取该向量的单位向量。

Return:

单位向量

Source code
python
@property
+def unit(self) -> 'Vector3':
+    """
+        获取该向量的单位向量。
+        Returns:
+            单位向量
+        """
+    return self / self.length
Source code
python
def __abs__(self):
+    return self.length
  • @overload

  • def __add__(self, other: 'Vector3')

Source code
python
@overload
+def __add__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __add__(self, other: 'Point3')

Source code
python
@overload
+def __add__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __add__(self, other)

V + P -> P

V + V -> V

Args:

other:

Source code
python
def __add__(self, other):
+    """
+        V + P -> P
+
+        V + V -> V
+        Args:
+            other:
+        Returns:
+
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x + other.x, self.y + other.y, self.z + other.z)
+    elif isinstance(other, Point3):
+        return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
+    else:
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")
  • def __eq__(self, other)

判断两个向量是否相等。

Args:

other:

Source code
python
def __eq__(self, other):
+    """
+        判断两个向量是否相等。
+        Args:
+            other:
+        Returns:
+            是否相等
+        """
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)
  • def __radd__(self, other: 'Point3')

P + V -> P

别去点那边实现了。 :param other: :return:

Source code
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    """
+        P + V -> P
+
+        别去点那边实现了。
+        :param other:
+        :return:
+        """
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
  • @overload

  • def __sub__(self, other: 'Vector3')

Source code
python
@overload
+def __sub__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __sub__(self, other: 'Point3')

Source code
python
@overload
+def __sub__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __sub__(self, other)

V - P -> P

V - V -> V

Args:

other:

Source code
python
def __sub__(self, other):
+    """
+        V - P -> P
+
+        V - V -> V
+        Args:
+            other:
+        Returns:
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
+    elif isinstance(other, Point3):
+        return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
+    else:
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')
  • def __rsub__(self, other: 'Point3')

P - V -> P

Args:

other:

Source code
python
def __rsub__(self, other: 'Point3'):
+    """
+        P - V -> P
+        Args:
+            other:
+        Returns:
+
+        """
+    if isinstance(other, Point3):
+        return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
+    else:
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")
  • @overload

  • def __mul__(self, other: 'Vector3')

Source code
python
@overload
+def __mul__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __mul__(self, other: RealNumber)

Source code
python
@overload
+def __mul__(self, other: RealNumber) -> 'Vector3':
+    ...
  • def __mul__(self, other: 'int | float | Vector3')

数组运算 非点乘。点乘使用@,叉乘使用cross。

Args:

other:

Source code
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    """
+        数组运算 非点乘。点乘使用@,叉乘使用cross。
+        Args:
+            other:
+
+        Returns:
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x * other.x, self.y * other.y, self.z * other.z)
+    elif isinstance(other, (float, int)):
+        return Vector3(self.x * other, self.y * other, self.z * other)
+    else:
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")
  • def __rmul__(self, other: 'RealNumber')

Source code
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)
  • def __matmul__(self, other: 'Vector3')

点乘。

Args:

other:

Source code
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+    """
+        点乘。
+        Args:
+            other:
+        Returns:
+        """
+    return self.x * other.x + self.y * other.y + self.z * other.z
  • def __truediv__(self, other: RealNumber)

Source code
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)
Source code
python
def __neg__(self):
+    return Vector3(-self.x, -self.y, -self.z)
Source code
python
def __repr__(self):
+    return f'Vector3({self.x}, {self.y}, {self.z})'
Source code
python
def __str__(self):
+    return f'Vector3({self.x}, {self.y}, {self.z})'
+ + + + \ No newline at end of file diff --git a/en/api/particle/index.html b/en/api/particle/index.html new file mode 100644 index 0000000..26c1b03 --- /dev/null +++ b/en/api/particle/index.html @@ -0,0 +1,24 @@ + + + + + + mbcp.particle | MBCP docs + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/en/api/presets/index.html b/en/api/presets/index.html new file mode 100644 index 0000000..2d54599 --- /dev/null +++ b/en/api/presets/index.html @@ -0,0 +1,24 @@ + + + + + + mbcp.presets | MBCP docs + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/en/api/presets/model/index.html b/en/api/presets/model/index.html new file mode 100644 index 0000000..d476ce7 --- /dev/null +++ b/en/api/presets/model/index.html @@ -0,0 +1,41 @@ + + + + + + mbcp.presets.model | MBCP docs + + + + + + + + + + + + + +
Skip to content

class GeometricModels

  • @staticmethod

  • def sphere(radius: float, density: float)

生成球体上的点集。

Args:

radius:

density:

Source code
python
@staticmethod
+def sphere(radius: float, density: float):
+    """
+        生成球体上的点集。
+        Args:
+            radius:
+            density:
+        Returns:
+            List[Point3]: 球体上的点集。
+        """
+    area = 4 * np.pi * radius ** 2
+    num = int(area * density)
+    phi_list = np.arccos([clamp(-1 + (2.0 * _ - 1.0) / num, -1, 1) for _ in range(num)])
+    theta_list = np.sqrt(num * np.pi) * phi_list
+    x_array = radius * np.sin(phi_list) * np.cos(theta_list)
+    y_array = radius * np.sin(phi_list) * np.sin(theta_list)
+    z_array = radius * np.cos(phi_list)
+    return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
+ + + + \ No newline at end of file diff --git a/hashmap.json b/hashmap.json index 0e11d89..156b8a3 100644 --- a/hashmap.json +++ b/hashmap.json @@ -1 +1 @@ -{"api-ex.md":"DOsKaL8H","api_index.md":"CsKClHFh","api_mp_math_angle.md":"9eUTSIe4","api_mp_math_const.md":"Bhz27OPg","api_mp_math_equation.md":"xiyFVY1c","api_mp_math_index.md":"DTIfeUA1","api_mp_math_line.md":"BybnyRUL","api_mp_math_mp_math_typing.md":"DXaadYgy","api_mp_math_plane.md":"Cdj0PlKB","api_mp_math_point.md":"D3f-vzVt","api_mp_math_segment.md":"DIViBThe","api_mp_math_utils.md":"CDwq4icO","api_mp_math_vector.md":"BgK1TmFY","api_particle_index.md":"BqH-w2FR","api_presets_index.md":"CvgR5vOS","api_presets_model_index.md":"D1iZ1qEr","index.md":"CJvRmMfL","md-ex.md":"BX0WqOqv"} +{"api-ex.md":"DOsKaL8H","api_index.md":"BvazTqTB","api_mp_math_angle.md":"7ZvAVHFT","api_mp_math_const.md":"Bc1LxtcU","api_mp_math_equation.md":"DcgE8elZ","api_mp_math_index.md":"4P0hk6gb","api_mp_math_line.md":"CPz5W_V9","api_mp_math_mp_math_typing.md":"BHJOAxTl","api_mp_math_plane.md":"B7Mh7SKE","api_mp_math_point.md":"BhIb1HeT","api_mp_math_segment.md":"BpLgqrZ6","api_mp_math_utils.md":"BgmONBdf","api_mp_math_vector.md":"BxisUL7s","api_particle_index.md":"BRCSxC3e","api_presets_index.md":"Dl6Ss91J","api_presets_model_index.md":"O3tM1JKS","en_api_index.md":"Bgu-LD1B","en_api_mp_math_angle.md":"Cpkg14Nd","en_api_mp_math_const.md":"DfcWuGeV","en_api_mp_math_equation.md":"BEubflOs","en_api_mp_math_index.md":"DrjDUYBY","en_api_mp_math_line.md":"JAqG1sD6","en_api_mp_math_mp_math_typing.md":"Dh1by9kw","en_api_mp_math_plane.md":"BRPMklJt","en_api_mp_math_point.md":"D_AsGf3x","en_api_mp_math_segment.md":"CRs1-Itg","en_api_mp_math_utils.md":"CoXbSyss","en_api_mp_math_vector.md":"Dk4b7P4S","en_api_particle_index.md":"CmC1QX5o","en_api_presets_index.md":"CZ5hl_7D","en_api_presets_model_index.md":"DD5WCYA0","index.md":"CJvRmMfL","ja_api_index.md":"4BnflFIm","ja_api_mp_math_angle.md":"B0vK-3H7","ja_api_mp_math_const.md":"CQY-Qdbh","ja_api_mp_math_equation.md":"CxOZG3Ck","ja_api_mp_math_index.md":"CSAMHYsB","ja_api_mp_math_line.md":"B_sNS7i2","ja_api_mp_math_mp_math_typing.md":"CeASNaiE","ja_api_mp_math_plane.md":"DoFcs9On","ja_api_mp_math_point.md":"DsWUjRQD","ja_api_mp_math_segment.md":"B3JRHboi","ja_api_mp_math_utils.md":"CMaGJtHQ","ja_api_mp_math_vector.md":"BaQ1gWXc","ja_api_particle_index.md":"E2YnH7EN","ja_api_presets_index.md":"ATGcHt9d","ja_api_presets_model_index.md":"D4BAOCXn","md-ex.md":"BX0WqOqv"} diff --git a/index.html b/index.html index 233f2df..355d7b1 100644 --- a/index.html +++ b/index.html @@ -17,8 +17,8 @@ -
Skip to content

MBCP docs

More basic change particle

用于几何运算和粒子制作的库

- +
Skip to content

MBCP docs

More basic change particle

用于几何运算和粒子制作的库

+ \ No newline at end of file diff --git a/ja/api/index.html b/ja/api/index.html new file mode 100644 index 0000000..5f5fbc1 --- /dev/null +++ b/ja/api/index.html @@ -0,0 +1,24 @@ + + + + + + mbcp | MBCP docs + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ja/api/mp_math/angle.html b/ja/api/mp_math/angle.html new file mode 100644 index 0000000..14a4320 --- /dev/null +++ b/ja/api/mp_math/angle.html @@ -0,0 +1,124 @@ + + + + + + mbcp.mp_math.angle | MBCP docs + + + + + + + + + + + + + +
Skip to content

class Angle

class AnyAngle

  • def __init__(self, value: float, is_radian: bool = False)

任意角度。

引数:

value: 角度或弧度值

is_radian: 是否为弧度,默认为否

ソースコード
python
def __init__(self, value: float, is_radian: bool=False):
+    """
+        任意角度。
+        Args:
+            value: 角度或弧度值
+            is_radian: 是否为弧度,默认为否
+        """
+    if is_radian:
+        self.radian = value
+    else:
+        self.radian = value * PI / 180
  • @property

  • def complementary(self)

余角:两角的和为90°。

戻り値:

余角

ソースコード
python
@property
+def complementary(self) -> 'AnyAngle':
+    """
+        余角:两角的和为90°。
+        Returns:
+            余角
+        """
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)
  • @property

  • def supplementary(self)

补角:两角的和为180°。

戻り値:

补角

ソースコード
python
@property
+def supplementary(self) -> 'AnyAngle':
+    """
+        补角:两角的和为180°。
+        Returns:
+            补角
+        """
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)
  • @property

  • def degree(self)

角度。

戻り値:

弧度

ソースコード
python
@property
+def degree(self) -> float:
+    """
+        角度。
+        Returns:
+            弧度
+        """
+    return self.radian * 180 / PI
  • @property

  • def minimum_positive(self)

最小正角。

戻り値:

最小正角度

ソースコード
python
@property
+def minimum_positive(self) -> 'AnyAngle':
+    """
+        最小正角。
+        Returns:
+            最小正角度
+        """
+    return AnyAngle(self.radian % (2 * PI))
  • @property

  • def maximum_negative(self)

最大负角。

戻り値:

最大负角度

ソースコード
python
@property
+def maximum_negative(self) -> 'AnyAngle':
+    """
+        最大负角。
+        Returns:
+            最大负角度
+        """
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)
  • @property

  • def sin(self)

正弦值。

戻り値:

正弦值

ソースコード
python
@property
+def sin(self) -> float:
+    """
+        正弦值。
+        Returns:
+            正弦值
+        """
+    return math.sin(self.radian)
  • @property

  • def cos(self)

余弦值。

戻り値:

余弦值

ソースコード
python
@property
+def cos(self) -> float:
+    """
+        余弦值。
+        Returns:
+            余弦值
+        """
+    return math.cos(self.radian)
  • @property

  • def tan(self)

正切值。

戻り値:

正切值

ソースコード
python
@property
+def tan(self) -> float:
+    """
+        正切值。
+        Returns:
+            正切值
+        """
+    return math.tan(self.radian)
  • @property

  • def cot(self)

余切值。

戻り値:

余切值

ソースコード
python
@property
+def cot(self) -> float:
+    """
+        余切值。
+        Returns:
+            余切值
+        """
+    return 1 / math.tan(self.radian)
  • @property

  • def sec(self)

正割值。

戻り値:

正割值

ソースコード
python
@property
+def sec(self) -> float:
+    """
+        正割值。
+        Returns:
+            正割值
+        """
+    return 1 / math.cos(self.radian)
  • @property

  • def csc(self)

余割值。

戻り値:

余割值

ソースコード
python
@property
+def csc(self) -> float:
+    """
+        余割值。
+        Returns:
+            余割值
+        """
+    return 1 / math.sin(self.radian)
  • def __add__(self, other: 'AnyAngle')

ソースコード
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)
  • def __eq__(self, other)

ソースコード
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)
  • def __sub__(self, other: 'AnyAngle')

ソースコード
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)
  • def __mul__(self, other: float)

ソースコード
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)
ソースコード
python
def __repr__(self):
+    return f'AnyAngle({self.radian}, is_radian=True)'
ソースコード
python
def __str__(self):
+    return f'AnyAngle({self.degree}° or {self.radian} rad)'
  • @overload

  • def __truediv__(self, other: float)

ソースコード
python
@overload
+def __truediv__(self, other: float) -> 'AnyAngle':
+    ...
  • @overload

  • def __truediv__(self, other: 'AnyAngle')

ソースコード
python
@overload
+def __truediv__(self, other: 'AnyAngle') -> float:
+    ...
  • def __truediv__(self, other)

ソースコード
python
def __truediv__(self, other):
+    if isinstance(other, AnyAngle):
+        return self.radian / other.radian
+    return AnyAngle(self.radian / other, is_radian=True)
+ + + + \ No newline at end of file diff --git a/ja/api/mp_math/const.html b/ja/api/mp_math/const.html new file mode 100644 index 0000000..b21d096 --- /dev/null +++ b/ja/api/mp_math/const.html @@ -0,0 +1,24 @@ + + + + + + mbcp.mp_math.const | MBCP docs + + + + + + + + + + + + + +
Skip to content

var PI = math.pi

var E = math.e

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

var GAMMA = 0.5772156649015329

var EPSILON = 0.0001

var APPROX = 0.001

+ + + + \ No newline at end of file diff --git a/ja/api/mp_math/equation.html b/ja/api/mp_math/equation.html new file mode 100644 index 0000000..2a8d9cc --- /dev/null +++ b/ja/api/mp_math/equation.html @@ -0,0 +1,86 @@ + + + + + + mbcp.mp_math.equation | MBCP docs + + + + + + + + + + + + + +
Skip to content

var result_func = get_partial_derivative_func(result_func, v, epsilon)

def get_partial_derivative_func(func: MultiVarsFunc = EPSILON)

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

引数:

func: 函数

var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

epsilon: 偏移量

ソースコード
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+    """
+    求N元函数一阶偏导函数。这玩意不太稳定,慎用。
+    Args:
+        func: 函数
+        var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
+        epsilon: 偏移量
+    Returns:
+        偏导函数
+    Raises:
+        ValueError: 无效变量类型
+    """
+    if isinstance(var, int):
+
+        def partial_derivative_func(*args: Var) -> Var:
+            args_list_plus = list(args)
+            args_list_plus[var] += epsilon
+            args_list_minus = list(args)
+            args_list_minus[var] -= epsilon
+            return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)
+        return partial_derivative_func
+    elif isinstance(var, tuple):
+
+        def high_order_partial_derivative_func(*args: Var) -> Var:
+            result_func = func
+            for v in var:
+                result_func = get_partial_derivative_func(result_func, v, epsilon)
+            return result_func(*args)
+        return high_order_partial_derivative_func
+    else:
+        raise ValueError('Invalid var type')

def partial_derivative_func()

ソースコード
python
def partial_derivative_func(*args: Var) -> Var:
+    args_list_plus = list(args)
+    args_list_plus[var] += epsilon
+    args_list_minus = list(args)
+    args_list_minus[var] -= epsilon
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

def high_order_partial_derivative_func()

ソースコード
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    result_func = func
+    for v in var:
+        result_func = get_partial_derivative_func(result_func, v, epsilon)
+    return result_func(*args)

class CurveEquation

  • def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

引数:

x_func: x函数

y_func: y函数

z_func: z函数

ソースコード
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    """
+        曲线方程。
+        Args:
+            x_func: x函数
+            y_func: y函数
+            z_func: z函数
+        """
+    self.x_func = x_func
+    self.y_func = y_func
+    self.z_func = z_func
  • def __call__(self)

计算曲线上的点。

引数:

*t:

参数:

ソースコード
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    """
+        计算曲线上的点。
+        Args:
+            *t:
+                参数
+        Returns:
+
+        """
+    if len(t) == 1:
+        return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
+    else:
+        return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
ソースコード
python
def __str__(self):
+    return 'CurveEquation()'
+ + + + \ No newline at end of file diff --git a/ja/api/mp_math/index.html b/ja/api/mp_math/index.html new file mode 100644 index 0000000..b6e2ac9 --- /dev/null +++ b/ja/api/mp_math/index.html @@ -0,0 +1,24 @@ + + + + + + mbcp.mp_math | MBCP docs + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ja/api/mp_math/line.html b/ja/api/mp_math/line.html new file mode 100644 index 0000000..dff5329 --- /dev/null +++ b/ja/api/mp_math/line.html @@ -0,0 +1,215 @@ + + + + + + mbcp.mp_math.line | MBCP docs + + + + + + + + + + + + + +
Skip to content

class Line3

  • def __init__(self, point: 'Point3', direction: 'Vector3')

三维空间中的直线。由一个点和一个方向向量确定。

引数:

point: 直线上的一点

direction: 直线的方向向量

ソースコード
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    """
+        三维空间中的直线。由一个点和一个方向向量确定。
+        Args:
+            point: 直线上的一点
+            direction: 直线的方向向量
+        """
+    self.point = point
+    self.direction = direction
  • def approx(self, other: 'Line3', epsilon: float = APPROX)

判断两条直线是否近似相等。

引数:

other: 另一条直线

epsilon: 误差

ソースコード
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    """
+        判断两条直线是否近似相等。
+        Args:
+            other: 另一条直线
+            epsilon: 误差
+        Returns:
+            是否近似相等
+        """
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)
  • def cal_angle(self, other: 'Line3')

计算直线和直线之间的夹角。

引数:

other: 另一条直线

ソースコード
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    """
+        计算直线和直线之间的夹角。
+        Args:
+            other: 另一条直线
+        Returns:
+            夹角弧度
+        Raises:
+            TypeError: 不支持的类型
+        """
+    return self.direction.cal_angle(other.direction)
  • def cal_distance(self, other: 'Line3 | Point3')

计算直线和直线或点之间的距离。

引数:

other: 平行直线或点

ソースコード
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    """
+        计算直线和直线或点之间的距离。
+        Args:
+            other: 平行直线或点
+
+        Returns:
+            距离
+        Raises:
+            TypeError: 不支持的类型
+        """
+    if isinstance(other, Line3):
+        if self == other:
+            return 0
+        elif self.is_parallel(other):
+            return (other.point - self.point).cross(self.direction).length / self.direction.length
+        elif not self.is_coplanar(other):
+            return abs(self.direction.cross(other.direction) @ (self.point - other.point) / self.direction.cross(other.direction).length)
+        else:
+            return 0
+    elif isinstance(other, Point3):
+        return (other - self.point).cross(self.direction).length / self.direction.length
+    else:
+        raise TypeError('Unsupported type.')
  • def cal_intersection(self, other: 'Line3')

计算两条直线的交点。

引数:

other: 另一条直线

ソースコード
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+    """
+        计算两条直线的交点。
+        Args:
+            other: 另一条直线
+        Returns:
+            交点
+        Raises:
+            ValueError: 直线平行
+            ValueError: 直线不共面
+        """
+    if self.is_parallel(other):
+        raise ValueError('Lines are parallel and do not intersect.')
+    if not self.is_coplanar(other):
+        raise ValueError('Lines are not coplanar and do not intersect.')
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction
  • def cal_perpendicular(self, point: 'Point3')

计算直线经过指定点p的垂线。

引数:

point: 指定点

ソースコード
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    """
+        计算直线经过指定点p的垂线。
+        Args:
+            point: 指定点
+        Returns:
+            垂线
+        """
+    return Line3(point, self.direction.cross(point - self.point))
  • def get_point(self, t: RealNumber)

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

引数:

t: 参数t

ソースコード
python
def get_point(self, t: RealNumber) -> 'Point3':
+    """
+        获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
+        Args:
+            t: 参数t
+        Returns:
+
+        """
+    return self.point + t * self.direction
  • def get_parametric_equations(self)

获取直线的参数方程。

戻り値:

x(t), y(t), z(t)

ソースコード
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    """
+        获取直线的参数方程。
+        Returns:
+            x(t), y(t), z(t)
+        """
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)
  • def is_approx_parallel(self, other: 'Line3', epsilon: float = 1e-06)

判断两条直线是否近似平行。

引数:

other: 另一条直线

epsilon: 误差

ソースコード
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    """
+        判断两条直线是否近似平行。
+        Args:
+            other: 另一条直线
+            epsilon: 误差
+        Returns:
+            是否近似平行
+        """
+    return self.direction.is_approx_parallel(other.direction, epsilon)
  • def is_parallel(self, other: 'Line3')

判断两条直线是否平行。

引数:

other: 另一条直线

ソースコード
python
def is_parallel(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否平行。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否平行
+        """
+    return self.direction.is_parallel(other.direction)
  • def is_collinear(self, other: 'Line3')

判断两条直线是否共线。

引数:

other: 另一条直线

ソースコード
python
def is_collinear(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否共线。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否共线
+        """
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)
  • def is_point_on(self, point: 'Point3')

判断点是否在直线上。

引数:

point: 点

ソースコード
python
def is_point_on(self, point: 'Point3') -> bool:
+    """
+        判断点是否在直线上。
+        Args:
+            point: 点
+        Returns:
+            是否在直线上
+        """
+    return (point - self.point).is_parallel(self.direction)
  • def is_coplanar(self, other: 'Line3')

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

引数:

other: 另一条直线

ソースコード
python
def is_coplanar(self, other: 'Line3') -> bool:
+    """
+        判断两条直线是否共面。
+        充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
+        Args:
+            other: 另一条直线
+        Returns:
+            是否共面
+        """
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0
  • def simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

ソースコード
python
def simplify(self):
+    """
+        简化直线方程,等价相等。
+        自体简化,不返回值。
+
+        按照可行性一次对x y z 化 0 处理,并对向量单位化
+        """
+    self.direction.normalize()
+    if self.direction.x == 0:
+        self.point.x = 0
+    if self.direction.y == 0:
+        self.point.y = 0
+    if self.direction.z == 0:
+        self.point.z = 0
  • @classmethod

  • def from_two_points(cls, p1: 'Point3', p2: 'Point3')

工厂函数 由两点构造直线。

引数:

p1: 点1

p2: 点2

ソースコード
python
@classmethod
+def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
+    """
+        工厂函数 由两点构造直线。
+        Args:
+            p1: 点1
+            p2: 点2
+        Returns:
+            直线
+        """
+    direction = p2 - p1
+    return cls(p1, direction)
  • def __and__(self, other: 'Line3')

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

引数:

other: 另一条直线

ソースコード
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    """
+        计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
+        Args:
+            other: 另一条直线
+        Returns:
+            交点
+        """
+    if self.is_collinear(other):
+        return self
+    elif self.is_parallel(other) or not self.is_coplanar(other):
+        return None
+    else:
+        return self.cal_intersection(other)
  • def __eq__(self, other)

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

引数:

other:

ソースコード
python
def __eq__(self, other) -> bool:
+    """
+        判断两条直线是否等价。
+
+        v1 // v2 ∧ (p1 - p2) // v1
+        Args:
+            other:
+
+        Returns:
+
+        """
+    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
ソースコード
python
def __str__(self):
+    """
+        返回点向式(x-x0)
+        Returns:
+
+        """
+    s = 'Line3: '
+    if self.direction.x != 0:
+        s += f'(x{sign_format(-self.point.x)})/{self.direction.x}'
+    if self.direction.y != 0:
+        s += f' = (y{sign_format(-self.point.y)})/{self.direction.y}'
+    if self.direction.z != 0:
+        s += f' = (z{sign_format(-self.point.z)})/{self.direction.z}'
+    return s
ソースコード
python
def __repr__(self):
+    return f'Line3({self.point}, {self.direction})'
+ + + + \ No newline at end of file diff --git a/ja/api/mp_math/mp_math_typing.html b/ja/api/mp_math/mp_math_typing.html new file mode 100644 index 0000000..cbcd608 --- /dev/null +++ b/ja/api/mp_math/mp_math_typing.html @@ -0,0 +1,24 @@ + + + + + + mbcp.mp_math.mp_math_typing | MBCP docs + + + + + + + + + + + + + +
Skip to content

var RealNumber: TypeAlias = int | float

var Number: TypeAlias = RealNumber | complex

var SingleVar = TypeVar('SingleVar', bound=Number)

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

var Var: TypeAlias = SingleVar | ArrayVar

var OneSingleVarFunc: TypeAlias = Callable[[SingleVar], SingleVar]

var OneArrayFunc: TypeAlias = Callable[[ArrayVar], ArrayVar]

var OneVarFunc: TypeAlias = OneSingleVarFunc | OneArrayFunc

var TwoSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar], SingleVar]

var TwoArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar], ArrayVar]

var TwoVarsFunc: TypeAlias = TwoSingleVarsFunc | TwoArraysFunc

var ThreeSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar, SingleVar], SingleVar]

var ThreeArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar, ArrayVar], ArrayVar]

var ThreeVarsFunc: TypeAlias = ThreeSingleVarsFunc | ThreeArraysFunc

var MultiSingleVarsFunc: TypeAlias = Callable[..., SingleVar]

var MultiArraysFunc: TypeAlias = Callable[..., ArrayVar]

var MultiVarsFunc: TypeAlias = MultiSingleVarsFunc | MultiArraysFunc

+ + + + \ No newline at end of file diff --git a/ja/api/mp_math/plane.html b/ja/api/mp_math/plane.html new file mode 100644 index 0000000..aeda391 --- /dev/null +++ b/ja/api/mp_math/plane.html @@ -0,0 +1,231 @@ + + + + + + mbcp.mp_math.plane | MBCP docs + + + + + + + + + + + + + +
Skip to content

var k = other.a / self.a

var A = np.array([[self.b, self.c], [other.b, other.c]])

var B = np.array([-self.d, -other.d])

var v2 = l2.get_point(1) - l1.point

var k = other.b / self.b

var A = np.array([[self.a, self.c], [other.a, other.c]])

var B = np.array([-self.d, -other.d])

var k = other.c / self.c

var A = np.array([[self.a, self.b], [other.a, other.b]])

var B = np.array([-self.d, -other.d])

class Plane3

  • def __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

引数:

a:

b:

c:

d:

ソースコード
python
def __init__(self, a: float, b: float, c: float, d: float):
+    """
+        平面方程:ax + by + cz + d = 0
+        Args:
+            a:
+            b:
+            c:
+            d:
+        """
+    self.a = a
+    self.b = b
+    self.c = c
+    self.d = d
  • def approx(self, other: 'Plane3')

判断两个平面是否近似相等。

引数:

other:

ソースコード
python
def approx(self, other: 'Plane3') -> bool:
+    """
+        判断两个平面是否近似相等。
+        Args:
+            other:
+
+        Returns:
+            是否近似相等
+        """
+    if self.a != 0:
+        k = other.a / self.a
+        return approx(other.b, self.b * k) and approx(other.c, self.c * k) and approx(other.d, self.d * k)
+    elif self.b != 0:
+        k = other.b / self.b
+        return approx(other.a, self.a * k) and approx(other.c, self.c * k) and approx(other.d, self.d * k)
+    elif self.c != 0:
+        k = other.c / self.c
+        return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
+    else:
+        return False
  • def cal_angle(self, other: 'Line3 | Plane3')

计算平面与平面之间的夹角。

引数:

other: 另一个平面

ソースコード
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+    """
+        计算平面与平面之间的夹角。
+        Args:
+            other: 另一个平面
+        Returns:
+            夹角弧度
+        Raises:
+            TypeError: 不支持的类型
+        """
+    if isinstance(other, Line3):
+        return self.normal.cal_angle(other.direction).complementary
+    elif isinstance(other, Plane3):
+        return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
+    else:
+        raise TypeError(f'Unsupported type: {type(other)}')
  • def cal_distance(self, other: 'Plane3 | Point3')

计算平面与平面或点之间的距离。

引数:

other: 另一个平面或点

ソースコード
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+    """
+        计算平面与平面或点之间的距离。
+        Args:
+            other: 另一个平面或点
+        Returns:
+            距离
+        Raises:
+            TypeError: 不支持的类型
+        """
+    if isinstance(other, Plane3):
+        return 0
+    elif isinstance(other, Point3):
+        return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
+    else:
+        raise TypeError(f'Unsupported type: {type(other)}')
  • def cal_intersection_line3(self, other: 'Plane3')

计算两平面的交线。该方法有问题,待修复。

引数:

other: 另一个平面

ソースコード
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+    """
+        计算两平面的交线。该方法有问题,待修复。
+        Args:
+            other: 另一个平面
+        Returns:
+            交线
+        Raises:
+        """
+    if self.normal.is_parallel(other.normal):
+        raise ValueError('Planes are parallel and have no intersection.')
+    direction = self.normal.cross(other.normal)
+    x, y, z = (0, 0, 0)
+    if self.a != 0 and other.a != 0:
+        A = np.array([[self.b, self.c], [other.b, other.c]])
+        B = np.array([-self.d, -other.d])
+        y, z = np.linalg.solve(A, B)
+    elif self.b != 0 and other.b != 0:
+        A = np.array([[self.a, self.c], [other.a, other.c]])
+        B = np.array([-self.d, -other.d])
+        x, z = np.linalg.solve(A, B)
+    elif self.c != 0 and other.c != 0:
+        A = np.array([[self.a, self.b], [other.a, other.b]])
+        B = np.array([-self.d, -other.d])
+        x, y = np.linalg.solve(A, B)
+    return Line3(Point3(x, y, z), direction)
  • def cal_intersection_point3(self, other: 'Line3')

计算平面与直线的交点。

引数:

other: 不与平面平行或在平面上的直线

ソースコード
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    """
+        计算平面与直线的交点。
+        Args:
+            other: 不与平面平行或在平面上的直线
+        Returns:
+            交点
+        Raises:
+            ValueError: 平面与直线平行或重合
+        """
+    if self.normal @ other.direction == 0:
+        raise ValueError('The plane and the line are parallel or coincident.')
+    x, y, z = other.get_parametric_equations()
+    t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
+    return Point3(x(t), y(t), z(t))
  • def cal_parallel_plane3(self, point: 'Point3')

计算平行于该平面且过指定点的平面。

引数:

point: 指定点

ソースコード
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    """
+        计算平行于该平面且过指定点的平面。
+        Args:
+            point: 指定点
+        Returns:
+            平面
+        """
+    return Plane3.from_point_and_normal(point, self.normal)
  • def is_parallel(self, other: 'Plane3')

判断两个平面是否平行。

引数:

other: 另一个平面

ソースコード
python
def is_parallel(self, other: 'Plane3') -> bool:
+    """
+        判断两个平面是否平行。
+        Args:
+            other: 另一个平面
+        Returns:
+            是否平行
+        """
+    return self.normal.is_parallel(other.normal)
  • @property

  • def normal(self)

平面的法向量。

戻り値:

法向量

ソースコード
python
@property
+def normal(self) -> 'Vector3':
+    """
+        平面的法向量。
+        Returns:
+            法向量
+        """
+    return Vector3(self.a, self.b, self.c)
  • @classmethod

  • def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3')

工厂函数 由点和法向量构造平面(点法式构造)。

引数:

point: 平面上的一点

normal: 法向量

ソースコード
python
@classmethod
+def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
+    """
+        工厂函数 由点和法向量构造平面(点法式构造)。
+        Args:
+            point: 平面上的一点
+            normal: 法向量
+        Returns:
+            平面
+        """
+    a, b, c = (normal.x, normal.y, normal.z)
+    d = -a * point.x - b * point.y - c * point.z
+    return cls(a, b, c, d)
  • @classmethod

  • def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3')

工厂函数 由三点构造平面。

引数:

p1: 点1

p2: 点2

p3: 点3

ソースコード
python
@classmethod
+def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
+    """
+        工厂函数 由三点构造平面。
+        Args:
+            p1: 点1
+            p2: 点2
+            p3: 点3
+        Returns:
+            平面
+        """
+    v1 = p2 - p1
+    v2 = p3 - p1
+    normal = v1.cross(v2)
+    return cls.from_point_and_normal(p1, normal)
  • @classmethod

  • def from_two_lines(cls, l1: 'Line3', l2: 'Line3')

工厂函数 由两直线构造平面。

引数:

l1: 直线1

l2: 直线2

ソースコード
python
@classmethod
+def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
+    """
+        工厂函数 由两直线构造平面。
+        Args:
+            l1: 直线1
+            l2: 直线2
+        Returns:
+            平面
+        """
+    v1 = l1.direction
+    v2 = l2.point - l1.point
+    if v2 == zero_vector3:
+        v2 = l2.get_point(1) - l1.point
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))
  • @classmethod

  • def from_point_and_line(cls, point: 'Point3', line: 'Line3')

工厂函数 由点和直线构造平面。

引数:

point: 面上一点

line: 面上直线,不包含点

ソースコード
python
@classmethod
+def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
+    """
+        工厂函数 由点和直线构造平面。
+        Args:
+            point: 面上一点
+            line: 面上直线,不包含点
+        Returns:
+            平面
+        """
+    return cls.from_point_and_normal(point, line.direction)
ソースコード
python
def __repr__(self):
+    return f'Plane3({self.a}, {self.b}, {self.c}, {self.d})'
ソースコード
python
def __str__(self):
+    s = 'Plane3: '
+    if self.a != 0:
+        s += f'{sign(self.a, only_neg=True)}{abs(self.a)}x'
+    if self.b != 0:
+        s += f' {sign(self.b)} {abs(self.b)}y'
+    if self.c != 0:
+        s += f' {sign(self.c)} {abs(self.c)}z'
+    if self.d != 0:
+        s += f' {sign(self.d)} {abs(self.d)}'
+    return s + ' = 0'
  • @overload

  • def __and__(self, other: 'Line3')

ソースコード
python
@overload
+def __and__(self, other: 'Line3') -> 'Point3 | None':
+    ...
  • @overload

  • def __and__(self, other: 'Plane3')

ソースコード
python
@overload
+def __and__(self, other: 'Plane3') -> 'Line3 | None':
+    ...
  • def __and__(self, other)

取两平面的交集(人话:交线)

引数:

other:

ソースコード
python
def __and__(self, other):
+    """
+        取两平面的交集(人话:交线)
+        Args:
+            other:
+        Returns:
+            不平行平面的交线,平面平行返回None
+        """
+    if isinstance(other, Plane3):
+        if self.normal.is_parallel(other.normal):
+            return None
+        return self.cal_intersection_line3(other)
+    elif isinstance(other, Line3):
+        if self.normal @ other.direction == 0:
+            return None
+        return self.cal_intersection_point3(other)
+    else:
+        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")
  • def __eq__(self, other)

ソースコード
python
def __eq__(self, other) -> bool:
+    return self.approx(other)
  • def __rand__(self, other: 'Line3')

ソースコード
python
def __rand__(self, other: 'Line3') -> 'Point3':
+    return self.cal_intersection_point3(other)
+ + + + \ No newline at end of file diff --git a/ja/api/mp_math/point.html b/ja/api/mp_math/point.html new file mode 100644 index 0000000..cf36822 --- /dev/null +++ b/ja/api/mp_math/point.html @@ -0,0 +1,64 @@ + + + + + + mbcp.mp_math.point | MBCP docs + + + + + + + + + + + + + +
Skip to content

class Point3

  • def __init__(self, x: float, y: float, z: float)

笛卡尔坐标系中的点。

引数:

x: x 坐标

y: y 坐标

z: z 坐标

ソースコード
python
def __init__(self, x: float, y: float, z: float):
+    """
+        笛卡尔坐标系中的点。
+        Args:
+            x: x 坐标
+            y: y 坐标
+            z: z 坐标
+        """
+    self.x = x
+    self.y = y
+    self.z = z
  • def approx(self, other: 'Point3', epsilon: float = APPROX)

判断两个点是否近似相等。

引数:

other:

epsilon:

ソースコード
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个点是否近似相等。
+        Args:
+            other:
+            epsilon:
+
+        Returns:
+            是否近似相等
+        """
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
ソースコード
python
def __str__(self):
+    return f'Point3({self.x}, {self.y}, {self.z})'
  • @overload

  • def __add__(self, other: 'Vector3')

ソースコード
python
@overload
+def __add__(self, other: 'Vector3') -> 'Point3':
+    ...
  • @overload

  • def __add__(self, other: 'Point3')

ソースコード
python
@overload
+def __add__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __add__(self, other)

P + V -> P P + P -> P

引数:

other:

ソースコード
python
def __add__(self, other):
+    """
+        P + V -> P
+        P + P -> P
+        Args:
+            other:
+        Returns:
+        """
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
  • def __eq__(self, other)

判断两个点是否相等。

引数:

other:

ソースコード
python
def __eq__(self, other):
+    """
+        判断两个点是否相等。
+        Args:
+            other:
+        Returns:
+        """
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)
+ + + + \ No newline at end of file diff --git a/ja/api/mp_math/segment.html b/ja/api/mp_math/segment.html new file mode 100644 index 0000000..093c1ac --- /dev/null +++ b/ja/api/mp_math/segment.html @@ -0,0 +1,39 @@ + + + + + + mbcp.mp_math.segment | MBCP docs + + + + + + + + + + + + + +
Skip to content

class Segment3

  • def __init__(self, p1: 'Point3', p2: 'Point3')

三维空间中的线段。 :param p1: :param p2:

ソースコード
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+    """
+        三维空间中的线段。
+        :param p1:
+        :param p2:
+        """
+    self.p1 = p1
+    self.p2 = p2
+    '方向向量'
+    self.direction = self.p2 - self.p1
+    '长度'
+    self.length = self.direction.length
+    '中心点'
+    self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
ソースコード
python
def __repr__(self):
+    return f'Segment3({self.p1}, {self.p2})'
ソースコード
python
def __str__(self):
+    return f'Segment3({self.p1} -> {self.p2})'
+ + + + \ No newline at end of file diff --git a/ja/api/mp_math/utils.html b/ja/api/mp_math/utils.html new file mode 100644 index 0000000..9512ffa --- /dev/null +++ b/ja/api/mp_math/utils.html @@ -0,0 +1,88 @@ + + + + + + mbcp.mp_math.utils | MBCP docs + + + + + + + + + + + + + +
Skip to content

def clamp()

区间截断函数。

引数:

x:

min_:

max_:

ソースコード
python
def clamp(x: float, min_: float, max_: float) -> float:
+    """
+    区间截断函数。
+    Args:
+        x:
+        min_:
+        max_:
+
+    Returns:
+        限制后的值
+    """
+    return max(min(x, max_), min_)

def approx(x: float = 0.0, y: float = APPROX)

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

引数:

x:

y:

epsilon:

ソースコード
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    """
+    判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
+    Args:
+        x:
+        y:
+        epsilon:
+
+    Returns:
+        是否近似相等
+    """
+    return abs(x - y) < epsilon

def sign(x: float = False)

获取数的符号。

引数:

x: 数

only_neg: 是否只返回负数的符号

ソースコード
python
def sign(x: float, only_neg: bool=False) -> str:
+    """获取数的符号。
+    Args:
+        x: 数
+        only_neg: 是否只返回负数的符号
+    Returns:
+        符号 + - ""
+    """
+    if x > 0:
+        return '+' if not only_neg else ''
+    elif x < 0:
+        return '-'
+    else:
+        return ''

def sign_format(x: float = False)

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

引数:

x: 数

only_neg: 是否只返回负数的符号

ソースコード
python
def sign_format(x: float, only_neg: bool=False) -> str:
+    """格式化符号数
+    -1 -> -1
+    1 -> +1
+    0 -> ""
+    Args:
+        x: 数
+        only_neg: 是否只返回负数的符号
+    Returns:
+        符号 + - ""
+    """
+    if x > 0:
+        return f'+{x}' if not only_neg else f'{x}'
+    elif x < 0:
+        return f'-{abs(x)}'
+    else:
+        return ''

class Approx

  • def __init__(self, value: RealNumber)

ソースコード
python
def __init__(self, value: RealNumber):
+    self.value = value
  • def __eq__(self, other)

ソースコード
python
def __eq__(self, other):
+    if isinstance(self.value, (float, int)):
+        if isinstance(other, (float, int)):
+            return abs(self.value - other) < APPROX
+        else:
+            self.raise_type_error(other)
+    elif isinstance(self.value, Vector3):
+        if isinstance(other, (Vector3, Point3, Plane3, Line3)):
+            return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
+        else:
+            self.raise_type_error(other)
  • def raise_type_error(self, other)

ソースコード
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')
  • def __ne__(self, other)

ソースコード
python
def __ne__(self, other):
+    return not self.__eq__(other)
+ + + + \ No newline at end of file diff --git a/ja/api/mp_math/vector.html b/ja/api/mp_math/vector.html new file mode 100644 index 0000000..3c1dd2b --- /dev/null +++ b/ja/api/mp_math/vector.html @@ -0,0 +1,212 @@ + + + + + + mbcp.mp_math.vector | MBCP docs + + + + + + + + + + + + + +
Skip to content

var zero_vector3 = Vector3(0, 0, 0)

var x_axis = Vector3(1, 0, 0)

var y_axis = Vector3(0, 1, 0)

var z_axis = Vector3(0, 0, 1)

class Vector3

  • def __init__(self, x: float, y: float, z: float)

3维向量

引数:

x: x轴分量

y: y轴分量

z: z轴分量

ソースコード
python
def __init__(self, x: float, y: float, z: float):
+    """
+        3维向量
+        Args:
+            x: x轴分量
+            y: y轴分量
+            z: z轴分量
+        """
+    self.x = x
+    self.y = y
+    self.z = z
  • def approx(self, other: 'Vector3', epsilon: float = APPROX)

判断两个向量是否近似相等。

引数:

other:

epsilon:

ソースコード
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个向量是否近似相等。
+        Args:
+            other:
+            epsilon:
+
+        Returns:
+            是否近似相等
+        """
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])
  • def cal_angle(self, other: 'Vector3')

计算两个向量之间的夹角。

引数:

other: 另一个向量

ソースコード
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    """
+        计算两个向量之间的夹角。
+        Args:
+            other: 另一个向量
+        Returns:
+            夹角
+        """
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)
  • def cross(self, other: 'Vector3')

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

ソースコード
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    """
+        向量积 叉乘:v1 cross v2 -> v3
+
+        叉乘为0,则两向量平行。
+        其余结果的模为平行四边形的面积。
+
+        返回如下行列式的结果:
+
+        ``i  j  k``
+
+        ``x1 y1 z1``
+
+        ``x2 y2 z2``
+
+        Args:
+            other:
+        Returns:
+            行列式的结果
+        """
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)
  • def is_approx_parallel(self, other: 'Vector3', epsilon: float = APPROX)

判断两个向量是否近似平行。

引数:

other: 另一个向量

epsilon: 允许的误差

ソースコード
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    """
+        判断两个向量是否近似平行。
+        Args:
+            other: 另一个向量
+            epsilon: 允许的误差
+        Returns:
+            是否近似平行
+        """
+    return self.cross(other).length < epsilon
  • def is_parallel(self, other: 'Vector3')

判断两个向量是否平行。

引数:

other: 另一个向量

ソースコード
python
def is_parallel(self, other: 'Vector3') -> bool:
+    """
+        判断两个向量是否平行。
+        Args:
+            other: 另一个向量
+        Returns:
+            是否平行
+        """
+    return self.cross(other).approx(zero_vector3)
  • def normalize(self)

将向量归一化。

自体归一化,不返回值。

ソースコード
python
def normalize(self):
+    """
+        将向量归一化。
+
+        自体归一化,不返回值。
+        """
+    length = self.length
+    self.x /= length
+    self.y /= length
+    self.z /= length
ソースコード
python
@property
+def np_array(self) -> 'np.ndarray':
+    """
+        返回numpy数组
+        Returns:
+        """
+    return np.array([self.x, self.y, self.z])
  • @property

  • def length(self)

向量的模。

戻り値:

ソースコード
python
@property
+def length(self) -> float:
+    """
+        向量的模。
+        Returns:
+
+        """
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)
  • @property

  • def unit(self)

获取该向量的单位向量。

戻り値:

单位向量

ソースコード
python
@property
+def unit(self) -> 'Vector3':
+    """
+        获取该向量的单位向量。
+        Returns:
+            单位向量
+        """
+    return self / self.length
ソースコード
python
def __abs__(self):
+    return self.length
  • @overload

  • def __add__(self, other: 'Vector3')

ソースコード
python
@overload
+def __add__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __add__(self, other: 'Point3')

ソースコード
python
@overload
+def __add__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __add__(self, other)

V + P -> P

V + V -> V

引数:

other:

ソースコード
python
def __add__(self, other):
+    """
+        V + P -> P
+
+        V + V -> V
+        Args:
+            other:
+        Returns:
+
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x + other.x, self.y + other.y, self.z + other.z)
+    elif isinstance(other, Point3):
+        return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
+    else:
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")
  • def __eq__(self, other)

判断两个向量是否相等。

引数:

other:

ソースコード
python
def __eq__(self, other):
+    """
+        判断两个向量是否相等。
+        Args:
+            other:
+        Returns:
+            是否相等
+        """
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)
  • def __radd__(self, other: 'Point3')

P + V -> P

别去点那边实现了。 :param other: :return:

ソースコード
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    """
+        P + V -> P
+
+        别去点那边实现了。
+        :param other:
+        :return:
+        """
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
  • @overload

  • def __sub__(self, other: 'Vector3')

ソースコード
python
@overload
+def __sub__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __sub__(self, other: 'Point3')

ソースコード
python
@overload
+def __sub__(self, other: 'Point3') -> 'Point3':
+    ...
  • def __sub__(self, other)

V - P -> P

V - V -> V

引数:

other:

ソースコード
python
def __sub__(self, other):
+    """
+        V - P -> P
+
+        V - V -> V
+        Args:
+            other:
+        Returns:
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
+    elif isinstance(other, Point3):
+        return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
+    else:
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')
  • def __rsub__(self, other: 'Point3')

P - V -> P

引数:

other:

ソースコード
python
def __rsub__(self, other: 'Point3'):
+    """
+        P - V -> P
+        Args:
+            other:
+        Returns:
+
+        """
+    if isinstance(other, Point3):
+        return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
+    else:
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")
  • @overload

  • def __mul__(self, other: 'Vector3')

ソースコード
python
@overload
+def __mul__(self, other: 'Vector3') -> 'Vector3':
+    ...
  • @overload

  • def __mul__(self, other: RealNumber)

ソースコード
python
@overload
+def __mul__(self, other: RealNumber) -> 'Vector3':
+    ...
  • def __mul__(self, other: 'int | float | Vector3')

数组运算 非点乘。点乘使用@,叉乘使用cross。

引数:

other:

ソースコード
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    """
+        数组运算 非点乘。点乘使用@,叉乘使用cross。
+        Args:
+            other:
+
+        Returns:
+        """
+    if isinstance(other, Vector3):
+        return Vector3(self.x * other.x, self.y * other.y, self.z * other.z)
+    elif isinstance(other, (float, int)):
+        return Vector3(self.x * other, self.y * other, self.z * other)
+    else:
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")
  • def __rmul__(self, other: 'RealNumber')

ソースコード
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)
  • def __matmul__(self, other: 'Vector3')

点乘。

引数:

other:

ソースコード
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+    """
+        点乘。
+        Args:
+            other:
+        Returns:
+        """
+    return self.x * other.x + self.y * other.y + self.z * other.z
  • def __truediv__(self, other: RealNumber)

ソースコード
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)
ソースコード
python
def __neg__(self):
+    return Vector3(-self.x, -self.y, -self.z)
ソースコード
python
def __repr__(self):
+    return f'Vector3({self.x}, {self.y}, {self.z})'
ソースコード
python
def __str__(self):
+    return f'Vector3({self.x}, {self.y}, {self.z})'
+ + + + \ No newline at end of file diff --git a/ja/api/particle/index.html b/ja/api/particle/index.html new file mode 100644 index 0000000..38c2eae --- /dev/null +++ b/ja/api/particle/index.html @@ -0,0 +1,24 @@ + + + + + + mbcp.particle | MBCP docs + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ja/api/presets/index.html b/ja/api/presets/index.html new file mode 100644 index 0000000..a59b646 --- /dev/null +++ b/ja/api/presets/index.html @@ -0,0 +1,24 @@ + + + + + + mbcp.presets | MBCP docs + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ja/api/presets/model/index.html b/ja/api/presets/model/index.html new file mode 100644 index 0000000..635af05 --- /dev/null +++ b/ja/api/presets/model/index.html @@ -0,0 +1,41 @@ + + + + + + mbcp.presets.model | MBCP docs + + + + + + + + + + + + + +
Skip to content

class GeometricModels

  • @staticmethod

  • def sphere(radius: float, density: float)

生成球体上的点集。

引数:

radius:

density:

ソースコード
python
@staticmethod
+def sphere(radius: float, density: float):
+    """
+        生成球体上的点集。
+        Args:
+            radius:
+            density:
+        Returns:
+            List[Point3]: 球体上的点集。
+        """
+    area = 4 * np.pi * radius ** 2
+    num = int(area * density)
+    phi_list = np.arccos([clamp(-1 + (2.0 * _ - 1.0) / num, -1, 1) for _ in range(num)])
+    theta_list = np.sqrt(num * np.pi) * phi_list
+    x_array = radius * np.sin(phi_list) * np.cos(theta_list)
+    y_array = radius * np.sin(phi_list) * np.sin(theta_list)
+    z_array = radius * np.cos(phi_list)
+    return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
+ + + + \ No newline at end of file diff --git a/md-ex.html b/md-ex.html index e8653c1..b7fe31a 100644 --- a/md-ex.html +++ b/md-ex.html @@ -17,7 +17,7 @@ -
Skip to content

Markdown Extension Examples

This page demonstrates some of the built-in markdown extensions provided by VitePress.

Syntax Highlighting

VitePress provides Syntax Highlighting powered by Shiki, with additional features like line-highlighting:

Input

md
```js{4}
+    
Skip to content

Markdown Extension Examples

This page demonstrates some of the built-in markdown extensions provided by VitePress.

Syntax Highlighting

VitePress provides Syntax Highlighting powered by Shiki, with additional features like line-highlighting:

Input

md
```js{4}
 export default {
   data () {
     return {
@@ -50,7 +50,7 @@
 ::: details
 This is a details block.
 :::

Output

INFO

This is an info box.

TIP

This is a tip.

WARNING

This is a warning.

DANGER

This is a dangerous warning.

Details

This is a details block.

More

Check out the documentation for the full list of markdown extensions.

- + \ No newline at end of file