加载中...
搜索中...
无匹配项
ellipsoid.hpp
转到此文件的文档。
1/*
2 * Copyright (c) 2023, NVIDIA CORPORATION.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://apache.ac.cn/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <cassert>
20#include <cmath>
21
22namespace cuproj {
23
28
34template <typename T>
35struct ellipsoid {
36 ellipsoid() = default;
37
44 constexpr ellipsoid(T a, T inverse_flattening) : a(a)
45 {
46 assert(inverse_flattening != 0.0);
47 b = a * (1. - 1. / inverse_flattening);
48 f = 1.0 / inverse_flattening;
49 es = 2 * f - f * f;
50 e = sqrt(es);
51 alpha = asin(e);
52 n = pow(tan(alpha / 2), 2);
53 }
54
55 T a{}; // 半长轴
56 T b{}; // 半短轴
57 T e{}; // 第一偏心率
58 T es{}; // 第一偏心率平方
59 T alpha{}; // 角偏心率
60 T f{}; // 扁率
61 T n{}; // 第三扁率
62};
63
70template <typename T>
72{
73 return ellipsoid<T>{T{6378137.0}, T{298.257223563}};
74}
75
79
80} // 命名空间 cuproj
constexpr ellipsoid< T > make_ellipsoid_wgs84()
创建 WGS84 椭球体。
椭球体参数。
constexpr ellipsoid(T a, T inverse_flattening)
从半长轴和扁率倒数构造椭球体。