Branch data Line data Source code
1 : : // ----------------- BEGIN LICENSE BLOCK --------------------------------- 2 : : // 3 : : // Copyright (C) 2018-2021 Intel Corporation 4 : : // 5 : : // SPDX-License-Identifier: MIT 6 : : // 7 : : // ----------------- END LICENSE BLOCK ----------------------------------- 8 : : /** 9 : : * @file 10 : : */ 11 : : 12 : : #pragma once 13 : : 14 : : #include "ad/map/point/ENUEdgeValidInputRange.hpp" 15 : : #include "ad/map/point/ENUPointValidInputRange.hpp" 16 : : #include "ad/map/point/PointOperation.hpp" 17 : : 18 : : namespace ad { 19 : : namespace map { 20 : : namespace point { 21 : : 22 : : /** 23 : : * @brief checks if the given ENUPoint is valid 24 : : * 25 : : * The point is valid if it's within valid input range. 26 : : */ 27 : 25448 : inline bool isValid(ENUPoint const &point, bool const logErrors = true) 28 : : { 29 : 25448 : return withinValidInputRange(point, logErrors); 30 : : } 31 : : 32 : : /** 33 : : * @brief checks if the given ENUEdge is valid 34 : : * 35 : : * The edge is valid if it's within valid input range. 36 : : */ 37 : 12 : inline bool isValid(ENUEdge const &edge, bool const logErrors = true) 38 : : { 39 : 12 : return withinValidInputRange(edge, logErrors); 40 : : } 41 : : 42 : : /** 43 : : * @brief create a ENUPoint 44 : : * 45 : : * @param[in] x x-coodinate of the point 46 : : * @param[in] y y-coodinate of the point 47 : : * @param[in] z z-coodinate of the point 48 : : */ 49 : 23477 : inline ENUPoint createENUPoint(double const x, double const y, double const z) 50 : : { 51 : 23477 : ENUPoint result; 52 : 23477 : result.x = ENUCoordinate(x); 53 : 23477 : result.y = ENUCoordinate(y); 54 : 23477 : result.z = ENUCoordinate(z); 55 : 23477 : return result; 56 : : } 57 : : 58 : : /** 59 : : * @brief create a ENUPoint 60 : : * 61 : : * @param[in] x x-coodinate of the point 62 : : * @param[in] y y-coodinate of the point 63 : : * @param[in] z z-coodinate of the point 64 : : */ 65 : 1156 : inline ENUPoint createENUPoint(ENUCoordinate const x, ENUCoordinate const y, ENUCoordinate const z) 66 : : { 67 : 1156 : ENUPoint result; 68 : 1156 : result.x = x; 69 : 1156 : result.y = y; 70 : 1156 : result.z = z; 71 : 1156 : return result; 72 : : } 73 : : 74 : : /** 75 : : * @brief get ENUPoint defining the East-Axis 76 : : */ 77 : 1130 : inline ENUPoint getEnuEastAxis() 78 : : { 79 : 1130 : ENUPoint result; 80 : 1130 : result.x = ENUCoordinate(1.); 81 : 1130 : result.y = ENUCoordinate(0.); 82 : 1130 : result.z = ENUCoordinate(0.); 83 : 1130 : return result; 84 : : } 85 : : 86 : : /** 87 : : * @brief get ENUPoint defining the North-Axis 88 : : */ 89 : : inline ENUPoint getEnuNorthAxis() 90 : : { 91 : : ENUPoint result; 92 : : result.x = ENUCoordinate(0.); 93 : : result.y = ENUCoordinate(1.); 94 : : result.z = ENUCoordinate(0.); 95 : : return result; 96 : : } 97 : : 98 : : /** 99 : : * @brief get ENUPoint defining the Up-Axis 100 : : */ 101 : 1130 : inline ENUPoint getEnuUpAxis() 102 : : { 103 : 1130 : ENUPoint result; 104 : 1130 : result.x = ENUCoordinate(0.); 105 : 1130 : result.y = ENUCoordinate(0.); 106 : 1130 : result.z = ENUCoordinate(1.); 107 : 1130 : return result; 108 : : } 109 : : 110 : : /** 111 : : * @brief Computes distance between ENU points. 112 : : * @returns Distance between two points in meters. 113 : : */ 114 : 269 : inline physics::Distance distance(ENUPoint const &point, ENUPoint const &other) 115 : : { 116 [ + - ]: 538 : return vectorLength(vectorSub(point, other)); 117 : : } 118 : : 119 : : /** @brief calculate the length of the provided border as distance value 120 : : * 121 : : * Length calculation is performed within Cartesian ECEF coordinate frame. 122 : : */ 123 : : physics::Distance calcLength(ENUEdge const &edge); 124 : : 125 : : } // namespace point 126 : : } // namespace map 127 : : } // namespace ad 128 : : 129 : : /** 130 : : * @brief calculate the dot product of two ENUPoint vectors 131 : : * 132 : : * @param[in] a vector a 133 : : * @param[in] b vector b 134 : : * 135 : : * @returns value d = a * b 136 : : */ 137 : 20 : inline double operator*(::ad::map::point::ENUPoint const &a, ::ad::map::point::ENUPoint const &b) 138 : : { 139 : 20 : return ::ad::map::point::vectorDotProduct(a, b); 140 : : } 141 : : 142 : : /** 143 : : * @brief multiplies a ENUPoint vector with a scalar 144 : : * @param[in] a vector a 145 : : * @param[in] b scalar b 146 : : */ 147 : : inline ::ad::map::point::ENUPoint operator*(::ad::map::point::ENUPoint const &a, ::ad::physics::Distance const &b) 148 : : { 149 : : return ::ad::map::point::vectorMultiplyScalar(a, b); 150 : : } 151 : : 152 : : /** 153 : : * @brief multiplies a ENUPoint vector with a scalar 154 : : * @param[in] b scalar b 155 : : * @param[in] a vector a 156 : : */ 157 : : inline ::ad::map::point::ENUPoint operator*(::ad::physics::Distance const &b, ::ad::map::point::ENUPoint const &a) 158 : : { 159 : : return ::ad::map::point::vectorMultiplyScalar(a, b); 160 : : } 161 : : 162 : : /** 163 : : * @brief multiplies a ENUPoint vector with a scalar 164 : : * @param[in] a vector a 165 : : * @param[in] b scalar b 166 : : */ 167 : : inline ::ad::map::point::ENUPoint operator*(::ad::map::point::ENUPoint const &a, double const &b) 168 : : { 169 : : return ::ad::map::point::vectorMultiplyScalar(a, b); 170 : : } 171 : : 172 : : /** 173 : : * @brief multiplies a ENUPoint vector with a scalar 174 : : * @param[in] b scalar b 175 : : * @param[in] a vector a 176 : : */ 177 : 11 : inline ::ad::map::point::ENUPoint operator*(double const &b, ::ad::map::point::ENUPoint const &a) 178 : : { 179 : 11 : return ::ad::map::point::vectorMultiplyScalar(a, b); 180 : : } 181 : : 182 : : /** 183 : : * @brief add two ENUPoint vectors 184 : : * 185 : : * @param[in] a vector a 186 : : * @param[in] b vector b 187 : : * 188 : : * @returns vector c = a + b 189 : : */ 190 : 8 : inline ::ad::map::point::ENUPoint operator+(::ad::map::point::ENUPoint const &a, ::ad::map::point::ENUPoint const &b) 191 : : { 192 : 8 : return ::ad::map::point::vectorAdd(a, b); 193 : : } 194 : : 195 : : /** 196 : : * @brief subtract two ENUPoint vectors from each right 197 : : * 198 : : * @param[in] a vector a 199 : : * @param[in] b vector b 200 : : * 201 : : * @returns c = a - b 202 : : */ 203 : 42 : inline ::ad::map::point::ENUPoint operator-(::ad::map::point::ENUPoint const &a, ::ad::map::point::ENUPoint const &b) 204 : : { 205 : 42 : return ::ad::map::point::vectorSub(a, b); 206 : : }