image-20220309194832300

icosahedron

正二十面体 https://baike.baidu.com/item/%E6%AD%A3%E4%BA%8C%E5%8D%81%E9%9D%A2%E4%BD%93/1921640

正二十面体(Regular icosahedron [2] ) 是由20个等边三角形所组成的正多面体,共有12个顶点,30条棱,20个面。为五个柏拉图多面体之一。

image-20220309164132823

sqrt(50-10*sqrt(5))/10 = 0.5257

sqrt(50+10*sqrt(5))/10 = 0.8507


画图十分精美

image-20220321102438566

https://www.redblobgames.com/x/1842-delaunay-voronoi-sphere/

image-20220321101619465


image-20220309171100201

% plot_triangle.m
clear all; close all;
m = sqrt(50-10*sqrt(5))/10;
n = sqrt(50+10*sqrt(5))/10;
A = [
n,-m,0;
n,m,0;
-n,m,0;
-n,-m,0;
0,n,-m;
0,n,m;
0,-n,m;
0,-n,-m;
-m,0,n;
m,0,n;
m,0,-n;
-m,0,-n;
];
scatter3(A(:,1),A(:,2),A(:,3));
hold on;
center=[];
center = [center;plot_triangle(A,1,0,10)];
center = [center;plot_triangle(A,0,1,9)];
center = [center;plot_triangle(A,0,9,6)];

center = [center;plot_triangle(A,9,8,6)];
center = [center;plot_triangle(A,0,7,10)];
center = [center;plot_triangle(A,6,7,0)];

center = [center;plot_triangle(A,7,6,3)];
center = [center;plot_triangle(A,6,8,3)];
center = [center;plot_triangle(A,11,10,7)];

center = [center;plot_triangle(A,7,3,11)];
center = [center;plot_triangle(A,3,2,11)];
center = [center;plot_triangle(A,2,3,8)];

center = [center;plot_triangle(A,10,11,4)];
center = [center;plot_triangle(A,2,4,11)];
center = [center;plot_triangle(A,5,4,2)];

center = [center;plot_triangle(A,2,8,5)];
center = [center;plot_triangle(A,4,1,10)];
center = [center;plot_triangle(A,4,5,1)];

center = [center;plot_triangle(A,5,9,1)];
center = [center;plot_triangle(A,8,9,5)];

hold on;
quiver3(0,0,0,1,0,0);
quiver3(0,0,0,0,1,0);
quiver3(0,0,0,0,0,1);
text(1,0,0,'x');
text(0,1,0,'y');
text(0,0,1,'z');

axis equal;
function plot_triangle(A,d1,d2,d3)
d1 = d1 + 1;
d2 = d2 + 1;
d3 = d3 + 1;
hold on;

line([A(d1,1),A(d2,1),A(d3,1),A(d1,1)],[A(d1,2),A(d2,2),A(d3,2),A(d1,2)],[A(d1,3),A(d2,3),A(d3,3),A(d1,3)]);

image-20220309194211980

image-20220312234651019


进入源码进行查看

StelGeodesicGrid::StelGeodesicGrid(StelGeodesicGrid.cpp) 被调用1次 调用20次
StelGeodesicGrid::initTriangle(StelGeodesicGrid.cpp)被调用20次 c0/c1/c2为20个面的3个点,函数内的循环没进

下面6个点为 c0/c1/c2/e0/e1/e2

1 [0.850651, 0.525731, 0] [0.850651, -0.525731, 0] [0.525731, 0, -0.850651] [0.809017, -0.309017, -0.5] [0.809017, 0.309017, -0.5] [1, 0, 0]

2 [0.850651, -0.525731, 0] [0.850651, 0.525731, 0] [0.525731, 0, 0.850651] [0.809017, 0.309017, 0.5] [0.809017, -0.309017, 0.5] [1, 0, 0]

3 [0.850651, -0.525731, 0] [0.525731, 0, 0.850651] [0, -0.850651, 0.525731] [0.309017, -0.5, 0.809017] [0.5, -0.809017, 0.309017] [0.809017, -0.309017, 0.5]

4 [0.525731, 0, 0.850651] [-0.525731, 0, 0.850651] [0, -0.850651, 0.525731] [-0.309017, -0.5, 0.809017] [0.309017, -0.5, 0.809017] [0, 0, 1]

5 [0.850651, -0.525731, 0] [0, -0.850651, -0.525731] [0.525731, 0, -0.850651] [0.309017, -0.5, -0.809017] [0.809017, -0.309017, -0.5] [0.5, -0.809017, -0.309017]

6 [0, -0.850651, 0.525731] [0, -0.850651, -0.525731] [0.850651, -0.525731, 0] [0.5, -0.809017, -0.309017] [0.5, -0.809017, 0.309017] [0, -1, 0]

7 [0, -0.850651, -0.525731] [0, -0.850651, 0.525731] [-0.850651, -0.525731, 0] [-0.5, -0.809017, 0.309017] [-0.5, -0.809017, -0.309017] [0, -1, 0]

8 [0, -0.850651, 0.525731] [-0.525731, 0, 0.850651] [-0.850651, -0.525731, 0] [-0.809017, -0.309017, 0.5] [-0.5, -0.809017, 0.309017] [-0.309017, -0.5, 0.809017]

9 [-0.525731, 0, -0.850651] [0.525731, 0, -0.850651] [0, -0.850651, -0.525731] [0.309017, -0.5, -0.809017] [-0.309017, -0.5, -0.809017] [0, 0, -1]

10 [0, -0.850651, -0.525731] [-0.850651, -0.525731, 0] [-0.525731, 0, -0.850651] [-0.809017, -0.309017, -0.5] [-0.309017, -0.5, -0.809017] [-0.5, -0.809017, -0.309017]

11 [-0.850651, -0.525731, 0] [-0.850651, 0.525731, 0] [-0.525731, 0, -0.850651] [-0.809017, 0.309017, -0.5] [-0.809017, -0.309017, -0.5] [-1, 0, 0]

12 [-0.850651, 0.525731, 0] [-0.850651, -0.525731, 0] [-0.525731, 0, 0.850651] [-0.809017, -0.309017, 0.5] [-0.809017, 0.309017, 0.5] [-1, 0, 0]

13 [0.525731, 0, -0.850651] [-0.525731, 0, -0.850651] [0, 0.850651, -0.525731] [-0.309017, 0.5, -0.809017] [0.309017, 0.5, -0.809017] [0, 0, -1]

14 [-0.850651, 0.525731, 0] [0, 0.850651, -0.525731] [-0.525731, 0, -0.850651] [-0.309017, 0.5, -0.809017] [-0.809017, 0.309017, -0.5] [-0.5, 0.809017, -0.309017]

15 [0, 0.850651, 0.525731] [0, 0.850651, -0.525731] [-0.850651, 0.525731, 0] [-0.5, 0.809017, -0.309017] [-0.5, 0.809017, 0.309017] [0, 1, 0]

16 [-0.850651, 0.525731, 0] [-0.525731, 0, 0.850651] [0, 0.850651, 0.525731] [-0.309017, 0.5, 0.809017] [-0.5, 0.809017, 0.309017] [-0.809017, 0.309017, 0.5]

