Difference between revisions of "LlAtan2/ja"

From Second Life Wiki
Jump to navigation Jump to search
(Add notation about range of return value)
 
(6 intermediate revisions by 3 users not shown)
Line 2: Line 2:
|func_id=3|func_sleep=0.0|func_energy=10.0
|func_id=3|func_sleep=0.0|func_energy=10.0
|func=llAtan2|sort=Atan2
|func=llAtan2|sort=Atan2
|func_footnote=通常のアークタンジェント (arctangent(y/x)) に似ていますが、象限を定めるために x と y の値を個別にとる点が異なります。x, y ともに 0 の場合 0 を返します。
|p1_type=float|p1_name=y|p1_desc
|p1_type=float|p1_name=y|p1_desc
|p2_type=float|p2_name=x|p2_desc
|p2_type=float|p2_name=x|p2_desc
|return_type=float
|return_type=float
|return_text=y, x の{{wikipedia|Atan2|arctangent2}}
|return_text='''y''', '''x''' の{{wikipedia|Atan2|arctangent2}}
|func_footnote=戻り値は [-{{LSLG/ja|PI}}, PI] の範囲にあります。
|func_footnote=アークタンジェント <span class="plainlinks">{{wikipedia|Inverse_trigonometric_functions|arctangent}}</span>('''y'''/'''x''') に似ていますが、 象限を定めるために '''x''' と '''y''' の値を個別にとる点が異なります。'''x''' , '''y''' ともにゼロの場合、ゼロを返します。<br />
|spec
戻り値は {{Interval|gte=-{{LSLG/ja|PI}}|gteh=-PI|lte=PI|center=return}}{{Interval/Footnote}} の範囲にあります。
|spec=
If {{LSLP|x}} is positive zero and...
* {{LSLP|y}} is zero, '''zero''' is returned.
* {{LSLP|y}} is positive, '''PI/2''' is returned.
* {{LSLP|y}} is negative, '''-PI/2''' is returned.
If {{LSLP|x}} is negative zero and...
* {{LSLP|y}} is positive zero, '''PI''' is returned.
* {{LSLP|y}} is negative zero, '''-PI''' is returned.
* {{LSLP|y}} is positive, '''PI/2''' is returned.
* {{LSLP|y}} is negative, '''-PI/2''' is returned.
 
Or
<source lang="lsl2">
if((string)x != (string)0.0 && y == 0.0)//negative zero
    return PI * ~-2*((string)y != (string)0.0));
return ((y > 0) - (y < 0)) * PI_BY_TWO;
</source>
戻り値の範囲 {{Interval|gte=-[[PI]]|gteh=-PI|lte=PI|center=return}}{{Interval/Footnote}}
|caveats
|caveats
|constants
|constants
|examples=<lsl>default
|examples=<source lang="lsl2">default
{
{
   state_entry()
   state_entry()
Line 23: Line 40:
     llOwnerSay("The arctangent of y divided by x is " + (string)llAtan2(num1, num2));
     llOwnerSay("The arctangent of y divided by x is " + (string)llAtan2(num1, num2));
   }
   }
}</lsl><lsl>//方向を示す vector 値を受け取り、その方角を文字で返す関数。
}</source><source lang="lsl2">//方向を示す vector 値を受け取り、その方角を文字で返す関数。
//by Ramana Sweetwater 2009/01, ご自由にお使いください。
//by Ramana Sweetwater 2009/01, ご自由にお使いください。


Line 32: Line 49:
     list DIRS =["W","NW","N","NE","E","SE","S","SW","W"];
     list DIRS =["W","NW","N","NE","E","SE","S","SW","W"];
     return llList2String(DIRS,llCeil(4.5-((4*llAtan2((target.y-me.y)/distance,(target.x-me.x)/distance))/PI)));
     return llList2String(DIRS,llCeil(4.5-((4*llAtan2((target.y-me.y)/distance,(target.x-me.x)/distance))/PI)));
}</lsl>
}</source>
|helpers
|helpers
|also_functions=
|also_functions=
{{LSL DefineRow|{{LSLG/ja|llSin}}|{{LSLG/ja|llAsin}}|サインとそ逆関数}}
{{LSL DefineRow|{{LSLG/ja|llSin}}|{{LSLG/ja|llAsin}}|サインとその逆関数}}
{{LSL DefineRow|{{LSLG/ja|llCos}}|{{LSLG/ja|llAcos}}|コサインとそ逆関数}}
{{LSL DefineRow|{{LSLG/ja|llCos}}|{{LSLG/ja|llAcos}}|コサインとその逆関数}}
{{LSL DefineRow|{{LSLG/ja|llTan}}||タンジェント}}
{{LSL DefineRow|{{LSLG/ja|llTan}}||タンジェント}}
|also_articles={{LSL DefineRow||{{Wikipedia|1=三角関数|lang=ja}}|}}
|also_articles={{LSL DefineRow||{{Wikipedia|1=三角関数|lang=ja}}|}}

Latest revision as of 12:24, 6 August 2021

要約

関数: float llAtan2( float y, float x );

y, x"Wikipedia logo"arctangent2を float で返します。

• float y
• float x

アークタンジェント "Wikipedia logo"arctangent(y/x) に似ていますが、 象限を定めるために xy の値を個別にとる点が異なります。x , y ともにゼロの場合、ゼロを返します。
戻り値は [-PI, PI][1] の範囲にあります。

仕様

If x is positive zero and...

  • y is zero, zero is returned.
  • y is positive, PI/2 is returned.
  • y is negative, -PI/2 is returned.

If x is negative zero and...

  • y is positive zero, PI is returned.
  • y is negative zero, -PI is returned.
  • y is positive, PI/2 is returned.
  • y is negative, -PI/2 is returned.

Or

if((string)x != (string)0.0 && y == 0.0)//negative zero
    return PI * ~-2*((string)y != (string)0.0));
return ((y > 0) - (y < 0)) * PI_BY_TWO;

戻り値の範囲 [-PI, PI][1]

サンプル

default
{
  state_entry()
  {
    float num1 = llFrand(100.0);
    float num2 = llFrand(100.0);

    llOwnerSay("y = " + (string)num1);
    llOwnerSay("x = " + (string)num2);

    llOwnerSay("The arctangent of y divided by x is " + (string)llAtan2(num1, num2));
  }
}
//方向を示す vector 値を受け取り、その方角を文字で返す関数。
//by Ramana Sweetwater 2009/01, ご自由にお使いください。

string compass (vector target) 
{
    vector me = llGetPos();
    float distance = llVecDist(me, target);
    list DIRS =["W","NW","N","NE","E","SE","S","SW","W"];
    return llList2String(DIRS,llCeil(4.5-((4*llAtan2((target.y-me.y)/distance,(target.x-me.x)/distance))/PI)));
}

関連項目

関数

• llSin llAsin サインとその逆関数
• llCos llAcos コサインとその逆関数
• llTan タンジェント

記事

•  "Wikipedia logo"三角関数

特記事項

Search JIRA for related Issues

脚注

  1. ^ 記事中の範囲は、 実数空間 に記載されているものです。

Signature

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