Martin:
On Tue, Feb 1, 2011 at 18:43, Martin <[email protected]> wrote:
> Try this:
>
> function getAngle(from, to){
> function wrapAngle(angle){
> if (angle>=360) {
> angle-=360;
> } else if (angle<0){
> angle+=360;
> }
> return angle;
> }
> var DEGREE_PER_RADIAN=57.2957795, RADIAN_PER_DEGREE=0.017453;
> var dLat=to.lat()-from.lat(), dLng=to.lng()-from.lng();
> var yaw=Math.atan2(dLng*Math.cos(to.lat()*RADIAN_PER_DEGREE),
> dLat)*DEGREE_PER_RADIAN;
> return wrapAngle(yaw);
> }
>
> 'from' and 'to' are both LatLng objects.
>
> Martin.
>
yaw looks like a simplified version of the forward azimuth algo on the
previously cited movable_type site (no?).
But now I am curious: what purpose is wrapAngle() serving? It is always the
case that -PI <= Math.atan2() <= PI -- does the Google StreetViewPov class
really care if you give it a negative heading?
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.