17 [0, 0.850651, -0.525731] [0.850651, 0.525731, 0] [0.525731, 0, -0.850651] [0.809017, 0.309017, -0.5] [0.309017, 0.5, -0.809017] [0.5, 0.809017, -0.309017]

18 [0, 0.850651, -0.525731] [0, 0.850651, 0.525731] [0.850651, 0.525731, 0] [0.5, 0.809017, 0.309017] [0.5, 0.809017, -0.309017] [0, 1, 0]

19 [0, 0.850651, 0.525731] [0.525731, 0, 0.850651] [0.850651, 0.525731, 0] [0.809017, 0.309017, 0.5] [0.5, 0.809017, 0.309017] [0.309017, 0.5, 0.809017]

20 [-0.525731, 0, 0.850651] [0.525731, 0, 0.850651] [0, 0.850651, 0.525731] [0.309017, 0.5, 0.809017] [-0.309017, 0.5, 0.809017] [0, 0, 1]


然后才进入了下面的程序

StarMgr::init()
StelGeodesicGrid::visitTriangles 被调用1次 调用20次函数
StelGeodesicGrid::visitTriangles 被调用20次 再每次调用自身4次函数
(*func)(lev, index, c0, c1, c2, context);
initTriangleFunc (StarMgr.hpp)
StarMgr::initTriangle 被调用1次
ZoneArray::initTriangle

需要注意调用了100次的 StelGeodesicGrid::visitTriangles 中的 Triangle &t(triangles [ lev ] [ index ] );

struct Triangle
{
Vec3f e0,e1,e2; // Seitenmittelpunkte
};
Triangle **triangles;

triangles变量在StelGeodesicGrid::initTriangle中已经定义过

checkAndLoadCatal visitTriangles 1

1 z->center [0.934172, 0, -0.356822] z->axis0 [0, 1, 0] z->axis1 [0.356822, 0, 0.934172] star_position_scale 0.763932 c0 [0.850651, 0.525731, 0] c1 [0.850651, -0.525731, 0] c2 [0.525731, 0, -0.850651]

2 z->center [0.939124, 0.294748, -0.176549] z->axis0 [-0.299452, 0.954111, 0] z->axis1 [0.168448, 0.052868, 0.984292] star_position_scale 0.361541 c0 [0.850651, 0.525731, 0] c1 [1, 0, 0] c2 [0.809017, 0.309017, -0.5]

3 z->center [0.939124, -0.294748, -0.176549] z->axis0 [0.299452, 0.954111, 0] z->axis1 [0.168448, -0.052868, 0.984292] star_position_scale 0.361541 c0 [1, 0, 0] c1 [0.850651, -0.525731, 0] c2 [0.809017, -0.309017, -0.5]

4 z->center [0.75696, 0, -0.653462] z->axis0 [0, 1, 0] z->axis1 [0.653462, 0, 0.75696] star_position_scale 0.361541 c0 [0.809017, 0.309017, -0.5] c1 [0.809017, -0.309017, -0.5] c2 [0.525731, 0, -0.850651]

5 z->center [0.934172, 0, -0.356822] z->axis0 [0, 1, 0] z->axis1 [0.356822, 0, 0.934172] star_position_scale 0.381966 c0 [0.809017, -0.309017, -0.5] c1 [0.809017, 0.309017, -0.5] c2 [1, 0, 0]

checkAndLoadCatal visitTriangles 2

6 z->center [0.934172, 0, 0.356822] z->axis0 [0, 1, 0] z->axis1 [-0.356822, 0, 0.934172] star_position_scale 0.763932 c0 [0.850651, -0.525731, 0] c1 [0.850651, 0.525731, 0] c2 [0.525731, 0, 0.850651]

7 z->center [0.939124, -0.294748, 0.176549] z->axis0 [0.299452, 0.954111, 0] z->axis1 [-0.168448, 0.052868, 0.984292] star_position_scale 0.381966 c0 [0.850651, -0.525731, 0] c1 [1, 0, 0] c2 [0.809017, -0.309017, 0.5]

8 z->center [0.939124, 0.294748, 0.176549] z->axis0 [-0.299452, 0.954111, 0] z->axis1 [-0.168448, -0.052868, 0.984292] star_position_scale 0.381966 c0 [1, 0, 0] c1 [0.850651, 0.525731, 0] c2 [0.809017, 0.309017, 0.5]

9 z->center [0.75696, 0, 0.653462] z->axis0 [0, 1, 0] z->axis1 [-0.653462, 0, 0.75696] star_position_scale 0.381966 c0 [0.809017, -0.309017, 0.5] c1 [0.809017, 0.309017, 0.5] c2 [0.525731, 0, 0.850651]

10 z->center [0.934172, 0, 0.356822] z->axis0 [0, 1, 0] z->axis1 [-0.356822, 0, 0.934172] star_position_scale 0.381966 c0 [0.809017, 0.309017, 0.5] c1 [0.809017, -0.309017, 0.5] c2 [1, 0, 0]

checkAndLoadCatal visitTriangles 3

11 z->center [0.57735, -0.57735, 0.57735] z->axis0 [0.707107, 0.707107, 0] z->axis1 [-0.408248, 0.408248, 0.816497] star_position_scale 0.763932 c0 [0.850651, -0.525731, 0] c1 [0.525731, 0, 0.850651] c2 [0, -0.850651, 0.525731]

12 z->center [0.762575, -0.580411, 0.285662] z->axis0 [0.605648, 0.795733, 0] z->axis1 [-0.227311, 0.173011, 0.95833] star_position_scale 0.381966 c0 [0.850651, -0.525731, 0] c1 [0.809017, -0.309017, 0.5] c2 [0.5, -0.809017, 0.309017]

13 z->center [0.580411, -0.285662, 0.762575] z->axis0 [0.441587, 0.897219, 0] z->axis1 [-0.684196, 0.336743, 0.6469] star_position_scale 0.381966 c0 [0.809017, -0.309017, 0.5] c1 [0.525731, 0, 0.850651] c2 [0.309017, -0.5, 0.809017]

14 z->center [0.285662, -0.762575, 0.580411] z->axis0 [0.936452, 0.350797, 0] z->axis1 [-0.203606, 0.543526, 0.814324] star_position_scale 0.381966 c0 [0.5, -0.809017, 0.309017] c1 [0.309017, -0.5, 0.809017] c2 [0, -0.850651, 0.525731]

15 z->center [0.57735, -0.57735, 0.57735] z->axis0 [0.707107, 0.707107, 0] z->axis1 [-0.408248, 0.408248, 0.816497] star_position_scale 0.381966 c0 [0.309017, -0.5, 0.809017] c1 [0.5, -0.809017, 0.309017] c2 [0.809017, -0.309017, 0.5]

checkAndLoadCatal visitTriangles 4

16 z->center [0, -0.356822, 0.934172] z->axis0 [1, 0, 0] z->axis1 [0, 0.934172, 0.356822] star_position_scale 0.763932 c0 [0.525731, 0, 0.850651] c1 [-0.525731, 0, 0.850651] c2 [0, -0.850651, 0.525731]

