| storage egg:math/sin_cos <<degree~double | 角度 degree (度数法) |
|---|---|
| storage egg:math/sin_cos >>sin~double | sin 値 |
| storage egg:math/sin_cos >>cos~double | cos 値 |
| return | 成否 |
degree の角度から sin と cos の値を同時に取得します。
処理効率の関係で sin と cos はセットで算出します。
# 引数設定.
data modify storage egg:math/sin_cos <<degree~double set from entity @s Rotation[0]
# 呼び出し.
function egg:math/sin_cos
# 結果取得.
data modify entity @s ... set from storage egg:math/sin_cos >>sin~double
data modify entity @s ... set from storage egg:math/sin_cos >>cos~double
| storage egg:math/sin_cos_tan <<degree~double | 角度 degree (度数法) |
|---|---|
| storage egg:math/sin_cos_tan >>sin~double | sin 値 |
| storage egg:math/sin_cos_tan >>cos~double | cos 値 |
| storage egg:math/sin_cos_tan >>tan~double | tan 値 |
| return | 成否 |
degree の角度から sin と cos と tan の値を同時に取得します。
tan を直接算出するより sin/cos から算出した方が精度が高かったため、三角関数の値を全て算出する形になっています。
固定小数点で演算を行っているため、大きな数値では精度が落ちます。
例えば90度に近い角度では正確に大きな数値は取得できず「非常に大きな値である」という事実を知る程度に留まります。
# 引数設定.
data modify storage egg:math/sin_cos_tan <<degree~double set from entity @s Rotation[0]
# 呼び出し.
function egg:math/sin_cos_tan
# 結果取得.
data modify entity @s ... set from storage egg:math/sin_cos_tan >>sin~double
data modify entity @s ... set from storage egg:math/sin_cos_tan >>cos~double
data modify entity @s ... set from storage egg:math/sin_cos_tan >>tan~double
| storage egg:math/asin_acos <<x~double | 座標値 x (-1 ≤ x ≤ 1) |
|---|---|
| storage egg:math/asin_acos >>asin~double | arcsin 値 (度数法) |
| storage egg:math/asin_acos >>acos~double | arccos 値 (度数法) |
| return | 成否 |
x の値から arcsin と arccos の値を同時に取得します。
処理効率の関係で arcsin と arccos はセットで算出します。
-1 〜 1 の範囲外の引数は、範囲内に収まるよう補正されます。
これは固定小数点での乗除による誤差などで 1 に収まる数値が 1 を超えてしまう可能性を考えての対応です。本来は -1 ~ 1 の範囲外数値はエラーを出すべきです。
# 引数設定.
data modify storage egg:math/asin_acos <<degree~double set from entity @s Motion[0]
# 呼び出し.
function egg:math/asin_acos
# 結果取得.
data modify entity @s ... set from storage egg:math/asin_acos >>asin~double
data modify entity @s ... set from storage egg:math/asin_acos >>acos~double