On May 31, 2:36 am, Mike Williams <[email protected]> wrote:
> That code would work if degrees of latitude and longitude had the same
> length.
The difference in radii is as follows ...
Equatorial radius 6378.137 km
Polar radius 6356.752 km
... or difference / mean = 0.0034 or 0.34%
Hence the error in the sides of the right-angled-triamgle should be
proportionately the same, so the error in the amgle computed via the
atan function should be at very worst of a similar order of magnitude,
but it's actually 12/145.7 = 8.24%
I don't think that can be the explanation.
> You might consider reverse engineering the OpenLayers .rotate() code:
Which is provably the same as my own code ...
Convert angle to radians, as I do ...
> angle*=Math.PI/180;
Calculate radius, which my code makes the same as my marker length by
simply adding its length in metres to the northing of the second point
before calling this routine ...
> var radius=this.distanceTo(origin);
Calculate new bearing of point 2 ('loc2' in my Google code) from
'origin' or point 1 ('loc1'), which, as this.x and origin.x are chosen
to be equal before calling here, accounts for the +90 in my code.
> var theta=angle+Math.atan2(this.y-origin.y,this.x-origin.x);
Calculate new x and y for point 2 in the same manner as I do
> this.x=origin.x+(radius*Math.cos(theta));
> this.y=origin.y+(radius*Math.sin(theta));
I think the explanation has something to do with the spherical
projection that Google uses internally, but what I don't understand
is, if Google's lat-lng functions are transparently converting to an
internal spherical projection, then the same conversion should be
being done for both loc1 and loc2, so the result should be correct.
It's not as though I'm taking a point specified in one projection and
rotating it about a point specified in another.
What I have noticed since my first post is that the actual marker
length makes a difference, and its manner of doing so confounds the
problem. I would have expected that the shorter the marker length,
the more accurate would be the result. Not so. The most accurate
marker length (for this location at any rate, I haven't tried what
happens at different latitudes and longitudes) is about 30 deg,
greater leads to an azimuth which is too small, less too large.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" 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-API?hl=en
-~----------~----~----~----~------~----~------~--~---