AnalyticalGraphicsInc/cesium — pull request #1862 by bagnell (2014-06-25 21:50:09+00:00)
Title: Window coordinates

For #91.

Modify `Transforms.pointToWindowCoordinates` and `SceneTransforms.wgs84ToWindowCoordinates` to return coordinates where the origin is at the top left.

You can test it by adding this code to the Picking Sandcastle example:
```javascript
// Mouse over the globe to see the cartographic position
handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
var cartesian = scene.camera.pickEllipsoid(movement.endPosition, ellipsoid);
if (cartesian) {
//var windowCoordinates = Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, cartesian);

var context = scene._context;
var viewProjMatrix = context.uniformState.viewProjection;
var viewport = new Cesium.BoundingRectangle();
viewport.width = context.drawingBufferWidth;
viewport.height = context.drawingBufferHeight;
var viewportTransformation = Cesium.Matrix4.computeViewportTransformation(viewport, 0.0, 1.0);
var windowCoordinates = Cesium.Transforms.pointToWindowCoordinates(viewProjMatrix, viewportTransformation, cartesian);

label.show = true;
label.text = '(' + movement.endPosition.x + ', ' + Math.floor(windowCoordinates.x + 0.5) + '), (' + movement.endPosition.y + ', ' + Math.floor(windowCoordinates.y + 0.5) + ')';
label.position = cartesian;
} else {
label.text = '';
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
```
Each pair of numbers should be equal.