Instance rotation?

Awesome, I’m glad it provided the desired results! I’ve rotated each of the 3 vectors (east,north,up) to get that matrix. Here’s a sandcastle example rotating the east vector. Can do the same with the north vector. No point in rotating the up vector around itself, it won’t change.

var viewer = new Cesium.Viewer("cesiumContainer");
var mypos = new Cesium.Cartesian3.fromDegrees(-75.6132, 40.0416);
var mymat = new Cesium.Matrix4();
mymat = Cesium.Transforms.eastNorthUpToFixedFrame(mypos, viewer.scene.globe.ellipsoid, mymat);

var CC3=Cesium.Cartesian3;
var rotatee=new CC3(mymat[0],mymat[1],mymat[2]); //east/right
var rotater=new CC3(mymat[8],mymat[9],mymat[10]); //up
var result= new CC3();
result=rotateVector(rotatee,rotater,Math.PI/4); //rotate east +90deg around up
console.log(result);

function rotateVector(rotatee,rotater,angleRad)
{
var CC3 = Cesium.Cartesian3;var rotated=new CC3();
var dotS = CC3.dot(rotatee,rotater);
var base = CC3.multiplyByScalar(rotater,dotS,new CC3());
var vpa = CC3.subtract(rotatee,base,new CC3());
var cx = CC3.multiplyByScalar(vpa,Math.cos(angleRad),new CC3());
var vppa = CC3.cross(rotater,vpa,new CC3());
var cy = CC3.multiplyByScalar(vppa,Math.sin(angleRad),new CC3());
var temp = CC3.add(base,cx,new CC3());
var rotated = CC3.add(temp,cy,new CC3());
return rotated;
}
2 Likes