OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vec3d.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Uber Technologies, Inc.
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  */
21 
22 // #include <math.h>
23 
30 EXTENSION_INLINE double _square(double x) {
31  return x * x;
32 }
33 
41 EXTENSION_NOINLINE double _pointSquareDist(const Vec3d(v1), const Vec3d(v2)) {
42  return _square(v1[X_INDEX] - v2[X_INDEX]) + _square(v1[Y_INDEX] - v2[Y_INDEX]) +
43  _square(v1[Z_INDEX] - v2[Z_INDEX]);
44 }
45 
53  double r = cos(geo[LAT_INDEX]);
54 
55  v[Z_INDEX] = sin(geo[LAT_INDEX]);
56  v[X_INDEX] = cos(geo[LON_INDEX]) * r;
57  v[Y_INDEX] = sin(geo[LON_INDEX]) * r;
58 
59  return true;
60 }
#define GeoCoord(variable_name)
Definition: h3api.h:94
#define Z_INDEX
Definition: vec3d.h:28
#define EXTENSION_NOINLINE
Definition: OmniSciTypes.h:28
#define LAT_INDEX
Definition: h3api.h:92
#define X_INDEX
Definition: vec2d.h:26
#define Vec3d(variable_name)
Definition: vec3d.h:29
EXTENSION_NOINLINE bool _geoToVec3d(const GeoCoord(geo), Vec3d(v))
Definition: vec3d.hpp:52
3D floating point vector functions.
#define LON_INDEX
Definition: h3api.h:93
EXTENSION_INLINE double _square(double x)
Definition: vec3d.hpp:30
#define Y_INDEX
Definition: vec2d.h:27
#define EXTENSION_INLINE
Definition: OmniSciTypes.h:27
EXTENSION_NOINLINE double _pointSquareDist(const Vec3d(v1), const Vec3d(v2))
Definition: vec3d.hpp:41