在 Cesiumjs 中创建一个方向上的点
Create a point in a direction In Cesiumjs
我正在使用 CesiumJs。我想使用方向 B
在距 A 点距离 C 处创建点 D
Point A => start Position (CartographicPosition {latitude, longitude; altitude})
Direction B => direction from A (HeadingPitchRoll {heading, pitch, roll})
Distance C => in meters
我正在尝试获取对象所面对的旋转,并在他的前面创建一个点。
我目前的实现是
public createROIfromRotation(position: Cartographic, rotation: HeadingPitchRoll): Cartographic {
const pos = Cesium.Ellipsoid.WGS84.cartographicToCartesian(position);
const quat = Cesium.Transforms.headingPitchRollQuaternion(pos, rotation);
const rot = CesiumMath.QuaternionToEuler(quat);
const dir = Cesium.Cartesian3.multiplyByScalar(rot, 10, new Cesium.Cartesian3());
const roiPos = Cesium.Cartesian3.add(pos, dir, new Cesium.Cartesian3());
return Cesium.Ellipsoid.WGS84.cartesianToCartographic(roiPos);
}
但它不是围绕物体旋转,而是在不同的平面上做某种曲线。
我希望红点始终在卡车前方 10 米处
Exemple
我使用
修复了
public createROIfromRotation(position: Cartographic, rotation: HeadingPitchRoll) {
const cartesianPosition = Cesium.Ellipsoid.WGS84.cartographicToCartesian(position);
rotation.heading = rotation.heading - CesiumMath.deg2Rad(90);
const referenceFrame1 = Cesium.Transforms.headingPitchRollQuaternion(cartesianPosition, rotation);
const rotationMatrix = Cesium.Matrix3.fromQuaternion(referenceFrame1, new Cesium.Matrix3());
// Replace 1000 for changing the distance
const rotationScaled = Cesium.Matrix3.multiplyByVector(rotationMatrix, new Cesium.Cartesian3(10000, 0, 0), new Cesium.Cartesian3());
const roiPos = Cesium.Cartesian3.add(cartesianPosition, rotationScaled, new Cesium.Cartesian3());
this.store$.dispatch(new ROIsStoreActions.CreateROIPoint({position: Cesium.Ellipsoid.WGS84.cartesianToCartographic(roiPos), id: uuid()}));
}
所以基本上,在应用我的计算之前将所有内容都转换为 Matrix3
我正在使用 CesiumJs。我想使用方向 B
在距 A 点距离 C 处创建点 DPoint A => start Position (CartographicPosition {latitude, longitude; altitude})
Direction B => direction from A (HeadingPitchRoll {heading, pitch, roll})
Distance C => in meters
我正在尝试获取对象所面对的旋转,并在他的前面创建一个点。
我目前的实现是
public createROIfromRotation(position: Cartographic, rotation: HeadingPitchRoll): Cartographic {
const pos = Cesium.Ellipsoid.WGS84.cartographicToCartesian(position);
const quat = Cesium.Transforms.headingPitchRollQuaternion(pos, rotation);
const rot = CesiumMath.QuaternionToEuler(quat);
const dir = Cesium.Cartesian3.multiplyByScalar(rot, 10, new Cesium.Cartesian3());
const roiPos = Cesium.Cartesian3.add(pos, dir, new Cesium.Cartesian3());
return Cesium.Ellipsoid.WGS84.cartesianToCartographic(roiPos);
}
但它不是围绕物体旋转,而是在不同的平面上做某种曲线。
我希望红点始终在卡车前方 10 米处 Exemple
我使用
修复了 public createROIfromRotation(position: Cartographic, rotation: HeadingPitchRoll) {
const cartesianPosition = Cesium.Ellipsoid.WGS84.cartographicToCartesian(position);
rotation.heading = rotation.heading - CesiumMath.deg2Rad(90);
const referenceFrame1 = Cesium.Transforms.headingPitchRollQuaternion(cartesianPosition, rotation);
const rotationMatrix = Cesium.Matrix3.fromQuaternion(referenceFrame1, new Cesium.Matrix3());
// Replace 1000 for changing the distance
const rotationScaled = Cesium.Matrix3.multiplyByVector(rotationMatrix, new Cesium.Cartesian3(10000, 0, 0), new Cesium.Cartesian3());
const roiPos = Cesium.Cartesian3.add(cartesianPosition, rotationScaled, new Cesium.Cartesian3());
this.store$.dispatch(new ROIsStoreActions.CreateROIPoint({position: Cesium.Ellipsoid.WGS84.cartesianToCartographic(roiPos), id: uuid()}));
}
所以基本上,在应用我的计算之前将所有内容都转换为 Matrix3