简体   繁体   English

两对方位角和高度之间的角度?

[英]Angle between two pairs of azimuth and altitude?

I have a solar panel pointing (it's normal vector) in some direction. 我有一个太阳能电池板指向(它是正常的矢量)在某个方向。 I want to calculate the angle between that and the current position of the sun. 我想计算它与太阳当前位置之间的角度。 I am using pyephem and I have this information in two pairs of azimuth and altitude. 我正在使用pyephem,并且在两对方位角和海拔高度中具有此信息。

panel_az = ephem.degrees('180')
panel_alt = ephem.degrees('45')
sun_az = ephem.degrees('245')
sun_alt = ephem.degrees('22')

What is the easiest way to find the angle between the panel's normal vector and the vector pointing towards the sun? 找到面板法线向量和指向太阳的向量之间的角度最简单的方法是什么?

The library offers a separation() function that gives the angle between two spherical coordinates; 该库提供了separation()函数,该函数给出了两个球坐标之间的角度。 look near the bottom of this section of the Quick Reference: 请看快速参考本部分底部的内容:

http://rhodesmill.org/pyephem/quick.html#other-functions http://rhodesmill.org/pyephem/quick.html#other-functions

I think you will get the angle you are seeking if you run: 如果你跑步,我想你会得到你想要的角度:

a = ephem.separation((panel_az, panel_alt), (sun_az, sun_alt))
print a

Good luck! 祝好运!

Convert both to vectors first: 首先将它们都转换为向量:

z = sin(altitude)
hyp = cos(altitude)
y = hyp*cos(azimuth)
x = hyp*sin(azimuth)
vector = (x,y,z)

Then calculate the angle between the vectors (say a and b) using cross and dot products. 然后使用十字和点积计算矢量(比​​如a和b)之间的角度。

angle = atan2(norm(cross(a,b)), dot(a,b))

For cross use: 对于交叉使用:

def cross(a, b):
    c = [a[1]*b[2] - a[2]*b[1],
         a[2]*b[0] - a[0]*b[2],
         a[0]*b[1] - a[1]*b[0]]
    return c

For dot use: 对于点使用:

def dot(a, b):
    c = [ a[i] * b[i] for i in range(len(a)) ]
    return c

For norm use: 对于规范使用:

def norm(a):
    mag = sqrt(sum(a[i]*a[i] for i in range(len(a))))
    c = [ a[i]/mag  for i in range(len(a)) ]
    return c
clear,clc,clf;
for n=[15 46 74 105 135 166 196 227 258 288 319 349];
delta=23.45*(sind(360*(284+n)/365));
phi=31.2;
omega=acosd(-tand(phi).*tand(delta));
omega1=-omega:0.1:omega;
alt=(sind(delta).*sind(phi))+(cosd(delta).*cosd(omega1).*cosd(phi));
alt1=asind(abs(alt))
azm=(cosd(delta).*sind(omega1))./cosd(alt);
azm1=asind(azm)
 plot(azm1,alt1,'b');hold on;
  end
grid on
xlabel('Solar Azimuth');ylabel('Solar altitude');
text(0,85,'noon')
hold off 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM