加载中...
搜索中...
无匹配项
degrees_to_radians.cuh
前往此文件的文档。
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 <cuproj/constants.hpp>
20#include <cuproj/detail/utility/cuda.hpp>
22
23namespace cuproj {
24
29
35template <typename Coordinate>
36class degrees_to_radians : operation<Coordinate> {
37 public
46 CUPROJ_HOST_DEVICE Coordinate operator()(Coordinate const& coord, direction dir) const
47 {
48 if (dir == direction::FORWARD)
49 return forward(coord);
50 else
51 return inverse(coord);
52 }
53
54 private
61 CUPROJ_HOST_DEVICE Coordinate forward(Coordinate const& coord) const
62 {
63 using T = typename Coordinate::value_type;
64 return Coordinate{coord.x * DEG_TO_RAD<T>, coord.y * DEG_TO_RAD<T>};
65 }
66
73 CUPROJ_HOST_DEVICE Coordinate inverse(Coordinate const& coord) const
74 {
75 using T = typename Coordinate::value_type;
76 return Coordinate{coord.x * RAD_TO_DEG<T>, coord.y * RAD_TO_DEG<T>};
77 }
78};
79
83
84} // namespace cuproj
将度转换为弧度,反之亦然。
CUPROJ_HOST_DEVICE Coordinate operator()(Coordinate const &coord, direction dir) const
将度转换为弧度,反之亦然。
所有转换操作的基类。
constexpr T DEG_TO_RAD
从度到弧度的转换因子。
constexpr T RAD_TO_DEG
从弧度到度的转换因子。
direction
枚举转换操作的方向。