Hi Mike, thanks for the comment (I need to check my submissions more often). It seems to me that the coordinates are being given in the wrong order. Let's see, this is Haversine:
R = 6371*1e3;
p1 = [45.5428,-73.6434];
p2 = [45.6813,-74.0250];
lat1 = p1(1); lon1 = p1(2); lat1 = lat1*pi/180; lon1 = lon1*pi/180;
lat2 = p2(1); lon2 = p2(2); lat2 = lat2*pi/180; lon2 = lon2*pi/180;
dLat = (lat2-lat1);
dLon = (lon2-lon1);
lat1 = lat1;
lat2 = lat2;
a = sin(dLat/2) * sin(dLat/2) + ...
sin(dLon/2) * sin(dLon/2) * cos(lat1) * cos(lat2);
c = 2 * atan2(sqrt(a), sqrt(1-a));
d = R * c
You get 3.3439e+04.
Now, if you do:
lat1 = p1(2); lon1 = p1(1); lat1 = lat1*pi/180; lon1 = lon1*pi/180;
lat2 = p2(2); lon2 = p2(1); lat2 = lat2*pi/180; lon2 = lon2*pi/180;
(bla bla bla...)
you get 4.2648e+04
Now, with geodistance([45.5428,-73.6434],[45.6813,-74.0250],6)
you get 4.2806e+04,
but with
geodistance([-73.6434,45.5428],[-74.0250,45.6813],6)
you get 3.3511e+04.
I will dare to say that geodistance can be expected to exhibit a decent accuracy because it allows the user to choose a local geoid. Unfortunately, I don't have data to substantiate this claim, so you will have to trust the code.

28 Nov 2013

Sea surface
Stochastic generation of the sea surface given wind speed and wind direction.
Author: Orlando Rodríguez

Hi Mike, thanks for the comment (I need to check my submissions more often). It seems to me that the coordinates are being given in the wrong order. Let's see, this is Haversine:
R = 6371*1e3;
p1 = [45.5428,-73.6434];
p2 = [45.6813,-74.0250];
lat1 = p1(1); lon1 = p1(2); lat1 = lat1*pi/180; lon1 = lon1*pi/180;
lat2 = p2(1); lon2 = p2(2); lat2 = lat2*pi/180; lon2 = lon2*pi/180;
dLat = (lat2-lat1);
dLon = (lon2-lon1);
lat1 = lat1;
lat2 = lat2;
a = sin(dLat/2) * sin(dLat/2) + ...
sin(dLon/2) * sin(dLon/2) * cos(lat1) * cos(lat2);
c = 2 * atan2(sqrt(a), sqrt(1-a));
d = R * c
You get 3.3439e+04.
Now, if you do:
lat1 = p1(2); lon1 = p1(1); lat1 = lat1*pi/180; lon1 = lon1*pi/180;
lat2 = p2(2); lon2 = p2(1); lat2 = lat2*pi/180; lon2 = lon2*pi/180;
(bla bla bla...)
you get 4.2648e+04
Now, with geodistance([45.5428,-73.6434],[45.6813,-74.0250],6)
you get 4.2806e+04,
but with
geodistance([-73.6434,45.5428],[-74.0250,45.6813],6)
you get 3.3511e+04.
I will dare to say that geodistance can be expected to exhibit a decent accuracy because it allows the user to choose a local geoid. Unfortunately, I don't have data to substantiate this claim, so you will have to trust the code.

28 Nov 2013

Sea surface
Stochastic generation of the sea surface given wind speed and wind direction.
Author: Orlando Rodríguez

Thanks... I guess there is a missing term in the line (dFdK = sqrt( g./K )/( 4*pi );). I think it will be dFdK = sqrt( g./K )./( 4*pi*K );.
Since F(k) = E(f,theta)/(k.(dk/df)) at ocean waves tutorial. k in this equation is missing. Please check it. Am I right?

03 Oct 2013

Sea surface
Stochastic generation of the sea surface given wind speed and wind direction.
Author: Orlando Rodríguez

tnx for your useful code.in mitsuyasu and hasselmann spreading function code,what does the line D = D + fliplr( flipud( D ) ) do? why did you write these lines?