Fesapi 2.3.0.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
Trigonometry.h
1/*-----------------------------------------------------------------------
2Licensed to the Apache Software Foundation (ASF) under one
3or more contributor license agreements. See the NOTICE file
4distributed with this work for additional information
5regarding copyright ownership. The ASF licenses this file
6to you under the Apache License, Version 2.0 (the
7"License"; you may not use this file except in compliance
8with the License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12Unless required by applicable law or agreed to in writing,
13software distributed under the License is distributed on an
14"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15KIND, either express or implied. See the License for the
16specific language governing permissions and limitations
17under the License.
18-----------------------------------------------------------------------*/
19#pragma once
20
21#include <math.h>
22#include <stdexcept>
23
24#include "../proxies/gsoap_resqml2_0_1Stub.h"
25
26namespace trigonometry
27{
36 double convertToRadians(double angleValue, gsoap_resqml2_0_1::eml20__PlaneAngleUom angleUom)
37 {
38 constexpr double PI = 3.141592653589793238463;
39
40 if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::rad)
41 return angleValue;
42 else if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::_0_x002e001_x0020seca)
43 return angleValue * PI / 648000000;
44 else if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::ccgr)
45 return angleValue * PI / 2000000;
46 else if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::cgr)
47 return angleValue * PI / 20000;
48 else if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::dega)
49 return angleValue * PI / 180;
50 else if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::gon)
51 return angleValue * PI / 200;
52 else if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::krad)
53 return angleValue * 1000;
54 else if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::mila)
55 return angleValue * PI / 3200;
56 else if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::mina)
57 return angleValue * PI / 10800;
58 else if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::Mrad)
59 return angleValue * 1000000;
60 else if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::mrad)
61 return angleValue / 1000;
62 else if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::rev)
63 return angleValue * PI * 2;
64 else if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::seca)
65 return angleValue * PI / 648000;
66 else if (angleUom == gsoap_resqml2_0_1::eml20__PlaneAngleUom::urad)
67 return angleValue / 1000000;
68 else
69 throw std::invalid_argument("The uom of the angle has not been recognized.");
70 }
71
83 std::pair<double, double> rotateXY(double xSource, double ySource, double angleValue, gsoap_resqml2_0_1::eml20__PlaneAngleUom angleUom)
84 {
85 const double radAngleValue = convertToRadians(angleValue, angleUom);
86 const double cosAngle = cos(radAngleValue);
87 const double sinAngle = sin(radAngleValue);
88
89 return std::pair<double, double>(xSource * cosAngle - ySource * sinAngle, xSource * sinAngle + ySource * cosAngle);
90 }
91}
The trigonometry namespace.
double convertToRadians(double angleValue, gsoap_resqml2_0_1::eml20__PlaneAngleUom angleUom)
Definition: Trigonometry.h:36
std::pair< double, double > rotateXY(double xSource, double ySource, double angleValue, gsoap_resqml2_0_1::eml20__PlaneAngleUom angleUom)
Definition: Trigonometry.h:83