リミックスなどをして、この画期的なライブラリを広めてください! 高速化のアイデアや、新しい機能の提案もぜひコメントで教えてください! Help spread this groundbreaking library by remixing! If you have ideas for optimizations or new features, feel free to share them in the comments! ↓ENGLISH↓ ## 複素数ライブラリ - Complex このライブラリは、**Scratch上で複素数を扱うための拡張モジュール**です。 最大の特長は、複素数オブジェクトに対して直接的な **メソッド呼び出しによる演算** が可能な点です。 * `A.add(B)` * `A.mul(B)` * `A.pow(B)` これにより、演算処理が直感的かつ可読性の高いコードで記述できます。 ### 実装されている機能一覧 #### ▶ オブジェクト生成(コンストラクタ) * `new Complex(real, imag)`:直交座標から生成 * `Complex.fromPolar(r, θ)`:極座標から生成 * `Complex.copy(obj)`:複素数のコピー #### ▶ メソッド(破壊的演算:元の値を更新) * `.add(B)`:加算(`+=`) * `.sub(B)`:減算(`-=`) * `.mul(B)`:乗算(`*=`) * `.div(B)`:除算(`/=`) * `.pow(B)`:べき乗(`**=`) #### ▶ ゲッター(非破壊的演算:値の取得) * `.real`:実部 * `.imag`:虚部 * `.abs`:絶対値 * `.arg`:偏角 * `.exp`, `.ln`:指数関数、自然対数 * `.cos`, `.sin`, `.tan`:三角関数 * `.acos`, `.asin`, `.atan`:逆三角関数 #### ▶ セッター * `.setReal(x)`:実部のみ設定 * `.setImag(y)`:虚部のみ設定 #### ▶ 補助メソッド * `.toString()`:文字列化 * `Reset()`:保存処理の前に呼び出す初期化関数 --- 注意事項: すべての角度計算はラジアン(弧度法)で行われます。 --- --- ## Complex Number Library - **Complex** This library is a **Scratch extension module for handling complex numbers**. Its most notable feature is that it supports **direct method-based operations** on complex number objects. * `A.add(B)` * `A.mul(B)` * `A.pow(B)` This makes expressions intuitive and code highly readable. --- ### Available Features #### ▶ Object Construction * `new Complex(real, imag)` – Creates from rectangular coordinates * `Complex.fromPolar(r, θ)` – Creates from polar coordinates * `Complex.copy(obj)` – Copies an existing complex number #### ▶ Methods (Destructive operations – modify the object) * `.add(B)` – Addition (`+=`) * `.sub(B)` – Subtraction (`-=`) * `.mul(B)` – Multiplication (`*=`) * `.div(B)` – Division (`/=`) * `.pow(B)` – Exponentiation (`**=`) #### ▶ Getters (Non-destructive – return a value) * `.real` – Real part * `.imag` – Imaginary part * `.abs` – Absolute value (magnitude) * `.arg` – Argument (angle) * `.exp`, `.ln` – Exponential and natural logarithm * `.cos`, `.sin`, `.tan` – Trigonometric functions * `.acos`, `.asin`, `.atan` – Inverse trigonometric functions #### ▶ Setters * `.setReal(x)` – Set real part only * `.setImag(y)` – Set imaginary part only #### ▶ Utility Methods * `.toString()` – Convert to string * `Reset()` – Initialization function for project saving --- ### Notes * **All angle-related calculations use radians.** ↑日本語↑ ---tag--- #tutorials #tutorial