17 z->center [0.294748, -0.176549, 0.939124] z->axis0 [0.513854, 0.857878, 0] z->axis1 [-0.805654, 0.482573, 0.343578] star_position_scale 0.381966 c0 [0.525731, 0, 0.850651] c1 [0, 0, 1] c2 [0.309017, -0.5, 0.809017]

18 z->center [-0.294748, -0.176549, 0.939124] z->axis0 [0.513854, -0.857878, 0] z->axis1 [0.805654, 0.482573, 0.343578] star_position_scale 0.381966 c0 [0, 0, 1] c1 [-0.525731, 0, 0.850651] c2 [-0.309017, -0.5, 0.809017]

19 z->center [0, -0.653462, 0.75696] z->axis0 [1, 0, 0] z->axis1 [0, 0.75696, 0.653462] star_position_scale 0.381966 c0 [0.309017, -0.5, 0.809017] c1 [-0.309017, -0.5, 0.809017] c2 [0, -0.850651, 0.525731]

20 z->center [0, -0.356822, 0.934172] z->axis0 [1, 0, 0] z->axis1 [0, 0.934172, 0.356822] star_position_scale 0.381966 c0 [-0.309017, -0.5, 0.809017] c1 [0.309017, -0.5, 0.809017] c2 [0, 0, 1]

checkAndLoadCatal visitTriangles 5

21 z->center [0.57735, -0.57735, -0.57735] z->axis0 [0.707107, 0.707107, 0] z->axis1 [0.408248, -0.408248, 0.816497] star_position_scale 0.763932 c0 [0.850651, -0.525731, 0] c1 [0, -0.850651, -0.525731] c2 [0.525731, 0, -0.850651]

22 z->center [0.762575, -0.580411, -0.285662] z->axis0 [0.605648, 0.795733, 0] z->axis1 [0.227311, -0.173011, 0.95833] star_position_scale 0.381966 c0 [0.850651, -0.525731, 0] c1 [0.5, -0.809017, -0.309017] c2 [0.809017, -0.309017, -0.5]

23 z->center [0.285662, -0.762575, -0.580411] z->axis0 [0.936452, 0.350797, 0] z->axis1 [0.203606, -0.543526, 0.814324] star_position_scale 0.381966 c0 [0.5, -0.809017, -0.309017] c1 [0, -0.850651, -0.525731] c2 [0.309017, -0.5, -0.809017]

24 z->center [0.580411, -0.285662, -0.762575] z->axis0 [0.441587, 0.897219, 0] z->axis1 [0.684196, -0.336743, 0.6469] star_position_scale 0.381966 c0 [0.809017, -0.309017, -0.5] c1 [0.309017, -0.5, -0.809017] c2 [0.525731, 0, -0.850651]

25 z->center [0.57735, -0.57735, -0.57735] z->axis0 [0.707107, 0.707107, 0] z->axis1 [0.408248, -0.408248, 0.816497] star_position_scale 0.381966 c0 [0.309017, -0.5, -0.809017] c1 [0.809017, -0.309017, -0.5] c2 [0.5, -0.809017, -0.309017]

checkAndLoadCatal visitTriangles 6

26 z->center [0.356822, -0.934172, 0] z->axis0 [0.934172, 0.356822, 0] z->axis1 [0, 0, 1] star_position_scale 0.763932 c0 [0, -0.850651, 0.525731] c1 [0, -0.850651, -0.525731] c2 [0.850651, -0.525731, 0]

27 z->center [0.176549, -0.939124, 0.294748] z->axis0 [0.982784, 0.184757, 0] z->axis1 [-0.0544568, 0.289674, 0.955575] star_position_scale 0.381966 c0 [0, -0.850651, 0.525731] c1 [0, -1, 0] c2 [0.5, -0.809017, 0.309017]

28 z->center [0.176549, -0.939124, -0.294748] z->axis0 [0.982784, 0.184757, 0] z->axis1 [0.0544568, -0.289674, 0.955575] star_position_scale 0.381966 c0 [0, -1, 0] c1 [0, -0.850651, -0.525731] c2 [0.5, -0.809017, -0.309017]

29 z->center [0.653462, -0.75696, 0] z->axis0 [0.75696, 0.653462, 0] z->axis1 [0, 0, 1] star_position_scale 0.381966 c0 [0.5, -0.809017, 0.309017] c1 [0.5, -0.809017, -0.309017] c2 [0.850651, -0.525731, 0]

30 z->center [0.356822, -0.934172, 0] z->axis0 [0.934172, 0.356822, 0] z->axis1 [0, 0, 1] star_position_scale 0.381966 c0 [0.5, -0.809017, -0.309017] c1 [0.5, -0.809017, 0.309017] c2 [0, -1, 0]

checkAndLoadCatal visitTriangles 7

31 z->center [-0.356822, -0.934172, 0] z->axis0 [0.934172, -0.356822, 0] z->axis1 [0, 0, 1] star_position_scale 0.763932 c0 [0, -0.850651, -0.525731] c1 [0, -0.850651, 0.525731] c2 [-0.850651, -0.525731, 0]

32 z->center [-0.176549, -0.939124, -0.294748] z->axis0 [0.982784, -0.184757, 0] z->axis1 [-0.0544568, -0.289674, 0.955575] star_position_scale 0.381966 c0 [0, -0.850651, -0.525731] c1 [0, -1, 0] c2 [-0.5, -0.809017, -0.309017]

33 z->center [-0.176549, -0.939124, 0.294748] z->axis0 [0.982784, -0.184757, 0] z->axis1 [0.0544568, 0.289674, 0.955575] star_position_scale 0.381966 c0 [0, -1, 0] c1 [0, -0.850651, 0.525731] c2 [-0.5, -0.809017, 0.309017]

34 z->center [-0.653462, -0.75696, 0] z->axis0 [0.75696, -0.653462, 0] z->axis1 [0, 0, 1] star_position_scale 0.381966 c0 [-0.5, -0.809017, -0.309017] c1 [-0.5, -0.809017, 0.309017] c2 [-0.850651, -0.525731, 0]

35 z->center [-0.356822, -0.934172, 0] z->axis0 [0.934172, -0.356822, 0] z->axis1 [0, 0, 1] star_position_scale 0.381966 c0 [-0.5, -0.809017, 0.309017] c1 [-0.5, -0.809017, -0.309017] c2 [0, -1, 0]

checkAndLoadCatal visitTriangles 8

36 z->center [-0.57735, -0.57735, 0.57735] z->axis0 [0.707107, -0.707107, 0] z->axis1 [0.408248, 0.408248, 0.816497] star_position_scale 0.763932 c0 [0, -0.850651, 0.525731] c1 [-0.525731, 0, 0.850651] c2 [-0.850651, -0.525731, 0]

37 z->center [-0.285662, -0.762575, 0.580411] z->axis0 [0.936452, -0.350797, 0] z->axis1 [0.203606, 0.543526, 0.814324] star_position_scale 0.381966 c0 [0, -0.850651, 0.525731] c1 [-0.309017, -0.5, 0.809017] c2 [-0.5, -0.809017, 0.309017]

