Advertisement

Android自定义视图——实时太阳轨迹

阅读量:

public class SunTrack {
// Compute the solar elevation angle
public static double calculateSunHeightAngle(double latitude, double solarDecay, double solarHourAngle) {
// Calculate the solar elevation angle
return Math.asin(Math.sin(latitude) * Math.cos(solarDecay) + Math.cos(latitude) * Math.sin(solarDecay) * Math.cos(solarHourAngle));
}
}

假装这里有个动图

大约半个圆形符号表示从日出到日落这段时间。通过实时调整位置,在合适的时间将太阳符号放置在正确的位置。然而由于圆形符号看起来不够美观最终选择了椭圆形符号。

attr.xml

复制代码
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <declare-styleable name="SunTrack">
    	<!-- 背景椭圆短轴和长轴长 -->

全部评论 (0)

还没有任何评论哟~