LoginSignup
1
1

More than 5 years have passed since last update.

CZMLのUnitQuaternionの設定

Last updated at Posted at 2016-02-27

unitQuaternionの計算

cesiumのczmlで3dモデルを移動させようと思うとunitQuaternionというのを
設定しないといけない。

しかし座標系も緯度経度でないし、往生していたのだが、sandcastleのinterpolationというサンプルにVelocityOrientationProterty(position)というので設定してある。これで計算すればいいのだ!というのでnodeで動かしてみると、defineがない!と言われる・・

というわけで苦労してnodeでcesiumのライブラリを動かしつつunitQuaternionを計算するプログラムをアップしておく。

まあ、これを拡張してczmlを自動で読んで、かってにorientationを追加したczmlを吐き出すというようにすればいいんでしょうけど、まずはご報告

disp.js
r=require('requirejs');
r.config({
    BaseUrl:"./Source",
    paths:{
        Cesium:"./Source"
    }
})
var C=r('./Source/Cesium.js');

var po=new C.SampledPositionProperty();
var t1=C.JulianDate.fromDate(new Date(2012,10,10,10));
var t2;
t2=C.JulianDate.addSeconds(t1,300,new C.JulianDate());
p1=C.Cartesian3.fromDegrees(135.0,35.0,0);
po.addSample(t1,p1);
p2=C.Cartesian3.fromDegrees(134.0,35.0,10000);
po.addSample(t2,p2);
var ori=new C.VelocityOrientationProperty(po);
var q1=new C.Quaternion();
var q2=new C.Quaternion();
ori.getValue(t1,q1);
ori.getValue(t2,q2);
console.log(q1);
console.log(q2);
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1