Difference between revisions of "LlAtan2/ja"

From Second Life Wiki
Jump to navigation Jump to search
 
Line 8: Line 8:
|func_footnote=アークタンジェント <span class="plainlinks">{{wikipedia|Inverse_trigonometric_functions|arctangent}}</span>('''y'''/'''x''') に似ていますが、 象限を定めるために '''x''' と '''y''' の値を個別にとる点が異なります。'''x''' , '''y''' ともにゼロの場合、ゼロを返します。<br />
|func_footnote=アークタンジェント <span class="plainlinks">{{wikipedia|Inverse_trigonometric_functions|arctangent}}</span>('''y'''/'''x''') に似ていますが、 象限を定めるために '''x''' と '''y''' の値を個別にとる点が異なります。'''x''' , '''y''' ともにゼロの場合、ゼロを返します。<br />
戻り値は {{Interval|gte=-{{LSLG/ja|PI}}|gteh=-PI|lte=PI|center=return}}{{Interval/Footnote}} の範囲にあります。
戻り値は {{Interval|gte=-{{LSLG/ja|PI}}|gteh=-PI|lte=PI|center=return}}{{Interval/Footnote}} の範囲にあります。
|spec
|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

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の関連した項目が参考になるかもしれません。