38 z->center [-0.580411, -0.285662, 0.762575] z->axis0 [0.441587, -0.897219, 0] z->axis1 [0.684196, 0.336743, 0.6469] star_position_scale 0.381966 c0 [-0.309017, -0.5, 0.809017] c1 [-0.525731, 0, 0.850651] c2 [-0.809017, -0.309017, 0.5]

39 z->center [-0.762575, -0.580411, 0.285662] z->axis0 [0.605648, -0.795733, 0] z->axis1 [0.227311, 0.173011, 0.95833] star_position_scale 0.381966 c0 [-0.5, -0.809017, 0.309017] c1 [-0.809017, -0.309017, 0.5] c2 [-0.850651, -0.525731, 0]

40 z->center [-0.57735, -0.57735, 0.57735] z->axis0 [0.707107, -0.707107, 0] z->axis1 [0.408248, 0.408248, 0.816497] star_position_scale 0.381966 c0 [-0.809017, -0.309017, 0.5] c1 [-0.5, -0.809017, 0.309017] c2 [-0.309017, -0.5, 0.809017]

checkAndLoadCatal visitTriangles 9

41 z->center [0, -0.356822, -0.934172] z->axis0 [1, 0, 0] z->axis1 [0, -0.934172, 0.356822] star_position_scale 0.763932 c0 [-0.525731, 0, -0.850651] c1 [0.525731, 0, -0.850651] c2 [0, -0.850651, -0.525731]

42 z->center [-0.294748, -0.176549, -0.939124] z->axis0 [0.513854, -0.857878, 0] z->axis1 [-0.805654, -0.482573, 0.343578] star_position_scale 0.381966 c0 [-0.525731, 0, -0.850651] c1 [0, 0, -1] c2 [-0.309017, -0.5, -0.809017]

43 z->center [0.294748, -0.176549, -0.939124] z->axis0 [0.513854, 0.857878, 0] z->axis1 [0.805654, -0.482573, 0.343578] star_position_scale 0.381966 c0 [0, 0, -1] c1 [0.525731, 0, -0.850651] c2 [0.309017, -0.5, -0.809017]

44 z->center [0, -0.653462, -0.75696] z->axis0 [1, 0, 0] z->axis1 [0, -0.75696, 0.653462] star_position_scale 0.381966 c0 [-0.309017, -0.5, -0.809017] c1 [0.309017, -0.5, -0.809017] c2 [0, -0.850651, -0.525731]

45 z->center [0, -0.356822, -0.934172] z->axis0 [1, 0, 0] z->axis1 [0, -0.934172, 0.356822] star_position_scale 0.381966 c0 [0.309017, -0.5, -0.809017] c1 [-0.309017, -0.5, -0.809017] c2 [0, 0, -1]

checkAndLoadCatal visitTriangles 10

46 z->center [-0.57735, -0.57735, -0.57735] z->axis0 [0.707107, -0.707107, 0] z->axis1 [-0.408248, -0.408248, 0.816497] star_position_scale 0.763932 c0 [0, -0.850651, -0.525731] c1 [-0.850651, -0.525731, 0] c2 [-0.525731, 0, -0.850651]

47 z->center [-0.285662, -0.762575, -0.580411] z->axis0 [0.936452, -0.350797, 0] z->axis1 [-0.203606, -0.543526, 0.814324] star_position_scale 0.381966 c0 [0, -0.850651, -0.525731] c1 [-0.5, -0.809017, -0.309017] c2 [-0.309017, -0.5, -0.809017]

48 z->center [-0.762575, -0.580411, -0.285662] z->axis0 [0.605648, -0.795733, 0] z->axis1 [-0.227311, -0.173011, 0.95833] star_position_scale 0.381966 c0 [-0.5, -0.809017, -0.309017] c1 [-0.850651, -0.525731, 0] c2 [-0.809017, -0.309017, -0.5]

49 z->center [-0.580411, -0.285662, -0.762575] z->axis0 [0.441587, -0.897219, 0] z->axis1 [-0.684196, -0.336743, 0.6469] star_position_scale 0.381966 c0 [-0.309017, -0.5, -0.809017] c1 [-0.809017, -0.309017, -0.5] c2 [-0.525731, 0, -0.850651]

50 z->center [-0.57735, -0.57735, -0.57735] z->axis0 [0.707107, -0.707107, 0] z->axis1 [-0.408248, -0.408248, 0.816497] star_position_scale 0.381966 c0 [-0.809017, -0.309017, -0.5] c1 [-0.309017, -0.5, -0.809017] c2 [-0.5, -0.809017, -0.309017]

checkAndLoadCatal visitTriangles 11

51 z->center [-0.934172, 0, -0.356822] z->axis0 [0, -1, 0] z->axis1 [-0.356822, 0, 0.934172] star_position_scale 0.763932 c0 [-0.850651, -0.525731, 0] c1 [-0.850651, 0.525731, 0] c2 [-0.525731, 0, -0.850651]

52 z->center [-0.939124, -0.294748, -0.176549] z->axis0 [0.299452, -0.954111, 0] z->axis1 [-0.168448, -0.052868, 0.984292] star_position_scale 0.381966 c0 [-0.850651, -0.525731, 0] c1 [-1, 0, 0] c2 [-0.809017, -0.309017, -0.5]

53 z->center [-0.939124, 0.294748, -0.176549] z->axis0 [-0.299452, -0.954111, 0] z->axis1 [-0.168448, 0.052868, 0.984292] star_position_scale 0.381966 c0 [-1, 0, 0] c1 [-0.850651, 0.525731, 0] c2 [-0.809017, 0.309017, -0.5]

54 z->center [-0.75696, 0, -0.653462] z->axis0 [0, -1, 0] z->axis1 [-0.653462, 0, 0.75696] star_position_scale 0.381966 c0 [-0.809017, -0.309017, -0.5] c1 [-0.809017, 0.309017, -0.5] c2 [-0.525731, 0, -0.850651]

55 z->center [-0.934172, 0, -0.356822] z->axis0 [0, -1, 0] z->axis1 [-0.356822, 0, 0.934172] star_position_scale 0.381966 c0 [-0.809017, 0.309017, -0.5] c1 [-0.809017, -0.309017, -0.5] c2 [-1, 0, 0]

checkAndLoadCatal visitTriangles 12

56 z->center [-0.934172, 0, 0.356822] z->axis0 [0, -1, 0] z->axis1 [0.356822, 0, 0.934172] star_position_scale 0.763932 c0 [-0.850651, 0.525731, 0] c1 [-0.850651, -0.525731, 0] c2 [-0.525731, 0, 0.850651]

57 z->center [-0.939124, 0.294748, 0.176549] z->axis0 [-0.299452, -0.954111, 0] z->axis1 [0.168448, -0.052868, 0.984292] star_position_scale 0.381966 c0 [-0.850651, 0.525731, 0] c1 [-1, 0, 0] c2 [-0.809017, 0.309017, 0.5]

