LlAtan2/ja
< LlAtan2
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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の関連した項目が参考になるかもしれません。