示例#1
0
 def test_cos_to(self, a0, h0, a1, h1):
     a = Horizontal(a0, h0)
     b = Horizontal(a1, h1)
     pa = a.to_point()
     pb = b.to_point()
     expected = -((pa - pb).length**2 - pa.length**2 - pb.length**2) / (
         2 * pa.length * pb.length)
     self.assertEqual(a.cos_to(b), expected, epsilon=self.EPS)
示例#2
0
文件: projector.py 项目: anaym/pysky
 def project_star(self,
                  pos: Horizontal,
                  star: Star,
                  always_project: bool = False):
     diameter = self._get_size(star.magnitude if star is not None else -1)
     in_eye = self.watcher.radius_low_bound < self.watcher.see.cos_to(
         pos) <= 1
     if in_eye or always_project:
         delta = pos.to_point() - self.watcher.see.to_point()
         prj_delta = delta.rmul_to_matrix(
             self.watcher.transformation_matrix)
         dx, dy = self.distortion(prj_delta.x, prj_delta.y,
                                  self.watcher.radius, prj_delta.z)
         diameter, _ = self.distortion(diameter, 0, self.watcher.radius,
                                       prj_delta.z)
         cx, cy = self.centre[0] + dx, self.centre[1] + dy
         return ProjectedStar(cx, cy, pos, diameter, star, in_eye)