Difference between revisions of "Category:LSL Vector/ja"

From Second Life Wiki
Jump to navigation Jump to search
(Redirected page to Category:LSL ベクトル)
Line 1: Line 1:
#Redirect [[:Category:LSL ベクトル]]
{{Multi-lang}}
{{LSL Header/ja|ml=*}}
{{LSLC/ja|}}{{LSLC/ja|Types}}
==Vector==
vectorは3個の{[[float/ja|float]]の値のセットを含むデータ[[:Category:LSL Types/ja|型(type)]]です。
 
===成分===
各要素は変数名の後に .x、.y、.zを付加することにより個別にアクセスできます。 
<source lang="lsl2">vector vec; float x = vec.x; float y = vec.y; float z = vec.z;</source>
 
===用途===
vector型は次のデータを保持するために使うことができます:
* 位置: x, y, zの単位はm(メートル)
* 速度: x, y, zはスピードをあらわします。
* {{LSLGC|Color|色}}: Redはx、Greenはy、Blueはz
 
===演算子===
vector型は次の操作をサポートしています:
* 加算、"+" 演算子
* 減算、"-" 演算子
* 乗算 (内積)、 "*" 演算子
* 外積、"%" 演算子
 
vector型は[[Quaternion/ja|クォータニオン]]の乗算または除算によって回転させることができます。
 
===例===
<source lang="lsl2">
vector test=<1.0, 2.0, 3.0>;
llOwnerSay((string)test.z); // 3.0を出力する
</source>
 
===便利なスニペット===
文字がVectorかチェックする
<source lang="lsl2">integer IsVector(string s) {
 
  list split = llParseString2List(s, [" "], ["<", ">", ","]);
  if(llGetListLength(split) != 7)//we must check the list length, or the next test won't work properly.
      return 0;
  return !((string)((vector)s) == (string)((vector)((string)llListInsertList(split, ["-"], 5))));
  //it works by trying to flip the sign on the Z element of the vector,
  //if it works or breaks the vector then the values won't match.
  //if the vector was already broken then the sign flip will have no affect and the values will match
  //we cast back to string so we can catch negative zero which allows for support of ZERO_VECTOR
 
}//Strife Onizuka</source>

Revision as of 19:06, 18 December 2015

Vector

vectorは3個の{floatの値のセットを含むデータ型(type)です。

成分

各要素は変数名の後に .x、.y、.zを付加することにより個別にアクセスできます。

vector vec; float x = vec.x; float y = vec.y; float z = vec.z;

用途

vector型は次のデータを保持するために使うことができます:

  • 位置: x, y, zの単位はm(メートル)
  • 速度: x, y, zはスピードをあらわします。
  • : Redはx、Greenはy、Blueはz

演算子

vector型は次の操作をサポートしています:

  • 加算、"+" 演算子
  • 減算、"-" 演算子
  • 乗算 (内積)、 "*" 演算子
  • 外積、"%" 演算子

vector型はクォータニオンの乗算または除算によって回転させることができます。

vector test=<1.0, 2.0, 3.0>;
llOwnerSay((string)test.z); // 3.0を出力する

便利なスニペット

文字がVectorかチェックする

integer IsVector(string s) {

   list split = llParseString2List(s, [" "], ["<", ">", ","]);
   if(llGetListLength(split) != 7)//we must check the list length, or the next test won't work properly.
       return 0;
   return !((string)((vector)s) == (string)((vector)((string)llListInsertList(split, ["-"], 5))));
   //it works by trying to flip the sign on the Z element of the vector,
   //if it works or breaks the vector then the values won't match.
   //if the vector was already broken then the sign flip will have no affect and the values will match
   //we cast back to string so we can catch negative zero which allows for support of ZERO_VECTOR

}//Strife Onizuka

Pages in category "LSL Vector/ja"

The following 6 pages are in this category, out of 6 total.