AGI.Foundation.Coordinates命名空間中提供了各種平移和旋轉(zhuǎn)坐標(biāo)類型。這些類型提供了以通用n元組(n-tuple)的方式,表示點(diǎn)的位置和軸的方向以及它們的導(dǎo)數(shù)。相關(guān)坐標(biāo)之間可以進(jìn)行相互轉(zhuǎn)換。
1. 坐標(biāo)
在STK組件中按照維度,坐標(biāo)可分為:二維坐標(biāo)、三維坐標(biāo)和四維坐標(biāo)。坐標(biāo)類型可分為直線坐標(biāo)和曲線坐標(biāo)。
1.1. 二維坐標(biāo)
- 直線坐標(biāo)
-
Rectangular(x, y):直角坐標(biāo) -
UnitRectangular(x, y):單位直角坐標(biāo)
-
- 曲線坐標(biāo)
-
Polar(clock, radial):極坐標(biāo)
-
1.2. 三維坐標(biāo)
- 直線坐標(biāo)
-
Cartesian(x, y, z):笛卡爾坐標(biāo) -
UnitCartesian(x, y, z):單位笛卡爾坐標(biāo)
-
- 曲線坐標(biāo)
-
AzimuthElevationRange(azimuth, elevation, range):由方位、仰角、距離組成的坐標(biāo) -
AzimuthHorizontalVertical(azimuth, horizontal, vertical):由方位、水平值、垂直值組成的坐標(biāo) -
Cartographic(longitude, latitude, height):由經(jīng)度、緯度、高度組成的地理坐標(biāo) -
Cylindrical(clock, radial, z):由時(shí)角、半徑、Z值組成的圓柱坐標(biāo) -
LongitudeLatitudeRadius (longitude, latitude, radius):經(jīng)緯半徑坐標(biāo) -
Pyramidal(zxAngle, zyAngle, z):金字塔坐標(biāo) -
Spherical (clock, cone, magnitude):球坐標(biāo) -
UnitSpherical (clock, cone):單位球坐標(biāo)
-
1.3. 四維坐標(biāo)
四維坐標(biāo)用于表示三維空間的旋轉(zhuǎn):
Quaternion(w, x, y, z)UnitQuaternion(w, x, y, z)
1.4. 示例
- 球坐標(biāo)轉(zhuǎn)為笛卡爾坐標(biāo)
var spherical0 = new Spherical(Math.PI / 4, Math.PI / 8, 100.0);
var cartesian0 = new Cartesian(spherical0);
Console.WriteLine("球坐標(biāo):{0};笛卡爾坐標(biāo):{1}", spherical0, cartesian0);
- 笛卡爾坐標(biāo)歸一化
UnitCartesian unitCartesian1 = cartesian0.Normalize();
Console.WriteLine("單位矢量笛卡爾坐標(biāo):{0}", unitCartesian1);
- 地圖坐標(biāo)轉(zhuǎn)為笛卡爾坐標(biāo)
var cartographic2 = new Cartographic(Trig.DegreesToRadians(120),Trig.DegreesToRadians(30),100);
EarthCentralBody earth = CentralBodiesFacet.GetFromContext().Earth;
Cartesian cartesian2 = earth.Shape.CartographicToCartesian(cartographic2);
Console.WriteLine("地圖坐標(biāo):{0};笛卡爾坐標(biāo):{1}", cartographic2, cartesian2);
- 笛卡爾坐標(biāo)轉(zhuǎn)為地圖坐標(biāo)
Cartographic cartographic3 = earth.Shape.CartesianToCartographic(cartesian2);
Console.WriteLine("笛卡爾坐標(biāo):{0};地圖坐標(biāo):{1}", cartesian2, cartographic3);
2. 旋轉(zhuǎn)
此處的旋轉(zhuǎn),是指原坐標(biāo)系采用某種方式旋轉(zhuǎn)成新坐標(biāo)系。旋轉(zhuǎn)矩陣×原向量,得到新坐標(biāo)系中的新向量值。
2.1. 旋轉(zhuǎn)方式
-
AngleAxisRotation(angle, axis):繞任意軸旋轉(zhuǎn)指定的角度 -
ElementaryRotation(axis, angle):繞主軸旋轉(zhuǎn)指定的角度 -
EulerSequence(angle1, angle2, angle3, sequence):按照指定的順序進(jìn)行三次坐標(biāo)旋轉(zhuǎn),后一次旋轉(zhuǎn)是在前一次旋轉(zhuǎn)產(chǎn)生的新坐標(biāo)系的基礎(chǔ)上進(jìn)行 -
YawPitchRoll(angle1, angle2, angle3, sequence):按照指定的順序進(jìn)行三次坐標(biāo)旋轉(zhuǎn),每次旋轉(zhuǎn)都是繞原始坐標(biāo)系的主軸
2.2. 旋轉(zhuǎn)矩陣
結(jié)構(gòu)Matrix3By3表示3×3的旋轉(zhuǎn)矩陣,可以由不同的旋轉(zhuǎn)方式得到。旋轉(zhuǎn)矩陣與某個(gè)3維向量相乘,即可得到該向量旋轉(zhuǎn)后的向量。
2.3. 示例
- 新坐標(biāo)系繞原坐標(biāo)系z(mì)軸旋轉(zhuǎn)90度,原向量(1,0,0)
var vector4 = new Cartesian(1, 0, 0);
var rotation4 = new ElementaryRotation(AxisIndicator.Third, Trig.DegreesToRadians(-90));
Cartesian newVector4 = new Matrix3By3(rotation4).Multiply(vector4);
Console.WriteLine("旋轉(zhuǎn)前:{0};旋轉(zhuǎn)后:{1}", vector4, newVector4);
- 歐拉旋轉(zhuǎn)
var vector5 = new Cartesian(1, 0, 0);
double angle = Trig.DegreesToRadians(90);
var euler = new EulerSequence(angle, angle, angle, EulerSequenceIndicator.Euler321);
Cartesian newVector5 = new Matrix3By3(euler).Multiply(vector5);
Console.WriteLine("旋轉(zhuǎn)前:{0};旋轉(zhuǎn)后:{1}", vector5, newVector5);
- 偏航俯仰翻滾旋轉(zhuǎn)
var vector6 = new Cartesian(1, 0, 0);
double angle6 = Trig.DegreesToRadians(90);
var ypr = new YawPitchRoll(angle, angle, angle, YawPitchRollIndicator.YPR);
Cartesian newVector6 = new Matrix3By3(ypr).Multiply(vector6);
Console.WriteLine("旋轉(zhuǎn)前:{0};旋轉(zhuǎn)后:{1}", vector6, newVector6);
源代碼地址
https://github.com/icgp/STKComponentsTutorial/blob/master/Example004/Example004.cs