58 z->center [-0.939124, -0.294748, 0.176549] z->axis0 [0.299452, -0.954111, 0] z->axis1 [0.168448, 0.052868, 0.984292] star_position_scale 0.381966 c0 [-1, 0, 0] c1 [-0.850651, -0.525731, 0] c2 [-0.809017, -0.309017, 0.5]

59 z->center [-0.75696, 0, 0.653462] z->axis0 [0, -1, 0] z->axis1 [0.653462, 0, 0.75696] star_position_scale 0.381966 c0 [-0.809017, 0.309017, 0.5] c1 [-0.809017, -0.309017, 0.5] c2 [-0.525731, 0, 0.850651]

60 z->center [-0.934172, 0, 0.356822] z->axis0 [0, -1, 0] z->axis1 [0.356822, 0, 0.934172] star_position_scale 0.381966 c0 [-0.809017, -0.309017, 0.5] c1 [-0.809017, 0.309017, 0.5] c2 [-1, 0, 0]

checkAndLoadCatal visitTriangles 13

61 z->center [0, 0.356822, -0.934172] z->axis0 [-1, 0, 0] z->axis1 [0, 0.934172, 0.356822] star_position_scale 0.763932 c0 [0.525731, 0, -0.850651] c1 [-0.525731, 0, -0.850651] c2 [0, 0.850651, -0.525731]

62 z->center [0.294748, 0.176549, -0.939124] z->axis0 [-0.513854, 0.857878, 0] z->axis1 [0.805654, 0.482573, 0.343578] star_position_scale 0.381966 c0 [0.525731, 0, -0.850651] c1 [0, 0, -1] c2 [0.309017, 0.5, -0.809017]

63 z->center [-0.294748, 0.176549, -0.939124] z->axis0 [-0.513854, -0.857878, 0] z->axis1 [-0.805654, 0.482573, 0.343578] star_position_scale 0.381966 c0 [0, 0, -1] c1 [-0.525731, 0, -0.850651] c2 [-0.309017, 0.5, -0.809017]

64 z->center [0, 0.653462, -0.75696] z->axis0 [-1, 0, 0] z->axis1 [0, 0.75696, 0.653462] star_position_scale 0.381966 c0 [0.309017, 0.5, -0.809017] c1 [-0.309017, 0.5, -0.809017] c2 [0, 0.850651, -0.525731]

65 z->center [0, 0.356822, -0.934172] z->axis0 [-1, 0, 0] z->axis1 [0, 0.934172, 0.356822] star_position_scale 0.381966 c0 [-0.309017, 0.5, -0.809017] c1 [0.309017, 0.5, -0.809017] c2 [0, 0, -1]

checkAndLoadCatal visitTriangles 14

66 z->center [-0.57735, 0.57735, -0.57735] z->axis0 [-0.707107, -0.707107, 0] z->axis1 [-0.408248, 0.408248, 0.816497] star_position_scale 0.763932 c0 [-0.850651, 0.525731, 0] c1 [0, 0.850651, -0.525731] c2 [-0.525731, 0, -0.850651]

67 z->center [-0.762575, 0.580411, -0.285662] z->axis0 [-0.605648, -0.795733, 0] z->axis1 [-0.227311, 0.173011, 0.95833] star_position_scale 0.381966 c0 [-0.850651, 0.525731, 0] c1 [-0.5, 0.809017, -0.309017] c2 [-0.809017, 0.309017, -0.5]

68 z->center [-0.285662, 0.762575, -0.580411] z->axis0 [-0.936452, -0.350797, 0] z->axis1 [-0.203606, 0.543526, 0.814324] star_position_scale 0.381966 c0 [-0.5, 0.809017, -0.309017] c1 [0, 0.850651, -0.525731] c2 [-0.309017, 0.5, -0.809017]

69 z->center [-0.580411, 0.285662, -0.762575] z->axis0 [-0.441587, -0.897219, 0] z->axis1 [-0.684196, 0.336743, 0.6469] star_position_scale 0.381966 c0 [-0.809017, 0.309017, -0.5] c1 [-0.309017, 0.5, -0.809017] c2 [-0.525731, 0, -0.850651]

70 z->center [-0.57735, 0.57735, -0.57735] z->axis0 [-0.707107, -0.707107, 0] z->axis1 [-0.408248, 0.408248, 0.816497] star_position_scale 0.381966 c0 [-0.309017, 0.5, -0.809017] c1 [-0.809017, 0.309017, -0.5] c2 [-0.5, 0.809017, -0.309017]

checkAndLoadCatal visitTriangles 15

71 z->center [-0.356822, 0.934172, 0] z->axis0 [-0.934172, -0.356822, 0] z->axis1 [0, 0, 1] star_position_scale 0.763932 c0 [0, 0.850651, 0.525731] c1 [0, 0.850651, -0.525731] c2 [-0.850651, 0.525731, 0]

72 z->center [-0.176549, 0.939124, 0.294748] z->axis0 [-0.982784, -0.184757, 0] z->axis1 [0.0544568, -0.289674, 0.955575] star_position_scale 0.381966 c0 [0, 0.850651, 0.525731] c1 [0, 1, 0] c2 [-0.5, 0.809017, 0.309017]

73 z->center [-0.176549, 0.939124, -0.294748] z->axis0 [-0.982784, -0.184757, 0] z->axis1 [-0.0544568, 0.289674, 0.955575] star_position_scale 0.381966 c0 [0, 1, 0] c1 [0, 0.850651, -0.525731] c2 [-0.5, 0.809017, -0.309017]

74 z->center [-0.653462, 0.75696, 0] z->axis0 [-0.75696, -0.653462, 0] z->axis1 [0, 0, 1] star_position_scale 0.381966 c0 [-0.5, 0.809017, 0.309017] c1 [-0.5, 0.809017, -0.309017] c2 [-0.850651, 0.525731, 0]

75 z->center [-0.356822, 0.934172, 0] z->axis0 [-0.934172, -0.356822, 0] z->axis1 [0, 0, 1] star_position_scale 0.381966 c0 [-0.5, 0.809017, -0.309017] c1 [-0.5, 0.809017, 0.309017] c2 [0, 1, 0]

checkAndLoadCatal visitTriangles 16

76 z->center [-0.57735, 0.57735, 0.57735] z->axis0 [-0.707107, -0.707107, 0] z->axis1 [0.408248, -0.408248, 0.816497] star_position_scale 0.763932 c0 [-0.850651, 0.525731, 0] c1 [-0.525731, 0, 0.850651] c2 [0, 0.850651, 0.525731]

77 z->center [-0.762575, 0.580411, 0.285662] z->axis0 [-0.605648, -0.795733, 0] z->axis1 [0.227311, -0.173011, 0.95833] star_position_scale 0.381966 c0 [-0.850651, 0.525731, 0] c1 [-0.809017, 0.309017, 0.5] c2 [-0.5, 0.809017, 0.309017]

78 z->center [-0.580411, 0.285662, 0.762575] z->axis0 [-0.441587, -0.897219, 0] z->axis1 [0.684196, -0.336743, 0.6469] star_position_scale 0.381966 c0 [-0.809017, 0.309017, 0.5] c1 [-0.525731, 0, 0.850651] c2 [-0.309017, 0.5, 0.809017]

