Pyramid Orientation

I posted a question I had earlier about the orientation of pyramids earlier in the forum, creating a new thread to maybe help explain the problem I’m having. I would like to orient a pyramid that points straight up in to the sky from the surface of the earth (with apex being on the surface). However I’ve noticed when using a fixed position for the pyramid, and setting the orientation for zero degrees of rotation, it seems to be getting its reference frame from the camera’s position? Is that the default reference frame? Is there a way I could force the pyramid’s reference frame to be ECF?

I’ve read through the documentation that a pyramid gets its reference frame from the object it’s attached to, which makes sense for a inertial frame. Thanks in advance for the help. Great job on Cesium, it’s helped our project immensely.

-Jon Carmack

Jon, are you trying to define a pyramid in CZML, or are you programatically using primitives? It sounds like you are talking about CZML, but I just wanted to be sure before I offered any advice.

Through CZML, sorry about that.

Matthew,

Do you have any advice for me? I’m still stuck with this problem.

-Jon

Also Matt I should add, a programmatic solution would be acceptable as well. As the pyramid will not be dynamic. So any solution, or idea of how to set the pyramid to East North Up reference frame would be acceptable.

-Jon

Matt was out today. Might be a couple days before you get a reply, sorry!

Jon, I’m sorry I never got back to you on this. Did you ever figure out your problem?

Thanks for getting back to me Matt. No I didn’t. But I did notice that the pyramid is oriented the same as it would be as if it was located at the center of the earth (default if no position is specified). I came to the conclusion that I was going to need to do a transformation to rotate the pyramid to point directly up, and facing north. If you could provide me some pointers as to how to do that by either computing the rotation myself, or if there is a programmatic solution, that would be awesome. I noticed that Ellipsoids have a transform property for this purpose, as does the camera, but I noticed the pyramid does not.

Thanks for your help,

jon carmack

Problem solved. I implemented a method that computes the quaternion needed to rotate the pyramid as I need by using an offset from the North Pole. Seems too elaborate of a method, alas, it works.

-Jon

I'd be interested in how you did this. I can't seem to find a reasonable way to simply orient a land sensor's field of view based on position and az, el. If anyone could generally describe the steps I'd have to take, that would help a ton.

I ended up using this example http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Sensors.html&label=Showcases and a lot of trial and error to get this working. The information I am visualizing was in Matlab, so I was trying to do most of the pre-processing there, then use the python czml writer to create the czml file. I was unable to get this working in Matlab with what I had on hand, so I tackled the quaternion problem in python using some functions I found for quaternions/coord conversions, then I had to re-implement the Cesium.Transforms.northEastDownToFixedFrame function in python, because there was nothing like it available anywhere else.

When you have a radar on the surface of the earth, you are pointing down into it. So I create a rotation matrix in the Z axis which rotates the radar in a way that you are looking into the earth, but its field of view is kind of rotating around a clock. You want to rotate in z to where you will eventually be in azimuth. Next you rotate in the Y axis, which rotates the radar fov up out of the earth. Rotating -90 degrees would put you at the azimuth, with 0 elevation, so by taking -(90+el) you get your rotation. This was the easier part.

The second challenge came to the northEastDownToFixedFrame function. Even after getting this working, producing the same output as the javascript version, the quaternion I calculate from the matrix that is produced by multiplying the "modelMatrix" by the rotation matrix, sometimes has the wrong signs. So, I'm not sure what Cesium does when producing a quaternion from a 3x3 matrix, but it seems slightly different from multiple functions I have used in Matlab and Python.

It seems like it would be useful to add a function that produces a quaternion from an az, el to Cesium, and provide that as an option in czml. I'll post everything I had to do once I can get the code cleaned up a bit.

Hey,

I implemented mine in java. I'll post the snippets later when I get on my laptop. It was rather simple once I figured out the default orientation. I would be interested in seeing your implementation, I didn't need to use a rotation matrix.

Jon

-Jon Carmack

A gist here with the key aspects of what I used: https://gist.github.com/rothnic/28745b11332946d79c93

I put some comments in there under radar1 and radar2 showing that there is still something messed up. Everything is identical to the output in the Sandcastle environment for the 3x3 portion of the 4x4 rotation matrix that is used internal to Cesium. When computing a quaternian within Sandcastle I get the correct answer for radar1, but not radar2.

Here is the snippet I wrote, it takes a location of an object, lat and long, and computes the needed quaternion to point the object straight up into the sky, and aligned along the North-South axis:

private UnitQuaternion rotateObjectUpAndNorth(TemporalPosition jammerLocation){

double longOffset = Math.abs(Math.abs(jammerLocation.getLongitude()) - 90.0 );

double latOffset = 90.0 - jammerLocation.getLatitude();//TODO:Test for south of equator

longOffset = Math.toRadians(longOffset/2.0);

latOffset = Math.toRadians(latOffset/2.0);

UnitQuaternion yawQuaternion = new UnitQuaternion(Math.cos(longOffset),0.0,0.0,Math.sin(longOffset));

UnitQuaternion pitchQuaternion = new UnitQuaternion(Math.cos(latOffset),-Math.sin(latOffset),0.0,0.0);

return UnitQuaternion.multiply(yawQuaternion, pitchQuaternion);

}

TemporalLocation is a POJO that stores location info (lat, long, elevation). UnitQuaternion is the quaternion class that is part of the java cesium-writer library. Hope this helps.

-Jon Carmack

Hello, I am in the process of building a personal wooden pyramid in my back yard. It will stand 6 feet in height with a 6 foot sq base. I need help in orientation. Is there someone near North Carolina who you know of that I can hire to complete the project? (nsturdivant@windstream.net) thanks much