“LlAtan2”的版本间的差异
(创建页面,内容为“{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}} {{函数详情 |函数名=float llAtan2( float y, float x ); |参数= 返回y,x的arctangent2…”) |
(没有差异)
|
2020年5月18日 (一) 09:34的最新版本
| 首页 | 函数 | 事件 | 类型 | 操作符 | 常数 | Flow Control | Script Library | Categorized Library | Tutorials |
| 函数名 |
|---|
| float llAtan2( float y, float x ); |
| 返回y,x的arctangent2浮点值。 |
| •浮动y
•浮动x 与反正切(y/x)类似,只是它利用x&y的符号来确定象限并避免被零除。 |
| 注意事项 |
|---|
| 如果x是正零并且。。。
y为零,返回零。 y为正,返回PI/2。 y为负,-PI/2被返回。 如果x是负零并且。。。 y为正零,返回PI。 y为负零,-PI返回。 y为正,返回PI/2。 y为负,-PI/2被返回。 或者 如果((字符串)x!=(字符串)0.0&&y==0.0)//负零 返回PI*~-2*((字符串)y!=(字符串)0.0); 返回((y>0)-(y<0))*PI_乘以2; 返回值在范围[-PI,PI] Search JIRA for related Bugs |
| 示例 |
|---|
示例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));
}
}
//Function with input of a vector determining the position of a target and returning
//a string with the literal compass-direction of that target towards your position
//by Ramana Sweetwater 2009/01, any use allowed license :-)
//corrected by Patrick Muggins
string compass (vector target)
{
vector source = llGetPos();
list DIRS =["W","NW","N","NE","E","SE","S","SW","W"];
integer index = llCeil(3.5 - (4 * llAtan2(target.y - source.y, target.x - source.x) / PI));
return llList2String(DIRS, index);
}
|
| 相关函数 |
|---|
| llSinllAsin– sine & inverse Sine
llCosllAcos– cosine & inverse cosine [[llTan ]] – tangent 文献: [1][2] |
| 相关事件 |
|---|
| Search JIRA for related Issues |