79 z->center [-0.285662, 0.762575, 0.580411] z->axis0 [-0.936452, -0.350797, 0] z->axis1 [0.203606, -0.543526, 0.814324] star_position_scale 0.381966 c0 [-0.5, 0.809017, 0.309017] c1 [-0.309017, 0.5, 0.809017] c2 [0, 0.850651, 0.525731]

80 z->center [-0.57735, 0.57735, 0.57735] z->axis0 [-0.707107, -0.707107, 0] z->axis1 [0.408248, -0.408248, 0.816497] star_position_scale 0.381966 c0 [-0.309017, 0.5, 0.809017] c1 [-0.5, 0.809017, 0.309017] c2 [-0.809017, 0.309017, 0.5]

checkAndLoadCatal visitTriangles 17

81 z->center [0.57735, 0.57735, -0.57735] z->axis0 [-0.707107, 0.707107, 0] z->axis1 [0.408248, 0.408248, 0.816497] star_position_scale 0.763932 c0 [0, 0.850651, -0.525731] c1 [0.850651, 0.525731, 0] c2 [0.525731, 0, -0.850651]

82 z->center [0.285662, 0.762575, -0.580411] z->axis0 [-0.936452, 0.350797, 0] z->axis1 [0.203606, 0.543526, 0.814324] star_position_scale 0.381966 c0 [0, 0.850651, -0.525731] c1 [0.5, 0.809017, -0.309017] c2 [0.309017, 0.5, -0.809017]

83 z->center [0.762575, 0.580411, -0.285662] z->axis0 [-0.605648, 0.795733, 0] z->axis1 [0.227311, 0.173011, 0.95833] star_position_scale 0.381966 c0 [0.5, 0.809017, -0.309017] c1 [0.850651, 0.525731, 0] c2 [0.809017, 0.309017, -0.5]

84 z->center [0.580411, 0.285662, -0.762575] z->axis0 [-0.441587, 0.897219, 0] z->axis1 [0.684196, 0.336743, 0.6469] star_position_scale 0.381966 c0 [0.309017, 0.5, -0.809017] c1 [0.809017, 0.309017, -0.5] c2 [0.525731, 0, -0.850651]

85 z->center [0.57735, 0.57735, -0.57735] z->axis0 [-0.707107, 0.707107, 0] z->axis1 [0.408248, 0.408248, 0.816497] star_position_scale 0.381966 c0 [0.809017, 0.309017, -0.5] c1 [0.309017, 0.5, -0.809017] c2 [0.5, 0.809017, -0.309017]

checkAndLoadCatal visitTriangles 18

86 z->center [0.356822, 0.934172, 0] z->axis0 [-0.934172, 0.356822, 0] z->axis1 [0, 0, 1] star_position_scale 0.763932 c0 [0, 0.850651, -0.525731] c1 [0, 0.850651, 0.525731] c2 [0.850651, 0.525731, 0]

87 z->center [0.176549, 0.939124, -0.294748] z->axis0 [-0.982784, 0.184757, 0] z->axis1 [0.0544568, 0.289674, 0.955575] star_position_scale 0.381966 c0 [0, 0.850651, -0.525731] c1 [0, 1, 0] c2 [0.5, 0.809017, -0.309017]

88 z->center [0.176549, 0.939124, 0.294748] z->axis0 [-0.982784, 0.184757, 0] z->axis1 [-0.0544568, -0.289674, 0.955575] star_position_scale 0.381966 c0 [0, 1, 0] c1 [0, 0.850651, 0.525731] c2 [0.5, 0.809017, 0.309017]

89 z->center [0.653462, 0.75696, 0] z->axis0 [-0.75696, 0.653462, 0] z->axis1 [0, 0, 1] star_position_scale 0.381966 c0 [0.5, 0.809017, -0.309017] c1 [0.5, 0.809017, 0.309017] c2 [0.850651, 0.525731, 0]

90 z->center [0.356822, 0.934172, 0] z->axis0 [-0.934172, 0.356822, 0] z->axis1 [0, 0, 1] star_position_scale 0.381966 c0 [0.5, 0.809017, 0.309017] c1 [0.5, 0.809017, -0.309017] c2 [0, 1, 0]

checkAndLoadCatal visitTriangles 19

91 z->center [0.57735, 0.57735, 0.57735] z->axis0 [-0.707107, 0.707107, 0] z->axis1 [-0.408248, -0.408248, 0.816497] star_position_scale 0.763932 c0 [0, 0.850651, 0.525731] c1 [0.525731, 0, 0.850651] c2 [0.850651, 0.525731, 0]

92 z->center [0.285662, 0.762575, 0.580411] z->axis0 [-0.936452, 0.350797, 0] z->axis1 [-0.203606, -0.543526, 0.814324] star_position_scale 0.381966 c0 [0, 0.850651, 0.525731] c1 [0.309017, 0.5, 0.809017] c2 [0.5, 0.809017, 0.309017]

93 z->center [0.580411, 0.285662, 0.762575] z->axis0 [-0.441587, 0.897219, 0] z->axis1 [-0.684196, -0.336743, 0.6469] star_position_scale 0.381966 c0 [0.309017, 0.5, 0.809017] c1 [0.525731, 0, 0.850651] c2 [0.809017, 0.309017, 0.5]

94 z->center [0.762575, 0.580411, 0.285662] z->axis0 [-0.605648, 0.795733, 0] z->axis1 [-0.227311, -0.173011, 0.95833] star_position_scale 0.381966 c0 [0.5, 0.809017, 0.309017] c1 [0.809017, 0.309017, 0.5] c2 [0.850651, 0.525731, 0]

95 z->center [0.57735, 0.57735, 0.57735] z->axis0 [-0.707107, 0.707107, 0] z->axis1 [-0.408248, -0.408248, 0.816497] star_position_scale 0.381966 c0 [0.809017, 0.309017, 0.5] c1 [0.5, 0.809017, 0.309017] c2 [0.309017, 0.5, 0.809017]

checkAndLoadCatal visitTriangles 20

96 z->center [0, 0.356822, 0.934172] z->axis0 [-1, 0, 0] z->axis1 [0, -0.934172, 0.356822] star_position_scale 0.763932 c0 [-0.525731, 0, 0.850651] c1 [0.525731, 0, 0.850651] c2 [0, 0.850651, 0.525731]

97 z->center [-0.294748, 0.176549, 0.939124] z->axis0 [-0.513854, -0.857878, 0] z->axis1 [0.805654, -0.482573, 0.343578] star_position_scale 0.381966 c0 [-0.525731, 0, 0.850651] c1 [0, 0, 1] c2 [-0.309017, 0.5, 0.809017]

98 z->center [0.294748, 0.176549, 0.939124] z->axis0 [-0.513854, 0.857878, 0] z->axis1 [-0.805654, -0.482573, 0.343578] star_position_scale 0.381966 c0 [0, 0, 1] c1 [0.525731, 0, 0.850651] c2 [0.309017, 0.5, 0.809017]

