Difference between revisions of "LlAngleBetween/ja"

From Second Life Wiki
Jump to navigation Jump to search
m (カテゴリ変更)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{LSL_Function/ja
{{Issues/SVC-2424}}{{LSL_Function/ja
|func_id=174|func_sleep=0.0|func_energy=10.0
|func_id=174|func_sleep=0.0|func_energy=10.0
|func=llAngleBetween|sort=AngleBetween
|func=llAngleBetween|sort=AngleBetween
Line 9: Line 9:
|spec
|spec
|caveats
|caveats
|examples
|examples=
<source lang="lsl2">
default
{
    touch_start(integer num_detected)
    {
        rotation currentRootRotation = llGetRootRotation();
        float angle = llAngleBetween(ZERO_ROTATION, currentRootRotation);
 
        // PUBLIC_CHANNEL has the integer value 0
        llSay(PUBLIC_CHANNEL,
            "llAngleBetween(ZERO_ROTATION, " + (string)currentRootRotation + ") = " + (string)angle);
    }
}
</source>
|helpers
|helpers
|also_functions={{LSL DefineRow||{{LSLG/ja|llRotBetween}}}}
|also_functions={{LSL DefineRow||{{LSLG/ja|llRotBetween}}}}
Line 17: Line 31:
|also_articles
|also_articles
|notes
|notes
|deepnotes=<lsl>float AngleBetween(rotation a, rotation b)
|deepnotes= ===参考===
<source lang="lsl2">float AngleBetween(rotation a, rotation b) // シンプルですが正確性に欠けます。
{
{
     return 2.0 * llAcos((a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s)
     return 2.0 * llAcos((a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s)
               / llSqrt((a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s)
               / llSqrt((a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s)
                       * (b.x * b.x + b.y * b.y + b.z * b.z + b.s * b.s)));
                       * (b.x * b.x + b.y * b.y + b.z * b.z + b.s * b.s)));
}</lsl>
}
|cat1=Math/3D/ja
</source>
<source lang="lsl2">
float AngleBetween(rotation a, rotation b)//上記より複雑な実装ですが、より正確で、合理的な速さです。
{
    rotation r = b / a; // calculate the rotation between the two arguments as quaternion
    float s2 = r.s * r.s; // square of the s-element
    float v2 = r.x * r.x + r.y * r.y + r.z * r.z; // sum of the squares of the v-elements
    if (s2 < v2) // compare the s-component to the v-component
        return 2.0 * llAcos(llSqrt(s2 / (s2 + v2))); // use arccos if the v-component is dominant
    if (v2) // make sure the v-component is non-zero
        return 2.0 * llAsin(llSqrt(v2 / (s2 + v2))); // use arcsin if the s-component is dominant
    return 0.0; // one or both arguments are scaled too small to be meaningful, or the values are the same, so return zero
}//Written by Moon Metty & Miranda Umino. Minor optimizations by Strife Onizuka
</source>
|cat1=Math/3D
|cat2
|cat2
|cat3
|cat3
|cat4
|cat4
}}
}}

Latest revision as of 20:22, 5 August 2021

要約

関数: float llAngleBetween( rotation a, rotation b );

2 つの rotation 値 a, b 間の角度を float で返します。

• rotation a rotation 値 A
• rotation b rotation 値 B

サンプル

default
{
    touch_start(integer num_detected)
    {
        rotation currentRootRotation = llGetRootRotation();
        float angle = llAngleBetween(ZERO_ROTATION, currentRootRotation);

        // PUBLIC_CHANNEL has the integer value 0
        llSay(PUBLIC_CHANNEL,
            "llAngleBetween(ZERO_ROTATION, " + (string)currentRootRotation + ") = " + (string)angle);
    }
}

関連項目

関数

•  llRotBetween
•  llRot2Angle 同様の機能で軸角度形式を求める

特記事項

参考

float AngleBetween(rotation a, rotation b) // シンプルですが正確性に欠けます。
{
    return 2.0 * llAcos((a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s)
               / llSqrt((a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s)
                      * (b.x * b.x + b.y * b.y + b.z * b.z + b.s * b.s)));
}
float AngleBetween(rotation a, rotation b)//上記より複雑な実装ですが、より正確で、合理的な速さです。
{
    rotation r = b / a; // calculate the rotation between the two arguments as quaternion
    float s2 = r.s * r.s; // square of the s-element
    float v2 = r.x * r.x + r.y * r.y + r.z * r.z; // sum of the squares of the v-elements
 
    if (s2 < v2) // compare the s-component to the v-component
        return 2.0 * llAcos(llSqrt(s2 / (s2 + v2))); // use arccos if the v-component is dominant
    if (v2) // make sure the v-component is non-zero
        return 2.0 * llAsin(llSqrt(v2 / (s2 + v2))); // use arcsin if the s-component is dominant
 
    return 0.0; // one or both arguments are scaled too small to be meaningful, or the values are the same, so return zero
}//Written by Moon Metty & Miranda Umino. Minor optimizations by Strife Onizuka

All Issues

~ Search JIRA for related Issues
   llAngleBetween() is sometimes inaccurate

Signature

function float llAngleBetween( rotation a, rotation b );
この翻訳は 原文 と比べて古いですか?間違いがありますか?読みにくいですか?みんなで 修正 していきましょう! (手順はこちら)
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。