STK Components二次开发

STK组件基础篇:坐标与旋转

2019-05-18  本文已影响0人  奔跑伯爵

AGI.Foundation.Coordinates命名空间中提供了各种平移和旋转坐标类型。这些类型提供了以通用n元组(n-tuple)的方式,表示点的位置和轴的方向以及它们的导数。相关坐标之间可以进行相互转换。

1. 坐标

在STK组件中按照维度,坐标可分为:二维坐标、三维坐标和四维坐标。坐标类型可分为直线坐标和曲线坐标。

1.1. 二维坐标

1.2. 三维坐标

1.3. 四维坐标

四维坐标用于表示三维空间的旋转:

1.4. 示例

var spherical0 = new Spherical(Math.PI / 4, Math.PI / 8, 100.0);
var cartesian0 = new Cartesian(spherical0);
Console.WriteLine("球坐标:{0};笛卡尔坐标:{1}", spherical0, cartesian0);
UnitCartesian unitCartesian1 = cartesian0.Normalize();
Console.WriteLine("单位矢量笛卡尔坐标:{0}", unitCartesian1);
var cartographic2 = new Cartographic(Trig.DegreesToRadians(120),Trig.DegreesToRadians(30),100);
EarthCentralBody earth = CentralBodiesFacet.GetFromContext().Earth;
Cartesian cartesian2 = earth.Shape.CartographicToCartesian(cartographic2);
Console.WriteLine("地图坐标:{0};笛卡尔坐标:{1}", cartographic2, cartesian2);
Cartographic cartographic3 = earth.Shape.CartesianToCartographic(cartesian2);
Console.WriteLine("笛卡尔坐标:{0};地图坐标:{1}", cartesian2, cartographic3);

2. 旋转

此处的旋转,是指原坐标系采用某种方式旋转成新坐标系。旋转矩阵×原向量,得到新坐标系中的新向量值。

2.1. 旋转方式

2.2. 旋转矩阵

结构Matrix3By3表示3×3的旋转矩阵,可以由不同的旋转方式得到。旋转矩阵与某个3维向量相乘,即可得到该向量旋转后的向量。

2.3. 示例

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("旋转前:{0};旋转后:{1}", vector4, newVector4);
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("旋转前:{0};旋转后:{1}", vector5, newVector5);
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("旋转前:{0};旋转后:{1}", vector6, newVector6);

源代码地址

https://github.com/icgp/STKComponentsTutorial/blob/master/Example004/Example004.cs

上一篇 下一篇

猜你喜欢

热点阅读