99 z->center [0, 0.653462, 0.75696] z->axis0 [-1, 0, 0] z->axis1 [0, -0.75696, 0.653462] star_position_scale 0.381966 c0 [-0.309017, 0.5, 0.809017] c1 [0.309017, 0.5, 0.809017] c2 [0, 0.850651, 0.525731]

100 z->center [0, 0.356822, 0.934172] z->axis0 [-1, 0, 0] z->axis1 [0, -0.934172, 0.356822] star_position_scale 0.381966 c0 [0.309017, 0.5, 0.809017] c1 [-0.309017, 0.5, 0.809017] c2 [0, 0, 1]

重点结论:star_position_scale = 0.763932

mu0 = (A(11,:) - center(1,:)) * axis0.';
mu1 = (A(11,:) - center(1,:)) * axis1.';
f = 1/(sqrt(1-mu0^2 -mu1^2));
h = abs(mu1)*f;

梳理好顺序之后,可以进入ZoneArray::initTriangle中进行查看,尝试第一个中点和轴的信息。

% plot_triangle.m 
% 12个顶点,30条棱,20个面
clear all; close all;
m = sqrt(50-10*sqrt(5))/10;
n = sqrt(50+10*sqrt(5))/10;
A = [ % 12个顶点
n,-m,0;
n,m,0;
-n,m,0;
-n,-m,0;
0,n,-m;
0,n,m;
0,-n,m;
0,-n,-m;
-m,0,n;
m,0,n;
m,0,-n;
-m,0,-n;
];
scatter3(A(:,1),A(:,2),A(:,3));
hold on;
center=[];c0=[];c1=[];c2=[];


[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,1,0,10); % 20个面
[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,0,1,9);
[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,0,9,6);

[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,9,8,6);
[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,0,7,10);
[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,6,7,0);

[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,7,6,3);
[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,6,8,3);
[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,11,10,7);

[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,7,3,11);
[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,3,2,11);
[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,2,3,8);

[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,10,11,4);
[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,2,4,11);
[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,5,4,2);

[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,2,8,5);
[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,4,1,10);
[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,4,5,1);

[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,5,9,1);
[center(end+1,:),c0(end+1,:),c1(end+1,:),c2(end+1,:)] = plot_triangle(A,8,9,5);

hold on;
quiver3(0,0,0,1,0,0);
quiver3(0,0,0,0,1,0);
quiver3(0,0,0,0,0,1);
text(1,0,0,'x');
text(0,1,0,'y');
text(0,0,1,'z');
text(A(2,1),A(2,2),A(2,3),'c0');
text(A(1,1),A(1,2),A(1,3),'c1');
text(A(11,1),A(11,2),A(11,3),'c2');

hold on;
d1=2;d2=1;d3=11;
line([A(d1,1),A(d2,1),A(d3,1),A(d1,1)],[A(d1,2),A(d2,2),A(d3,2),A(d1,2)],[A(d1,3),A(d2,3),A(d3,3),A(d1,3)],'color','r');
hold on;

scatter3(center(1,1),center(1,2),center(1,3));
hold on;
axis0 = cross([0,0,1],center(1,:));
axis0 = axis0./norm(axis0);
axis1 = cross(center(1,:),axis0);
axis1 = axis1./norm(axis1);
quiver3(center(1,1),center(1,2),center(1,3),axis0(1,1),axis0(1,2),axis0(1,3));
quiver3(center(1,1),center(1,2),center(1,3),axis1(1,1),axis1(1,2),axis1(1,3));


axis equal;

image-20220313100715334

​ // Initialize star_position_scale. This scale is used to multiply stars position
​ // encoded as integers so that it optimize precision over the triangle.
​ // It has to be computed for each triangle because the relative orientation of the 2 axis is different for each triangle.

// 初始化star_position_scale。 此比例用于乘以星星位置

// 编码为整数,以便优化三角形的精度。

// 必须为每个三角形计算它,因为每个三角形的 2 轴的相对方向不同。


MaxPosVal 2147483647=0x7fff ffff

20个大三角形 star_position_scale = 0.763932

80个小三角形 star_position_scale 0.381966

在ZoneArray.cpp中 查看变量 star_position_scale

mag_min 这一层中星等的下界。单位:millimag(10−3)。对最亮的恒星可能是负的。-2000 和 6000

mag_range 这一层星等的范围,都为12.8星等。单位:millimags

mag_steps 用于描述mag_range中的值的步骤数都为256 。总是正的。单个恒星的mag条目从0..mag_steps开始 256 12800/256=50 .每次移动 一步0.05mags,可以看到软件中最低分辨率为0.05星等。最多256步。

arg(level=01).arg(type=0).arg(major=0).arg(minor=8)
class HipZoneArray : public SpecialZoneArray<Star1>
class SpecialZoneArray : public ZoneArray

rval = new HipZoneArray(file, byte_swap, use_mmap, level, mag_min, mag_range, mag_steps);
SpecialZoneArray<Star>::SpecialZoneArray();

在该函数中,可以得到star.hpp中的信息

          _______________
0 x0 | |
1 |___________ |
2 x1 | |___|
3 |_______ |
4 bV |_______|_______|
5 mag |_________|_____| bV

int x0 :18
int x1 :18
unsigned int bV :7
unsigned int mag :5

点鼠标一下,这是可以触发的函数。

StelObjectMgr::cleverFind
StarMgr::searchAround 指向 放大倍率
SpecialZoneArray< Star>::searchAround
s->getJ2000Pos(z, static_cast< float>(movementFactor), tmp);


注意到只有这里一次调用了星表里的26785=4979+21806个数据。

StarMgr::loadData
z->updateHipIndex(hipIndex);

​ HipZoneArray::updateHipIndex

因此在ZoneArray.cpp中仿写saveHipIndex函数为

void HipZoneArray::saveHipIndex(HipIndexStruct hipIndex[]) const {
StelCore* core = StelApp::getInstance().getCore();
static const double d2000 = 2451545.0;
const double movementFactor = (M_PI / 180.) * (0.0001 / 3600.) * ((core->getJDE() - d2000) / 365.25) / static_cast<double>(star_position_scale);
for (const SpecialZoneData<Star1> *z = getZones() + (nr_of_zones - 1); z >= getZones(); z--) { // 100次
for (const Star1 *s = z->getStars() + z->size - 1; s >= z->getStars(); s--) {
Vec3f tmp;
s->getJ2000Pos(z, static_cast<float>(movementFactor), tmp);
qDebug() << "checkAndLoadCatalogcheckAndLoadCatalog" << ++aa << s->getHip() << s->getX0() << s->getX1() << s->getDx0() << s->getDx1() << s->getBV() << s->getMag() << s->getPlx() << s->getSpInt() << s->getBVIndex() << s->hasName() << tmp;
}
}
}

保存文件的代码:

