我做日晷模拟器,画椭圆,然后在这个椭圆上画几个小时。每一个our都是由以下内容指定的:
x = a * sin(t);
y = b * cos(t);其中:
a- length of longer semi-axis
b- length of smaller semi-axis
t- hour in degrees ( 1 hour == 15 degrees)我用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最后,我得到了这张照片:我的椭圆和小时点
但是应该是这样的:正确时间地点
椭圆是正确的(我为其他纬度绘制我的版本)。
也许有人能帮我?
对不起我的英语:)
编辑
我修理它--只需将度转换为弧度。
EDIT2
我更改源代码
发布于 2015-04-27 16:17:18
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
endhttps://stackoverflow.com/questions/29872175
复制相似问题