﻿//! 緯度経度→スクリーン座標
function toScreenX(lat) {
  return  Math.floor((lat - camera.eye.x) * 256 / span.width) + 128;
}
function toScreenY(lng) {
  return -Math.floor((lng - camera.eye.y) * 240 / span.height) + 120;
}

//! クリップ
function isClip(x, y) {
	return (x < -8  ||
	        x > 264 ||
	        y < -8  ||
	        y > 248 ||
			isWindow);
}

//! カメラ
var Camera = Class.create();
Camera.prototype = {
	initialize : function() {
		this.eye = new GPoint();
		this.pre = new GPoint();
		this.ofs = new GPoint();
		this.ofs.x = this.ofs.y = 0;
	},

	update : function() {
		var r = 0.92;
		this.pre.x = this.eye.x;
		this.pre.y = this.eye.y;
		this.ofs.x = this.ofs.x * r + (heli0.vx * 15) * (1 - r);
		this.ofs.y = this.ofs.y * r + (heli0.vy * 15) * (1 - r);
		this.eye.x = heli0.x + this.ofs.x;
		this.eye.y = heli0.y + this.ofs.y;
	},

	isMoved : function() {
		var dx = this.eye.x - this.pre.x;
		var dy = this.eye.y - this.pre.y;
		if (dx <= -0.000001 || dx >= 0.000001 ||
		    dy <= -0.000001 || dy >= 0.000001) return true;
		return false;
	}
};
