Difference between revisions of "LlAtan2/ja"
< LlAtan2
Jump to navigation
Jump to search
m (Typo) |
|||
(5 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 | ||
|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=戻り値は | |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=< | |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)); | ||
} | } | ||
}</ | }</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))); | ||
}</ | }</source> | ||
|helpers | |helpers | ||
|also_functions= | |also_functions= |
Latest revision as of 11:24, 6 August 2021
LSL ポータル | 関数 | イベント | 型 | 演算子 | 定数 | 実行制御 | スクリプトライブラリ | カテゴリ別スクリプトライブラリ | チュートリアル |
要約
関数: float llAtan2( float y, float x );y, x の arctangent2を float で返します。
• float | y | |||
• float | x |
アークタンジェント arctangent(y/x) に似ていますが、 象限を定めるために x と y の値を個別にとる点が異なります。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;
サンプル
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)));
}
特記事項
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。