この文書の現在のバージョンと選択したバージョンの差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン 最新リビジョン 両方とも次のリビジョン | ||
vci:script:reference:vector3 [2021/03/24 17:51] t-daihisa |
vci:script:reference:vector3 [2022/09/01 19:44] pastatto 微調整 |
||
---|---|---|---|
ライン 1: | ライン 1: | ||
+ | ~~NOTOC~~ | ||
====== Vector3 ====== | ====== Vector3 ====== | ||
- | **types.lua を開くと最新のメソッド一覧を確認できます。**\\ | ||
Vector3はX,Y,Zの3つの値を持ったクラスです。\\ | Vector3はX,Y,Zの3つの値を持ったクラスです。\\ | ||
- | 位置や力の方向を表したりするのに使います。\\ | + | 位置や力の方向を表したりするのに使います。 |
- | ---- | ||
- | ===== メソッド一覧 ===== | + | ^ 名前 ^ 説明 ^ バージョン ^ |
+ | | [[vci/script/reference/vector3#Slerp ]] | 2つのベクトル間を t で球面補間します。t は[0, 1]の範囲です。 | | ||
+ | | [[vci/script/reference/vector3#SlerpUnclamped ]] | Slerpと同じですが t の値を[0, 1]に制限しません。バネ等に使います。 | | ||
+ | | [[vci/script/reference/vector3#OrthoNormalize ]] | 正規化したベクトル、直交ベクトル、外積を作成します。 | | ||
+ | | [[vci/script/reference/vector3#RotateTowards ]] | currentの向きから、targetの向きまで回転させます。ただし、その際の最大速度はmaxRadiansDelta m/secに制限されます。 | | ||
+ | | [[vci/script/reference/vector3#Lerp ]] | 2つのベクトル間を t で線形補間します。t は[0, 1]の範囲です。 | | ||
+ | | [[vci/script/reference/vector3#LerpUnclamped ]] | Lerpと同じですが t の値を[0, 1]に制限しません。バネ等に使います。 | | ||
+ | | [[vci/script/reference/vector3#MoveTowards ]] | currentの位置から、targetの位置まで移動させます。ただし、その際の最大速度はmaxDistanceDelta m/secに制限されます。 | | ||
+ | | [[vci/script/reference/vector3#SmoothDamp ]] | 目的地に向かって時間の経過とともに徐々にベクトルを変化させます。 | | ||
+ | | [[vci/script/reference/vector3#set_Item ]] | Vector3の値をvalueで上書きします。index 0 = x, 1 = y, 2 = z | | ||
+ | | [[vci/script/reference/vector3#Set ]] | Vector3の値を上書きします。 | | ||
+ | | [[vci/script/reference/vector3#Scale ]] | 2つのベクトルの各成分を乗算します。 | | ||
+ | | [[vci/script/reference/vector3#Cross ]] | 2つのベクトルの外積を計算します。 | | ||
+ | | [[vci/script/reference/vector3#GetHashCode ]] | ハッシュ値を求めます。 | | ||
+ | | [[vci/script/reference/vector3#Reflect ]] | inDirectionで指定したベクトルをinNormalで反射させます。 | | ||
+ | | [[vci/script/reference/vector3#Normalize ]] | ベクトルを正規化して単位ベクトルにします。 | | ||
+ | | [[vci/script/reference/vector3#Dot ]] | 2つのベクトルの内積を計算します。\\ | | ||
+ | | [[vci/script/reference/vector3#Project ]] | onNormalを基準としvectorを投影した時のベクトルを求めます。 | | ||
+ | | [[vci/script/reference/vector3#ProjectOnPlane ]] | planeNormalを法線ベクトルとする面へのvectorベクトルの投影ベクトルを求めます。 | | ||
+ | | [[vci/script/reference/vector3#Angle ]] | from,toの2つのベクトルが張る角度を度数法で返す。 | | ||
+ | | [[vci/script/reference/vector3#SignedAngle ]] | fromベクトルとtoベクトルの間の角度を符号付きで返します。正負はaxisの方向によって決定されます。 | | ||
+ | | [[vci/script/reference/vector3#Distance ]] | aとb、2点間の距離を計算します。 ※(a-b).magnitudeと同じ処理 | | ||
+ | | [[vci/script/reference/vector3#ClampMagnitude ]] | vectorの長さを最大maxLengthに制限します。vectorの長さがmaxLength以下の場合そのまま返します。maxLength以上の場合は方向はそのまま長さがmaxLengthになるように規格化します。 | | ||
+ | | [[vci/script/reference/vector3#Magnitude ]] | ベクトルの長さを求めます。 | | ||
+ | | [[vci/script/reference/vector3#SqrMagnitude ]] | ベクトルを二乗の長さを求めます。 | | ||
+ | | [[vci/script/reference/vector3#Min / Max |Min ]] | 2つのベクトルの各成分を比較して、最小の値でベクトルを作成します。 | | ||
+ | | [[vci/script/reference/vector3#Min / Max |Max ]] | 2つのベクトルの各成分を比較して、最大の値でベクトルを作成します。 | | ||
+ | | [[vci/script/reference/vector3#ToString ]] | 文字列に変換します | | ||
+ | | [[vci/script/reference/vector3#AngleBetween ]] | 単位がラジアンのAngle。fromとtoとの間の角度をラジアンで返します。符号は付きません。 | | ||
+ | | Exclude(非推奨) | ProjectOnPlaneと同じです。([[https://answers.unity.com/questions/25110/what-is-vector3exclude-for.html|unity4.6より非推奨のようです。]]ProjectOnPlaneを使用してください。) | | ||
+ | | [[vci/script/reference/vector3#normalized ]] | ベクトルの正規化を行います。(読み取り専用) | | ||
+ | | [[vci/script/reference/vector3#magnitude(num) ]] | ベクトルを長さとして読み取ります。 | | ||
+ | | [[vci/script/reference/vector3#sqrmagnitude(num) ]] | ベクトルを二乗の長さとして読み取ります。 | | ||
- | **メソッド一覧は[EmbeddedScriptWorkspace]フォルダ内の[types.lua]を開くと最新のメソッド一覧を確認できます。**\\ | ||
- | **表記の省略の為、''Vector3型'' は ''Vec3''、''number型'' は ''num'' と表記してあります。**\\ | ||
- | **引数は ''()'' の中に、戻り値の型は '':(セミコロン)'' の後に表記してあります。**\\ | ||
- | |||
- | | メソッド名 | 説明 | | ||
- | | [[vci/script/reference/vector3#slerp_球面補間 | Slerp (a: Vec3, b: Vec3, t: num): Vec3 ]] | 2つのベクトル間を t で球面補間します。t は[0, 1]の範囲です。 | | ||
- | | [[vci/script/reference/vector3#slerpunclamped_球面補間 | SlerpUnclamped (a: Vec3, b: Vec3, t: num): Vec3 ]] | Slerpと同じですが t の値を[0, 1]に制限しません。バネ等に使います。 | | ||
- | | [[vci/script/reference/vector3#orthonormalize | OrthoNormalize (normal: usertype, tangent: usertype) ]] | 正規化したベクトル、直交ベクトル、外積を作成します。 | | ||
- | | [[vci/script/reference/vector3#rotatetowards | RotateTowards (current, target, maxRadiansDelta, maxMagnitudeDelta): Vec3 ]] | currentの向きから、targetの向きまで回転させます。ただし、その際の最大速度はmaxRadiansDelta m/secに制限されます。 | | ||
- | | [[vci/script/reference/vector3#lerp_線形補間 | Lerp (a: Vec3, b: Vec3, t: num): Vec3 ]] | 2つのベクトル間を t で線形補間します。t は[0, 1]の範囲です。 | | ||
- | | [[vci/script/reference/vector3#lerpunclamped_線形補間 | LerpUnclamped (a: Vec3, b: Vec3, t: num): Vec3 ]] | Lerpと同じですが t の値を[0, 1]に制限しません。バネ等に使います。 | | ||
- | | [[vci/script/reference/vector3#movetowards | MoveTowards (current: Vec3, target: Vec3, maxDistanceDelta: num): Vec3 ]] | currentの位置から、targetの位置まで移動させます。ただし、その際の最大速度はmaxDistanceDelta m/secに制限されます。 | | ||
- | | [[vci/script/reference/vector3#smoothdamp | SmoothDamp (current: Vec3, target: Vec3, currentVelocity: usertype, smoothTime: num, maxSpeed: num): Vec3 ]] | 目的地に向かって時間の経過とともに徐々にベクトルを変化させます。 | | ||
- | | [[vci/script/reference/vector3#set_item | set_Item (index: num, value: num) ]] | Vector3の値をvalueで上書きします。index 0 = x, 1 = y, 2 = z | | ||
- | | [[vci/script/reference/vector3#set | Set (newX: num, newY: num, newZ: num) ]] | Vector3の値を上書きします。 | | ||
- | | [[vci/script/reference/vector3#scale | Scale (a: Vec3, b: Vec3): Vec3 ]] | 2つのベクトルの各成分を乗算します。 | | ||
- | | [[vci/script/reference/vector3#cross | Cross (lhs: Vec3, rhs: Vec3): Vec3 ]] | 2つのベクトルの外積を計算します。 | | ||
- | | [[vci/script/reference/vector3#gethashcode | GetHashCode (): num ]] | ハッシュ値を求めます。 | | ||
- | | [[vci/script/reference/vector3#reflect | Reflect (inDirection: Vec3, inNormal: Vec3): Vec3 ]] | inDirectionで指定したベクトルをinNormalで反射させます。 | | ||
- | | [[vci/script/reference/vector3#normalize | Normalize (value: Vec3): Vec3 ]] | ベクトルを正規化して単位ベクトルにします。 | | ||
- | | [[vci/script/reference/vector3#dot_%E5%86%85%E7%A9%8D | Dot (lhs: Vec3, rhs: Vec3): num ]] | 2つのベクトルの内積を計算します。\\ | | ||
- | | [[vci/script/reference/vector3#project | Project (vector: Vec3, onNormal: Vec3): Vec3 ]] | onNormalを基準としvectorを投影した時のベクトルを求めます。 | | ||
- | | [[vci/script/reference/vector3#projectonplane | ProjectOnPlane (vector: Vec3, planeNormal: Vec3): Vec3 ]] | planeNormalを法線ベクトルとする面へのvectorベクトルの投影ベクトルを求めます。 | | ||
- | | [[vci/script/reference/vector3#angle | Angle (from: Vec3, to: Vec3): num ]] | from,toの2つのベクトルが張る角度を度数法で返す。 | | ||
- | | [[vci/script/reference/vector3#signedangle | SignedAngle (from: Vec3, to: Vec3, axis: Vec3): num ]] | fromベクトルとtoベクトルの間の角度を符号付きで返します。正負はaxisの方向によって決定されます。 | | ||
- | | [[vci/script/reference/vector3#distance | Distance (a: Vec3, b: Vec3): num ]] | aとb、2点間の距離を計算します。 ※(a-b).magnitudeと同じ処理 | | ||
- | | [[vci/script/reference/vector3#clampmagnitude | ClampMagnitude (vector: Vec3, maxLength: num): Vec3 ]] | vectorの長さを最大maxLengthに制限します。vectorの長さがmaxLength以下の場合そのまま返します。maxLength以上の場合は方向はそのまま長さがmaxLengthになるように規格化します。 | | ||
- | | [[vci/script/reference/vector3#magnitude | Magnitude (vector: Vec3): num ]] | ベクトルの長さを求めます。 | | ||
- | | [[vci/script/reference/vector3#sqrmagnitude | SqrMagnitude (vector: Vec3): num ]] | ベクトルを二乗の長さを求めます。 | | ||
- | | [[vci/script/reference/vector3#min_max | Min (lhs: Vec3, rhs: Vec3): Vec3 ]] | 2つのベクトルの各成分を比較して、最小の値でベクトルを作成します。 | | ||
- | | [[vci/script/reference/vector3#min_max | Max (lhs: Vec3, rhs: Vec3): Vec3 ]] | 2つのベクトルの各成分を比較して、最大の値でベクトルを作成します。 | | ||
- | | [[vci/script/reference/vector3#tostring | ToString (): string ]] | 文字列に変換します | | ||
- | | [[vci/script/reference/vector3#anglebetween | AngleBetween (from: Vec3, to: Vec3): num ]] | 単位がラジアンのAngle。fromとtoとの間の角度をラジアンで返します。符号は付きません。 | | ||
- | | Exclude (excludeThis: Vec3, fromThat: Vec3): Vec3 | ProjectOnPlaneと同じです。([[https://answers.unity.com/questions/25110/what-is-vector3exclude-for.html|unity4.6より非推奨のようです。]]ProjectOnPlaneを使用してください。) | | ||
- | | [[vci/script/reference/vector3#normalized | normalized: Vec3 ]] | ベクトルの正規化を行います。(読み取り専用) | | ||
- | | [[vci/script/reference/vector3#magnitude1 | magnitude: num ]] | ベクトルを長さとして読み取ります。 | | ||
- | | [[vci/script/reference/vector3#sqrmagnitude1 | sqrMagnitude: num ]] | ベクトルを二乗の長さとして読み取ります。 | | ||
- | |||
- | ---- | ||
===== 初期化について ===== | ===== 初期化について ===== | ||
- | ==== 初期化周りのメソッド ==== | + | --> 初期化周りの関数 一覧 (クリックで展開) # |
- | | メソッド名 | 説明 | | + | ^ 名前 ^ 説明 ^ |
| _new (x: num, y: num, z: num): Vec3 | 初期化 新しいVector3を宣言する時に使用します | | | _new (x: num, y: num, z: num): Vec3 | 初期化 新しいVector3を宣言する時に使用します | | ||
| zero: Vec3 | (0.0, 0.0, 0.0) | | | zero: Vec3 | (0.0, 0.0, 0.0) | | ||
ライン 72: | ライン 64: | ||
| z: num | ''Vec3'' の ''z'' のみにアクセスします | | | z: num | ''Vec3'' の ''z'' のみにアクセスします | | ||
- | ---- | + | <-- |
サンプル\\ | サンプル\\ | ||
ライン 133: | ライン 125: | ||
説明\\ | 説明\\ | ||
X軸方向が左右 Y軸方向が上下 Z軸方向が前後 となるベクトルです。\\ | X軸方向が左右 Y軸方向が上下 Z軸方向が前後 となるベクトルです。\\ | ||
- | 例えば、[[vci:script:reference:exporttransform|ExportTransform]]のSetVelocity()を使ってVector3.forwardをSubItemのに加えれば、Z軸の方向に向かって移動します。\\ | + | 例えば、[[vci:script:reference:exporttransform|ExportTransform]]のSetVelocity()を使ってVector3.forwardをSubItemのに加えれば、Z軸の方向に向かって移動します。 |
ライン 157: | ライン 149: | ||
説明\\ | 説明\\ | ||
Infinityは無限を表します。AddForceで利用すると、目に見えない速度で飛んでいきます。\\ | Infinityは無限を表します。AddForceで利用すると、目に見えない速度で飛んでいきます。\\ | ||
- | Vector3.fwd は Vector3.forward と同じ意味です。\\ | + | Vector3.fwd は Vector3.forward と同じ意味です。 |
==== kEpsilon ==== | ==== kEpsilon ==== | ||
ライン 174: | ライン 166: | ||
9099999974737875E-06 | 9099999974737875E-06 | ||
</code> | </code> | ||
+ | |||
==== x y z の各要素へのアクセス ==== | ==== x y z の各要素へのアクセス ==== | ||
ライン 180: | ライン 173: | ||
local pos = Vector3.__new(1,1,1) | local pos = Vector3.__new(1,1,1) | ||
pos.x = pos.x + 1 | pos.x = pos.x + 1 | ||
- | pos.x = pos.y + 2 | + | pos.y = pos.y + 2 |
- | pos.x = pos.z + 3 | + | pos.z = pos.z + 3 |
print(pos.x) | print(pos.x) | ||
print(pos.y) | print(pos.y) | ||
ライン 195: | ライン 188: | ||
Vector3の各要素へ個別にアクセスする場合は、変数の末尾にアクセスしたい要素を指定します。\\ | Vector3の各要素へ個別にアクセスする場合は、変数の末尾にアクセスしたい要素を指定します。\\ | ||
- | **変数名.アクセスしたい要素** と書きます。\\ | + | **変数名.アクセスしたい要素** と書きます。 |
- | + | ===== Slerp ===== | |
- | ---- | + | |
- | + | ||
- | ===== Slerp (球面補間) ===== | + | |
**Slerp (a: Vec3, b: Vec3, t: num): Vec3** | **Slerp (a: Vec3, b: Vec3, t: num): Vec3** | ||
ライン 222: | ライン 212: | ||
2つのベクトル間を t で球面補間します。t は[0, 1]の範囲です。 | 2つのベクトル間を t で球面補間します。t は[0, 1]の範囲です。 | ||
- | ---- | + | ===== SlerpUnclamped ===== |
- | ===== SlerpUnclamped (球面補間) ===== | + | |
**SlerpUnclamped (a: Vec3, b: Vec3, t: num): Vec3** | **SlerpUnclamped (a: Vec3, b: Vec3, t: num): Vec3** | ||
ライン 245: | ライン 234: | ||
Slerpと同じですが t の値を[0, 1]に制限しません。バネ等に使います。 | Slerpと同じですが t の値を[0, 1]に制限しません。バネ等に使います。 | ||
- | ---- | ||
===== OrthoNormalize ===== | ===== OrthoNormalize ===== | ||
ライン 274: | ライン 262: | ||
説明\\ | 説明\\ | ||
- | 正規化したベクトル、直交ベクトル、外積を求めることが出来ます。\\ | + | 正規化したベクトル、直交ベクトル、外積を求めることが出来ます。 |
- | \\ | + | |
- | ---- | ||
===== RotateTowards ===== | ===== RotateTowards ===== | ||
ライン 302: | ライン 288: | ||
currentの向きから、targetの向きまで回転させます。ただし、その際の最大速度はmaxRadiansDelta m/secに制限されます。 | currentの向きから、targetの向きまで回転させます。ただし、その際の最大速度はmaxRadiansDelta m/secに制限されます。 | ||
- | ---- | + | ===== Lerp ===== |
- | + | ||
- | ===== Lerp (線形補間) ===== | + | |
**Lerp (a: Vec3, b: Vec3, t: num): Vec3** | **Lerp (a: Vec3, b: Vec3, t: num): Vec3** | ||
ライン 326: | ライン 310: | ||
2つのベクトル間を t で線形補間します。t は[0, 1]の範囲です。 | 2つのベクトル間を t で線形補間します。t は[0, 1]の範囲です。 | ||
- | ---- | + | ===== LerpUnclamped ===== |
- | ===== LerpUnclamped (線形補間) ===== | + | |
**LerpUnclamped (a: Vec3, b: Vec3, t: num): Vec3** | **LerpUnclamped (a: Vec3, b: Vec3, t: num): Vec3** | ||
ライン 349: | ライン 332: | ||
Lerpと同じですが t の値を[0, 1]に制限しません。バネ等に使います。 | Lerpと同じですが t の値を[0, 1]に制限しません。バネ等に使います。 | ||
- | ---- | ||
===== MoveTowards ===== | ===== MoveTowards ===== | ||
ライン 373: | ライン 355: | ||
currentの位置から、targetの位置まで移動させます。ただし、その際の最大速度はmaxDistanceDelta m/secに制限されます。 | currentの位置から、targetの位置まで移動させます。ただし、その際の最大速度はmaxDistanceDelta m/secに制限されます。 | ||
- | ---- | ||
===== SmoothDamp ===== | ===== SmoothDamp ===== | ||
- | **SmoothDamp (current: Vec3, target: Vec3, currentVelocity: usertype, smoothTime: num, maxSpeed: num): Vec3** | + | **SmoothDamp (current: Vec3, target: Vec3, currentVelocity: usertype, smoothTime: num, maxSpeed: num, deltaTime: num): (Vec3, Vec3)** |
サンプル\\ | サンプル\\ | ||
<file lua main.lua> | <file lua main.lua> | ||
- | local Subitem = vci.assets.GetTransform("Subitem") | + | local target = vci.assets.GetTransform("target") |
- | local Subitem2 = vci.assets.GetTransform("Subitem2") | + | local mover = vci.assets.GetTransform("mover") |
+ | local velocity = Vector3.zero | ||
+ | local prevTime = os.time() | ||
- | local ver = Vector3.zero | + | function update() |
+ | local time = os.time() | ||
+ | local deltaTime = time - prevTime; | ||
+ | prevTime = time | ||
+ | |||
+ | local position | ||
+ | position, velocity = Vector3.SmoothDamp(mover.GetPosition(), target.GetPosition(), velocity, 1.0, math.huge, deltaTime) | ||
- | function updateAll() | + | mover.SetPosition(position) |
- | local move = Vector3.SmoothDamp(Subitem2.GetPosition(), Subitem.GetPosition(), ver, 1, 1) | + | |
- | Subitem2.SetPosition(move) | + | |
end | end | ||
- | |||
</file> | </file> | ||
実行結果\\ | 実行結果\\ | ||
<code lua> | <code lua> | ||
- | Subitem2がSubitemに向かって動きます。 | + | "mover"が"target"に向かって動きます。 |
</code> | </code> | ||
ライン 399: | ライン 385: | ||
目的地に向かって時間の経過とともに徐々にベクトルを変化させます。 | 目的地に向かって時間の経過とともに徐々にベクトルを変化させます。 | ||
- | ---- | ||
===== set_Item ===== | ===== set_Item ===== | ||
ライン 434: | ライン 419: | ||
説明\\ | 説明\\ | ||
Vector3の値をvalueで上書きします。index 0 = x, 1 = y, 2 = z | Vector3の値をvalueで上書きします。index 0 = x, 1 = y, 2 = z | ||
- | ---- | + | |
===== Set ===== | ===== Set ===== | ||
ライン 461: | ライン 446: | ||
説明\\ | 説明\\ | ||
Vector3の値を上書きします。 | Vector3の値を上書きします。 | ||
- | ---- | + | |
===== Scale ===== | ===== Scale ===== | ||
ライン 490: | ライン 475: | ||
説明\\ | 説明\\ | ||
2つのベクトルの各成分を乗算します。 | 2つのベクトルの各成分を乗算します。 | ||
- | ---- | + | |
===== Cross ===== | ===== Cross ===== | ||
ライン 529: | ライン 514: | ||
説明\\ | 説明\\ | ||
2つのベクトルの外積を計算します。 | 2つのベクトルの外積を計算します。 | ||
- | ---- | + | |
===== GetHashCode ===== | ===== GetHashCode ===== | ||
ライン 566: | ライン 551: | ||
Vector3に対してハッシュ値を求めます。\\ | Vector3に対してハッシュ値を求めます。\\ | ||
VCIを再読み込みしたり部屋から退出するとハッシュ値が変わります。 | VCIを再読み込みしたり部屋から退出するとハッシュ値が変わります。 | ||
- | ---- | + | |
===== Reflect ===== | ===== Reflect ===== | ||
ライン 590: | ライン 575: | ||
inDirectionで指定したベクトルをinNormalで反射させます。\\ | inDirectionで指定したベクトルをinNormalで反射させます。\\ | ||
第一引数に反射させたいベクトル、第二引数に反射させたい面の法線ベクトルを指定します。 | 第一引数に反射させたいベクトル、第二引数に反射させたい面の法線ベクトルを指定します。 | ||
- | |||
- | ---- | ||
===== Normalize ===== | ===== Normalize ===== | ||
ライン 616: | ライン 599: | ||
ベクトルを方向として扱いたい場合、長さを1に揃えて方向のみの要素として扱う必要があります。 | ベクトルを方向として扱いたい場合、長さを1に揃えて方向のみの要素として扱う必要があります。 | ||
- | ---- | + | ===== Dot ===== |
- | + | ||
- | + | ||
- | ===== Dot (内積) ===== | + | |
**Dot (lhs: Vec3, rhs: Vec3): num** | **Dot (lhs: Vec3, rhs: Vec3): num** | ||
ライン 640: | ライン 620: | ||
説明\\ | 説明\\ | ||
2つのベクトルの内積を計算します。 | 2つのベクトルの内積を計算します。 | ||
- | ---- | + | |
===== Project ===== | ===== Project ===== | ||
ライン 666: | ライン 646: | ||
説明\\ | 説明\\ | ||
onNormalを基準としvectorを投影した時のベクトルを求めます。 | onNormalを基準としvectorを投影した時のベクトルを求めます。 | ||
- | \\ | ||
- | ---- | ||
===== ProjectOnPlane ===== | ===== ProjectOnPlane ===== | ||
ライン 722: | ライン 700: | ||
planeNormalを法線ベクトルとする面へのvectorベクトルの投影ベクトルを求めます。 | planeNormalを法線ベクトルとする面へのvectorベクトルの投影ベクトルを求めます。 | ||
- | ---- | ||
===== Angle ===== | ===== Angle ===== | ||
ライン 749: | ライン 726: | ||
from,toの2つのベクトルが張る角度を度数法で返す。 | from,toの2つのベクトルが張る角度を度数法で返す。 | ||
- | ---- | ||
===== SignedAngle ===== | ===== SignedAngle ===== | ||
ライン 776: | ライン 752: | ||
説明\\ | 説明\\ | ||
fromベクトルとtoベクトルの間の角度を符号付きで返します。正負はaxisの方向によって決定されます。 | fromベクトルとtoベクトルの間の角度を符号付きで返します。正負はaxisの方向によって決定されます。 | ||
- | ---- | ||
===== Distance ===== | ===== Distance ===== | ||
ライン 809: | ライン 784: | ||
aとb、2点間の距離を計算します。 ※(a-b).magnitudeと同じ処理 | aとb、2点間の距離を計算します。 ※(a-b).magnitudeと同じ処理 | ||
- | ---- | ||
===== ClampMagnitude ===== | ===== ClampMagnitude ===== | ||
ライン 837: | ライン 811: | ||
vectorの長さがmaxLength以下の場合そのまま返します。\\ | vectorの長さがmaxLength以下の場合そのまま返します。\\ | ||
maxLength以上の場合は方向はそのまま長さがmaxLengthになるように規格化します。\\ | maxLength以上の場合は方向はそのまま長さがmaxLengthになるように規格化します。\\ | ||
- | ---- | ||
===== Magnitude ===== | ===== Magnitude ===== | ||
ライン 858: | ライン 831: | ||
説明\\ | 説明\\ | ||
ベクトルの長さを求めます。 | ベクトルの長さを求めます。 | ||
- | ---- | + | |
===== SqrMagnitude ===== | ===== SqrMagnitude ===== | ||
ライン 879: | ライン 852: | ||
ベクトルを二乗の長さを求めます。 | ベクトルを二乗の長さを求めます。 | ||
- | ---- | + | ===== Min / Max ===== |
- | ===== Min,Max ===== | + | |
**Min (lhs: Vec3, rhs: Vec3): Vec3**\\ | **Min (lhs: Vec3, rhs: Vec3): Vec3**\\ | ||
ライン 910: | ライン 882: | ||
2つのベクトルの各成分を比較して、最小(Min)、最大(Max)の値でベクトルを作成します。 | 2つのベクトルの各成分を比較して、最小(Min)、最大(Max)の値でベクトルを作成します。 | ||
- | ---- | ||
===== ToString ===== | ===== ToString ===== | ||
ライン 933: | ライン 904: | ||
文字列に変換します。\\ | 文字列に変換します。\\ | ||
- | ---- | ||
===== AngleBetween ===== | ===== AngleBetween ===== | ||
ライン 959: | ライン 929: | ||
単位がラジアンのAngle。fromとtoとの間の角度をラジアンで返します。符号は付きません。 | 単位がラジアンのAngle。fromとtoとの間の角度をラジアンで返します。符号は付きません。 | ||
180度 = 3.14159... | 180度 = 3.14159... | ||
- | \\ | + | |
- | ---- | + | |
===== normalized ===== | ===== normalized ===== | ||
ライン 985: | ライン 954: | ||
ベクトルを方向として扱いたい場合、長さを1に揃えて方向のみの要素として扱う必要があります。 | ベクトルを方向として扱いたい場合、長さを1に揃えて方向のみの要素として扱う必要があります。 | ||
- | ---- | + | ===== magnitude(num) ===== |
- | ===== magnitude ===== | + | |
**magnitude: num** | **magnitude: num** | ||
ライン 1006: | ライン 974: | ||
説明\\ | 説明\\ | ||
ベクトルを長さとして読み取ります。 | ベクトルを長さとして読み取ります。 | ||
- | \\ | + | |
- | ---- | + | ===== sqrMagnitude(num) ===== |
- | ===== sqrMagnitude ===== | + | |
**sqrMagnitude: num** | **sqrMagnitude: num** | ||
ライン 1028: | ライン 995: | ||
説明\\ | 説明\\ | ||
ベクトルを二乗の長さとして読み取ります。 | ベクトルを二乗の長さとして読み取ります。 | ||
- | \\ | + | |
- | ---- | + |