For my homepage I made a certain irregular-regular figure which I particularly like, the pentagon.
For this we need to calculate 5 points from a center, for which I have used this function, made from the GPS calculating page:
function bearing( latlngStart, dP, brngP ){
var R = 6371;
var lat1 = latlngStart.lat()/180*3.1415;
var lon1 = latlngStart.lng()/180*3.1415;
var d = dP;
var brng = brngP/180*3.1415;
var lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) + Math.cos(lat1)*Math.sin(d/R)*Math.cos(brng) );
var lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(lat1), Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2));
lat2 = (lat2* 180/3.1415 + 360 ) % 360;
lon2 = (lon2* 180/3.1415 + 360 ) % 360;
var newPoint = new google.maps.LatLng( lat2 ,lon2);
return newPoint;
}
This functions returns a newPoint, after doing some long mathematics.
This point starts from a center point, and does a radius of dP kilometers, at an angle of brngP degrees.
In a for loop this is done 5 times, getting a pentagon, and this is repeated five times in another for-loop, which shifts the starting angle.
In the same way a polygon, colored is added.
You can see the result here: http://www.contrechoc.com/ which is actually my homepage:

Aucun commentaire:
Enregistrer un commentaire