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/ECEFEdgeValidInputRange.hpp" 15 : : #include "ad/map/point/ECEFPointValidInputRange.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 ECEFPoint is valid 24 : : * 25 : : * The point is valid if it's within valid input range. 26 : : */ 27 : 7733990 : inline bool isValid(ECEFPoint const &point, bool const logErrors = true) 28 : : { 29 : 7733990 : return withinValidInputRange(point, logErrors); 30 : : } 31 : : 32 : : /** 33 : : * @brief checks if the given ECEFEdge is valid 34 : : * 35 : : * The point is valid if it's within valid input range. 36 : : */ 37 : 47705 : inline bool isValid(ECEFEdge const &edge, bool const logErrors = true) 38 : : { 39 : 47705 : return withinValidInputRange(edge, logErrors); 40 : : } 41 : : 42 : : /** 43 : : * @brief create a ECEFPoint 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 : 493426 : inline ECEFPoint createECEFPoint(double const x, double const y, double const z) 50 : : { 51 : 493426 : ECEFPoint result; 52 : 493426 : result.x = ECEFCoordinate(x); 53 : 493426 : result.y = ECEFCoordinate(y); 54 : 493426 : result.z = ECEFCoordinate(z); 55 : 493426 : return result; 56 : : } 57 : : 58 : : /** 59 : : * @brief create a ECEFPoint 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 : : inline ECEFPoint createECEFPoint(ECEFCoordinate const x, ECEFCoordinate const y, ECEFCoordinate const z) 66 : : { 67 : : ECEFPoint result; 68 : : result.x = x; 69 : : result.y = y; 70 : : result.z = z; 71 : : return result; 72 : : } 73 : : 74 : : /** 75 : : * @brief Computes distance between ECEF points. 76 : : * @returns Distance between two points in meters. 77 : : */ 78 : 84369700 : inline physics::Distance distance(ECEFPoint const &point, ECEFPoint const &other) 79 : : { 80 [ + - ]: 168739000 : return vectorLength(vectorSub(point, other)); 81 : : } 82 : : 83 : : /** @brief calculate the length of the provided border as distance value 84 : : * 85 : : * Length calculation is performed within Cartesian ECEF coordinate frame. 86 : : */ 87 : : physics::Distance calcLength(ECEFEdge const &edge); 88 : : 89 : : } // namespace point 90 : : } // namespace map 91 : : } // namespace ad 92 : : 93 : : /** 94 : : * @brief calculate the dot product of two ECEFPoint vectors 95 : : * 96 : : * @param[in] a vector a 97 : : * @param[in] b vector b 98 : : * 99 : : * @returns value d = a * b 100 : : */ 101 : : inline double operator*(::ad::map::point::ECEFPoint const &a, ::ad::map::point::ECEFPoint const &b) 102 : : { 103 : : return ::ad::map::point::vectorDotProduct(a, b); 104 : : } 105 : : 106 : : /** 107 : : * @brief multiplies a ECEFPoint vector with a scalar 108 : : * @param[in] a vector a 109 : : * @param[in] b scalar b 110 : : */ 111 : 68 : inline ::ad::map::point::ECEFPoint operator*(::ad::map::point::ECEFPoint const &a, ::ad::physics::Distance const &b) 112 : : { 113 : 68 : return ::ad::map::point::vectorMultiplyScalar(a, b); 114 : : } 115 : : 116 : : /** 117 : : * @brief multiplies a ECEFPoint vector with a scalar 118 : : * @param[in] b scalar b 119 : : * @param[in] a vector a 120 : : */ 121 : 3911 : inline ::ad::map::point::ECEFPoint operator*(::ad::physics::Distance const &b, ::ad::map::point::ECEFPoint const &a) 122 : : { 123 : 3911 : return ::ad::map::point::vectorMultiplyScalar(a, b); 124 : : } 125 : : 126 : : /** 127 : : * @brief multiplies a ECEFPoint vector with a scalar 128 : : * @param[in] a vector a 129 : : * @param[in] b scalar b 130 : : */ 131 : : inline ::ad::map::point::ECEFPoint operator*(::ad::map::point::ECEFPoint const &a, double const &b) 132 : : { 133 : : return ::ad::map::point::vectorMultiplyScalar(a, b); 134 : : } 135 : : 136 : : /** 137 : : * @brief multiplies a ECEFPoint vector with a scalar 138 : : * @param[in] b scalar b 139 : : * @param[in] a vector a 140 : : */ 141 : 47800 : inline ::ad::map::point::ECEFPoint operator*(double const &b, ::ad::map::point::ECEFPoint const &a) 142 : : { 143 : 47800 : return ::ad::map::point::vectorMultiplyScalar(a, b); 144 : : } 145 : : 146 : : /** 147 : : * @brief add two ECEFPoint vectors 148 : : * 149 : : * @param[in] a vector a 150 : : * @param[in] b vector b 151 : : * 152 : : * @returns vector c = a + b 153 : : */ 154 : 57182 : inline ::ad::map::point::ECEFPoint operator+(::ad::map::point::ECEFPoint const &a, ::ad::map::point::ECEFPoint const &b) 155 : : { 156 : 57182 : return ::ad::map::point::vectorAdd(a, b); 157 : : } 158 : : 159 : : /** 160 : : * @brief subtract two ECEFPoint vectors from each right 161 : : * 162 : : * @param[in] a vector a 163 : : * @param[in] b vector b 164 : : * 165 : : * @returns c = a - b 166 : : */ 167 : 47081100 : inline ::ad::map::point::ECEFPoint operator-(::ad::map::point::ECEFPoint const &a, ::ad::map::point::ECEFPoint const &b) 168 : : { 169 : 47081100 : return ::ad::map::point::vectorSub(a, b); 170 : : }