GeoMath¶
数学ユーティリティー
数学関連の関数または定数を定義するユーティリティークラスである。 このクラスは static メンバーしか持たない。
Properties¶
DEGREE¶
staticreadonlyDEGREE:number=0.017453292519943295769
1度に対応するラジアンの数値
この数値は π / 180 である。
度数を DEGREE で掛け合せることによってラジアンに変換することができる。
EARTH_RADIUS¶
staticreadonlyEARTH_RADIUS:number=6378137
地球の半径
Inou 球面座標系で定義された、地球の半径 (Meters) である。
LOG2PI¶
staticreadonlyLOG2PI:number=1.6514961294723187980
log2(π)
Methods¶
add2()¶
staticadd2(a,b,dst):Vector2
2 次ベクトルの和を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Vector2 |
左のベクトル |
b |
Vector2 |
右のベクトル |
dst |
Vector2 |
計算結果を格納するバッファ |
Returns¶
a と b の和
add3()¶
staticadd3(a,b,dst):Vector3
3 次ベクトルの和を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Vector3 |
左のベクトル |
b |
Vector3 |
右のベクトル |
dst |
Vector3 |
計算結果を格納するバッファ |
Returns¶
a と b の和
clamp()¶
staticclamp(x,min,max):number
値を指定区間内に制限
Parameters¶
| Parameter | Type | Description |
|---|---|---|
x |
number |
値 |
min |
number |
最小値 |
max |
number |
最大値 |
Returns¶
number
min <= x <= max のとき x, x < min のとき min, x > max のとき max
conjugate_quat()¶
staticconjugate_quat(q,dst):Vector4
四元数の複素共役を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
q |
Vector4 |
四元数 |
dst |
Vector4 |
結果を代入する四元数 |
Returns¶
dst
copyMatrix()¶
staticcopyMatrix(src,dst):Matrix
行列を代入
src を dst に代入する。
Parameters¶
| Parameter | Type | Description |
|---|---|---|
src |
Matrix |
代入元 |
dst |
Matrix |
代入先 |
Returns¶
dst
copyVector2()¶
staticcopyVector2<T>(src,dst):T
2 次ベクトルを代入
src を dst に代入する。
Type parameters¶
| Type parameter |
|---|
T extends Vector4 | Vector3 | Vector2 |
Parameters¶
| Parameter | Type | Description |
|---|---|---|
src |
Vector4 | Vector3 | Vector2 |
代入元 |
dst |
T |
代入先 |
Returns¶
T
dst
copyVector3()¶
staticcopyVector3<T>(src,dst):T
3 次ベクトルを代入
src を dst に代入する。
Type parameters¶
| Type parameter |
|---|
T extends Vector4 | Vector3 |
Parameters¶
| Parameter | Type | Description |
|---|---|---|
src |
Vector4 | Vector3 |
代入元 |
dst |
T |
代入先 |
Returns¶
T
dst
copyVector4()¶
staticcopyVector4(src,dst):Vector4
4 次ベクトルを代入
src を dst に代入する。
Parameters¶
| Parameter | Type | Description |
|---|---|---|
src |
Vector4 |
代入元 |
dst |
Vector4 |
代入先 |
Returns¶
dst
createMatrix()¶
staticcreateMatrix(mat?):Matrix
行列オブジェクトを作成
mat を複製する。ただし mat を省略したときは、すべての要素が 0 の行列を生成する。
Parameters¶
| Parameter | Type | Description |
|---|---|---|
mat? |
Matrix |
入力行列 |
Returns¶
新しい行列
createVector2()¶
staticcreateVector2(vec?):Vector2
2 次ベクトルの生成 vec を複製して 2 次ベクトルを生成する。ただし vec を省略したときは、すべての要素が 0 のベクトルを生成する。
Parameters¶
| Parameter | Type | Description |
|---|---|---|
vec? |
Vector2 |
入力ベクトル |
Returns¶
新しいベクトル
createVector3()¶
staticcreateVector3(vec?):Vector3
3 次ベクトルの生成 vec を複製して 3 次ベクトルを生成する。ただし vec を省略したときは、すべての要素が 0 のベクトルを生成する。
Parameters¶
| Parameter | Type | Description |
|---|---|---|
vec? |
Vector3 |
入力ベクトル |
Returns¶
新しいベクトル
createVector4()¶
staticcreateVector4(vec?):Vector4
4 次ベクトルの生成
vec を複製して 4 次ベクトルを生成する。ただし vec を省略したときは、すべての要素が 0 のベクトルを生成する。
Parameters¶
| Parameter | Type | Description |
|---|---|---|
vec? |
Vector4 |
入力ベクトル |
Returns¶
新しいベクトル
cross3()¶
staticcross3(a,b,dst):Vector3
3次ベクトルの外積を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Vector3 |
左のベクトル |
b |
Vector3 |
右のベクトル |
dst |
Vector3 |
a と b の外積を代入するベクトル |
Returns¶
dst
dot2()¶
staticdot2(a,b):number
2 次ベクトルの内積を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Vector2 |
左のベクトル |
b |
Vector2 |
右のベクトル |
Returns¶
number
a と b の内積
dot3()¶
staticdot3(a,b):number
3 次ベクトルの内積を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Vector3 |
左のベクトル |
b |
Vector3 |
右のベクトル |
Returns¶
number
a と b の内積
dot4()¶
staticdot4(a,b):number
4 次ベクトルの内積を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Vector4 |
左のベクトル |
b |
Vector4 |
右のベクトル |
Returns¶
number
a と b の内積
frustum_matrix()¶
staticfrustum_matrix(left,right,bottom,top,nearVal,farVal,dst):Matrix
座標変換行列を計算 (視点座標系 → クリップ同次座標系)
Parameters¶
| Parameter | Type | Description |
|---|---|---|
left |
number |
|
right |
number |
|
bottom |
number |
|
top |
number |
|
nearVal |
number |
|
farVal |
number |
|
dst |
Matrix |
結果を代入する行列 |
Returns¶
dst
See¶
https://www.opengl.org/sdk/docs/man2/xhtml/glFrustum.xml
~~gocs_to_iscs()~~¶
staticgocs_to_iscs(src,dst):GeoPointData
地心直交座標を Inou 球面座標に変換
Parameters¶
| Parameter | Type | Description |
|---|---|---|
src |
Vector3 |
入力 GOCS 座標 (Meters) |
dst |
GeoPointData |
出力 ISCS 座標 |
Returns¶
dst
Deprecated¶
mapray.GeoPoint.setFromGocs の使用を推奨
gudermannian()¶
staticgudermannian(x):number
グーデルマン関数
Parameters¶
| Parameter | Type | Description |
|---|---|---|
x |
number |
数値 |
Returns¶
number
gd( x )
invGudermannian()¶
staticinvGudermannian(x):number
逆グーデルマン関数
Parameters¶
| Parameter | Type | Description |
|---|---|---|
x |
number |
数値 |
Returns¶
number
gd-1( x )
inverse_A()¶
staticinverse_A(mat,dst):Matrix
逆行列を計算 (アフィン変換)
Parameters¶
| Parameter | Type | Description |
|---|---|---|
mat |
Matrix |
行列 |
dst |
Matrix |
結果を代入する行列 |
Returns¶
dst
inverse_quat()¶
staticinverse_quat(q,dst):Vector4
逆四元数の計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
q |
Vector4 |
四元数 |
dst |
Vector4 |
結果を代入する四元数 |
Returns¶
dst
isVector2()¶
staticisVector2(vec):vec is Vector2
2次ベクトルであるかを判定
Parameters¶
| Parameter | Type |
|---|---|
vec |
Vector4 | Vector3 | Vector2 |
Returns¶
vec is Vector2
isVector3()¶
staticisVector3(vec):vec is Vector3
3次ベクトルであるかを判定
Parameters¶
| Parameter | Type |
|---|---|
vec |
Vector4 | Vector3 | Vector2 |
Returns¶
vec is Vector3
isVector4()¶
staticisVector4(vec):vec is Vector4
4次ベクトルであるかを判定
Parameters¶
| Parameter | Type |
|---|---|
vec |
Vector4 | Vector3 | Vector2 |
Returns¶
vec is Vector4
~~iscs_to_gocs_matrix()~~¶
staticiscs_to_gocs_matrix(position,dst):Matrix
座標変換行列を計算 (Inou 球面座標系 → 地心直交座標系)
原点が position の直交座標系 (LOCS) から地心直交座標系 (GOCS) に変換する行列を計算する。 position.height + GeoMath.EARTH_RADIUS > 0 かつ position.latitude == 0 のとき、LOCS の Z 軸は上方向、Y 軸は北方向、X 軸は東方向となる。
Parameters¶
| Parameter | Type | Description |
|---|---|---|
position |
GeoPointData |
位置 (Inou 球面座標系) |
dst |
Matrix |
結果を代入する行列 |
Returns¶
dst
Deprecated¶
mapray.GeoPoint.getMlocsToGocsMatrix の使用を推奨
~~kml_model_matrix()~~¶
statickml_model_matrix(heading,tilt,roll,scale,dst):Matrix
KML 互換のモデル変換行列
変換は scale -> roll -> tilt -> heading の順に行われる。
Parameters¶
| Parameter | Type | Description |
|---|---|---|
heading |
number |
Z 軸を中心に Y 軸から X 軸の方向の回転角 (Degrees) |
tilt |
number |
X 軸を中心に Z 軸から Y 軸の方向の回転角 (Degrees) |
roll |
number |
Y 軸を中心に X 軸から Z 軸の方向の回転角 (Degrees) |
scale |
Vector3 |
スケール |
dst |
Matrix |
結果を代入する行列 |
Returns¶
dst
Package¶
See¶
https://developers.google.com/kml/documentation/kmlreference#model
Deprecated¶
mapray.Orientation.getTransformMatrix の使用を推奨
length2()¶
staticlength2(vec):number
2 次ベクトルの長さを計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
vec |
Vector2 |
ベクトル |
Returns¶
number
ベクトルの長さ
length3()¶
staticlength3(vec):number
3 次ベクトルの長さを計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
vec |
Vector3 |
ベクトル |
Returns¶
number
ベクトルの長さ
length4()¶
staticlength4(vec):number
4 次ベクトルの長さを計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
vec |
Vector4 |
ベクトル |
Returns¶
number
ベクトルの長さ
lengthSquared2()¶
staticlengthSquared2(vec):number
2 次ベクトルの長さの2乗を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
vec |
Vector2 |
ベクトル |
Returns¶
number
ベクトルの長さの2乗
lengthSquared3()¶
staticlengthSquared3(vec):number
3 次ベクトルの長さの2乗を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
vec |
Vector3 |
ベクトル |
Returns¶
number
ベクトルの長さの2乗
lengthSquared4()¶
staticlengthSquared4(vec):number
4 次ベクトルの長さの2乗を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
vec |
Vector4 |
ベクトル |
Returns¶
number
ベクトルの長さの2乗
linearInterpolate2()¶
staticlinearInterpolate2(a,b,t,dst):Vector2
2次ベクトルの線形補間を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Vector2 |
ベクトル |
b |
Vector2 |
ベクトル |
t |
number |
補間パラメータ |
dst |
Vector2 |
計算結果を代入するベクトル |
Returns¶
dst
linearInterpolate3()¶
staticlinearInterpolate3(a,b,t,dst):Vector3
3次ベクトルの線形補間を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Vector3 |
ベクトル |
b |
Vector3 |
ベクトル |
t |
number |
補間パラメータ |
dst |
Vector3 |
計算結果を代入するベクトル |
Returns¶
dst
linearInterpolate4()¶
staticlinearInterpolate4(a,b,t,dst):Vector4
4次ベクトルの線形補間を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Vector4 |
ベクトル |
b |
Vector4 |
ベクトル |
t |
number |
補間パラメータ |
dst |
Vector4 |
計算結果を代入するベクトル |
Returns¶
dst
lookat_matrix()¶
staticlookat_matrix(eye,center,up,dst):Matrix
座標変換行列を計算 (右手座標系 → 視点座標系)
Parameters¶
| Parameter | Type | Description |
|---|---|---|
eye |
Vector3 |
視点の位置 |
center |
Vector3 |
注視点の位置 |
up |
Vector3 |
上方向ベクトル |
dst |
Matrix |
結果を代入する行列 |
Returns¶
dst
matrix_to_quat()¶
staticmatrix_to_quat(mat,dst):Vector4
行列と同じ回転を表す四元数を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
mat |
Matrix |
行列 |
dst |
Vector4 |
結果を代入する四元数 |
Returns¶
dst
mul_AA()¶
staticmul_AA(a,b,dst):Matrix
行列の積を計算 (アフィン変換 x アフィン変換)
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Matrix |
左の行列 |
b |
Matrix |
右の行列 |
dst |
Matrix |
結果を代入する行列 |
Returns¶
dst
mul_GA()¶
staticmul_GA(a,b,dst):Matrix
行列の積を計算 (一般変換 x アフィン変換)
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Matrix |
左の行列 |
b |
Matrix |
右の行列 |
dst |
Matrix |
結果を代入する行列 |
Returns¶
dst
mul_PzA()¶
staticmul_PzA(a,b,dst):Matrix
行列の積を計算 (投影変換 x アフィン変換)
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Matrix |
左の行列 |
b |
Matrix |
右の行列 |
dst |
Matrix |
結果を代入する行列 |
Returns¶
dst
mul_quat()¶
staticmul_quat(p,q,dst):Vector4
四元数の積を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
p |
Vector4 |
左の四元数 |
q |
Vector4 |
右の四元数 |
dst |
Vector4 |
結果を代入する四元数 |
Returns¶
dst
normalize2()¶
staticnormalize2(vec,dst):Vector2
2次ベクトルの正規化を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
vec |
Vector2 |
ベクトル |
dst |
Vector2 |
正規化された値を代入するベクトル |
Returns¶
dst
normalize3()¶
staticnormalize3(vec,dst):Vector3
3次ベクトルの正規化を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
vec |
Vector3 |
ベクトル |
dst |
Vector3 |
正規化された値を代入するベクトル |
Returns¶
dst
normalize4()¶
staticnormalize4(vec,dst):Vector4
4次ベクトルの正規化を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
vec |
Vector4 |
ベクトル |
dst |
Vector4 |
正規化された値を代入するベクトル |
Returns¶
dst
normalizePlane()¶
staticnormalizePlane(plane,dst):Vector4
平面ベクトルの正規化を計算
法線部 (最初の 3 要素) の長さが 1 になるように平面ベクトル plane を正規化し、dst に代入する。
Parameters¶
| Parameter | Type | Description |
|---|---|---|
plane |
Vector4 |
平面ベクトル |
dst |
Vector4 |
正規化された値を代入するベクトル |
Returns¶
dst
quat_to_matrix()¶
staticquat_to_matrix(scale,quat,dst):Matrix
四元数と同じ回転を表す行列を計算。 平行移動成分は (0, 0, 0) になります。
Parameters¶
| Parameter | Type | Description |
|---|---|---|
scale |
Vector3 |
スケール |
quat |
Vector4 |
四元数 |
dst |
Matrix |
結果を代入する行列 |
Returns¶
dst
rotation_matrix()¶
staticrotation_matrix(axis,angle,dst):Matrix
任意軸回りの回転行列
axis を Z 軸方向とすると、X 軸から Y 軸の方向に angle 度回転させる変換行列を返す。
Parameters¶
| Parameter | Type | Description |
|---|---|---|
axis |
Vector3 |
回転軸 (単位ベクトル) |
angle |
number |
回転角 (Degrees) |
dst |
Matrix |
結果を代入する行列 |
Returns¶
dst
rotation_quat()¶
staticrotation_quat(axis,angle,dst):Vector4
任意軸周りに回転する四元数を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
axis |
Vector3 |
回転軸 |
angle |
number |
回転角 (Degrees) |
dst |
Vector4 |
結果を代入する四元数 |
Returns¶
dst
scale2()¶
staticscale2(a,vec,dst):Vector2
2次ベクトルのスカラ倍を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
number |
スカラ |
vec |
Vector2 |
ベクトル |
dst |
Vector2 |
計算結果を代入するベクトル |
Returns¶
dst
scale3()¶
staticscale3(a,vec,dst):Vector3
3次ベクトルのスカラ倍を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
number |
スカラ |
vec |
Vector3 |
ベクトル |
dst |
Vector3 |
計算結果を代入するベクトル |
Returns¶
dst
scale4()¶
staticscale4(a,vec,dst):Vector4
4次ベクトルのスカラ倍を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
number |
スカラ |
vec |
Vector4 |
ベクトル |
dst |
Vector4 |
計算結果を代入するベクトル |
Returns¶
dst
setIdentity()¶
staticsetIdentity(dst):Matrix
恒等行列を設定
Parameters¶
| Parameter | Type | Description |
|---|---|---|
dst |
Matrix |
結果を代入する行列 |
Returns¶
dst
slerp_quat()¶
staticslerp_quat(q1,q2,alpha,dst):Vector4
球面線形補間を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
q1 |
Vector4 |
四元数(単位ベクトル) |
q2 |
Vector4 |
四元数(単位ベクトル) |
alpha |
number |
補間、0 ≤ alpha ≤ 1 |
dst |
Vector4 |
結果を代入する四元数 |
Returns¶
dst
sub2()¶
staticsub2(a,b,dst):Vector2
2 次ベクトルの差を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Vector2 |
左のベクトル |
b |
Vector2 |
右のベクトル |
dst |
Vector2 |
計算結果を格納するバッファ |
Returns¶
a と b の差
sub3()¶
staticsub3(a,b,dst):Vector3
3 次ベクトルの差を計算
Parameters¶
| Parameter | Type | Description |
|---|---|---|
a |
Vector3 |
左のベクトル |
b |
Vector3 |
右のベクトル |
dst |
Vector3 |
計算結果を格納するバッファ |
Returns¶
a と b の差
transformDirection_A()¶
statictransformDirection_A(mat,dir,dst):Vector3
方向を変換 (アフィン変換)
方向 dir を変換行列 mat により座標変換して dst に代入する。
mat は dir が想定する座標系から、ある座標系へ方向ベクトルを変換するための行列である。
Parameters¶
| Parameter | Type | Description |
|---|---|---|
mat |
Matrix |
変換行列 |
dir |
Vector3 |
方向 |
dst |
Vector3 |
結果を代入するベクトル |
Returns¶
dst
transformPlane_A()¶
statictransformPlane_A(mat,plane,dst):Vector4
平面ベクトルを変換 (アフィン変換)
mat には平面ベクトルを変換する行列を指定する。 位置ベクトルを変換する行列が M なら、平面ベクトルを変換する行列は M-1 を指定する。
dst には plane * mat が代入される。
Parameters¶
| Parameter | Type | Description |
|---|---|---|
mat |
Matrix |
変換行列 |
plane |
Vector4 |
平面ベクトル |
dst |
Vector4 |
結果を代入するベクトル |
Returns¶
dst
transformPosition_A()¶
statictransformPosition_A<T>(mat,pos,dst):T
位置を変換 (アフィン変換)
位置 pos を変換行列 mat により座標変換して dst に代入する。
mat は pos が想定する座標系から、ある座標系へ位置ベクトルを変換するための行列である。
Type parameters¶
| Type parameter |
|---|
T extends Vector3 | Vector2 |
Parameters¶
| Parameter | Type | Description |
|---|---|---|
mat |
Matrix |
変換行列 |
pos |
Vector3 | Vector2 |
位置 |
dst |
T |
結果を代入するベクトル |
Returns¶
T
dst