void HipZoneArray::saveHipIndex(HipIndexStruct hipIndex[]) const {
QFile myFile("C:/Users/hp/Desktop/catalog.txt");
if (myFile.open(QFile::WriteOnly | QFile::Append | QIODevice::Text)) {
QTextStream out(&myFile);
StelCore* core = StelApp::getInstance().getCore();
static const double d2000 = 2451545.0;
const double movementFactor = (M_PI / 180.) * (0.0001 / 3600.) * ((core->getJDE() - d2000) / 365.25) / static_cast<double>(star_position_scale);
for (const SpecialZoneData<Star1> *z = getZones() + (nr_of_zones - 1); z >= getZones(); z--) { // 100次
for (const Star1 *s = z->getStars() + z->size - 1; s >= z->getStars(); s--) {
Vec3f tmp;
s->getJ2000Pos(z, static_cast<float>(movementFactor), tmp);
tmp.normalize();
Vec3d vel = core->getCurrentPlanet()->getHeliocentricEclipticVelocity();
vel = StelCore::matVsop87ToJ2000 * vel * core->getAberrationFactor() * (AU / (86400.0 * SPEED_OF_LIGHT));
Vec3d pos = tmp.toVec3d() + vel;
pos.normalize();
qDebug() << "checkAndLoadCatalogcheckAndLoadCatalog" << ++aa << s->getHip() << " " << s->getX0() << " " << s->getX1() << " " << s->getDx0() << " " << s->getDx1() << " " << s->getBV() << " " << s->getMag() << " " << s->getPlx() << " " << s->getSpInt() << " " << s->getBVIndex() << " " << s->hasName() << " " << tmp << " " << level << " " << z->getNrOfStars() << " " << star_position_scale << "\n";
out << aa << " " << s->getHip() << " " << s->getX0() << " " << s->getX1() << " " << s->getDx0() << " " << s->getDx1() << " " << s->getBV() << " " << s->getMag() << " " << s->getPlx() << " " << s->getSpInt() << " " << s->getBVIndex() << " " << s->hasName() << " " << pos[0] << " " << pos[1] << " " << pos[2] << " " << level << " " << z->getNrOfStars() << " " << star_position_scale << "\n";
}
}
}
myFile.close();
}

在StarMgr.cpp的StarMgr::searchAround中添加

qDebug() << "searchAround" << ++bbbb << vv << limFov;
if(bbbb >= 23 )
for (auto* z : gridLevels)
z->saveHipIndex( hipIndex);

image-20220316101930812

clear all;close all;clc;
tic
A = importdata("catalog.txt");
hip = A(:,2);
x0 = A(:,3);
x1 = A(:,4);
dx0 = A(:,5);
dx1 = A(:,6);
bv = A(:,7);
mag = A(:,8);
plx = A(:,9);
spInt = A(:,10);
bvIndex = A(:,11);
hasName = A(:,12);
xyz = A(:,13:15);
level = A(:,16);
getNrOfStars = A(:,17);
star_position_scale = A(:,18);

mag_true = mag .* 0.05 + 6;

b = asind(xyz(:,3));
a = acosd(xyz(:,1)./sqrt(1-xyz(:,3).^2));
for i=1:length(b)
if(xyz(i,2)<0)
a(i,:)=360-a(i,:);
end
if(level(i)==0)
mag_true(i) = -2 + mag(i) * 0.05;
end
end

hh1 = (a./15);
hh = fix(hh1);
mm1 = (a./15 - hh)*60;
mm = fix(mm1);
ss = (mm1 - mm)*60;

al_hh = fix(b);
al_mm1 = (abs(b)-abs(al_hh))*60;
al_mm = fix(al_mm1);
al_ss = (al_mm1 - al_mm)*60;


A=[A,a,b,hh,mm,ss,al_hh,al_mm,al_ss,mag_true];

xlswrite('catal',A);
toc

getJ2000Pos 函数

getJ2000EquatorialPos (StarWrapper.hpp)

只有StarWrapper.cpp 和 ZoneArray.cpp 包含 #include “StarWrapper.hpp”

ZoneArray.cpp
StarMgr.hpp

class StelRegionObject //抽象基类 	
virtual Vec3d getPointInRegion() const=0;
class StelObject : public StelRegionObject
virtual QString getInfoString(const StelCore *, const InfoStringGroup& ) const = 0; //抽象基类
class Exoplanet : public StelObject
class MeteorShower : public StelObject
class Nova : public StelObject
class Pulsar : public StelObject
class Quasar : public StelObject
class Satellite : public StelObject
class Supernova : public StelObject
class TelescopeClient : public QObject, public StelObject
class TelescopeClientASCOM : public TelescopeClient
class TelescopeClientINDI : public TelescopeClient
class TelescopeClientDirectLx200 : public TelescopeClient, public Server
class TelescopeClientDirectNexStar : public TelescopeClient, public Server
class TelescopeClientJsonRts2 : public TelescopeClient
class Asterism : public StelObject
class Constellation : public StelObject
class CustomObject : public StelObject
class Nebula : public StelObject
class NomenclatureItem : public StelObject
class Planet : public StelObject

class StarWrapperBase : public StelObject
class StarWrapper : public StarWrapperBase
virtual Vec3d getJ2000EquatorialPos(const StelCore * core) const Q_DECL_OVERRIDE
class StarWrapper1 : public StarWrapper<Star1>
class StarWrapper2 : public StarWrapper<Star2>
class StarWrapper3 : public StarWrapper<Star3>

验证从二进制文件到赤经赤纬

qDebug() << "checkAndLoadCatalogcheckAndLoadCatalog"  << ++aa << s->getHip()  << "  " << s->getX0() << "  " << s->getX1() << "  " << s->getDx0() << "  " << s->getDx1() << "  " <<  s->getBV() << "  " << s->getMag()  << "  " << s->getPlx() << "  " << s->getSpInt() << "  " << s->getBVIndex() << "  " <<  s->hasName() << "  " <<  tmp  << "  " << level << "  " << z->getNrOfStars()  << "  " << star_position_scale << movementFactor << core->getJDE() << "\n";

image-20220317144732768

验证最后一个星

s->getJ2000Pos(z, static_cast<float>(movementFactor), tmp);

进入函数
pos = (z->center) + (getX0())+movementFactorgetDx0()) (z->axis0) + (getX1())+movementFactorgetDx1()) (z->axis1);

(-623411838+ans*(-37) )* [-5.32625e-11, 1.69705e-10, 0]+(-188238807+ans*(-2097))*[2.99612e-11, 9.40346e-12, 1.75073e-10]+[0.939124, 0.294748, -0.176549]

ans =

0.9667 0.1872 -0.2095
ans./norm(ans)

ans =

0.9603 0.1859 -0.2081
[0.960264, 0.185937, -0.208135]差不多

ans +[-7.89179e-06, -9.1333e-05, -3.95923e-05]

ans =

0.9603 0.1858 -0.2082

movementFactor = (M_PI / 180.) (0.0001 / 3600.) ((core->getJDE() - d2000) / 365.25) /(star_position_scale);

core->getJDE() = 2459656

d2000 = 2451545.0 截止2022.3.17 差距8111天

3.14159265358979323846 / 180.0 * 0.0001/3600.0*8111/365.25/60.5274

ans =

1.7787e-10

image-20220317145315365

最终得到包含赤经赤纬星等的表

image-20220317161906242