libcuproj  24.04.00
Loading...
Searching...
No Matches
degrees_to_radians.cuh
Go to the documentation of this file.
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 * http://www.apache.org/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
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
84} // namespace cuproj
Converts degrees to radians and vice versa.
CUPROJ_HOST_DEVICE Coordinate operator()(Coordinate const &coord, direction dir) const
Converts degrees to radians and vice versa.
Base class for all transform operations.
Definition operation.cuh:63
direction
Enumerates the direction of a transform operation.
Definition operation.cuh:44