Search code examples
matlabgeolocationgeocodingellipsehour

Matlabs ellipse hours calc


I make sundial simulator and i draw ellipse and then i have to draw hours on this ellipse. Every our is specified by:

x = a * sin(t);
y = b * cos(t);

where:

a- length of longer semi-axis
b- length of smaller semi-axis
t- hour in degrees ( 1 hour == 15 degrees)

I wrote this function in Matlab:

function [hx,hy] = calcHourCoords(ra,rb)
    %input:
    %ra, rb length of semi-axis in ellipse
    %output:
    %hx, hy coords of hour's plot
    hourAngle = 15*180/pi;
    step = 0;
    for i=1:1:24
       hx(i)= ra * sin(step);
       hy(i)= rb * cos(step);
       step = step+hourAngle;
    end
end

Finally i get that pic: My ellipse and hours points

But is should looks like: Correct hour place's

Ellipse is correct ( I draw my version for other latitude ).

Maybe someone could help me ?

Sorry for my english :)

EDIT

I repair it - just convert degrees to radians.

EDIT2

I change source code FYI


Solution

  • function [hx,hy] = calcHourCoords(ra,rb)
        %input:
        %ra, rb length of semi-axis in ellipse 
        %output:
        %hx, hy coords of hour's plot
        hourAngle = 15*pi/180;
        step = 0;
           for i=1:1:24
               hx(i)= ra * sin(step);
               hy(i)= rb * cos(step);
               step = step+hourAngle;
           end
    end