OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vec2d.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016-2017 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 // #include <stdio.h>
24 
30 EXTENSION_INLINE double _v2dMag(const Vec2d(v)) {
31  return sqrt(v[X_INDEX] * v[X_INDEX] + v[Y_INDEX] * v[Y_INDEX]);
32 }
33 
34 // /**
35 // * Finds the intersection between two lines. Assumes that the lines intersect
36 // * and that the intersection is not at an endpoint of either line.
37 // * @param p0 The first endpoint of the first line.
38 // * @param p1 The second endpoint of the first line.
39 // * @param p2 The first endpoint of the second line.
40 // * @param p3 The second endpoint of the second line.
41 // * @param inter The intersection point.
42 // */
43 // void _v2dIntersect(const Vec2d* p0, const Vec2d* p1, const Vec2d* p2,
44 // const Vec2d* p3, Vec2d* inter) {
45 // Vec2d s1, s2;
46 // s1.x = p1->x - p0->x;
47 // s1.y = p1->y - p0->y;
48 // s2.x = p3->x - p2->x;
49 // s2.y = p3->y - p2->y;
50 
51 // float t;
52 // t = (s2.x * (p0->y - p2->y) - s2.y * (p0->x - p2->x)) /
53 // (-s2.x * s1.y + s1.x * s2.y);
54 
55 // inter->x = p0->x + (t * s1.x);
56 // inter->y = p0->y + (t * s1.y);
57 // }
58 
59 // /**
60 // * Whether two 2D vectors are equal. Does not consider possible false
61 // * negatives due to floating-point errors.
62 // * @param v1 First vector to compare
63 // * @param v2 Second vector to compare
64 // * @return Whether the vectors are equal
65 // */
66 // bool _v2dEquals(const Vec2d* v1, const Vec2d* v2) {
67 // return v1->x == v2->x && v1->y == v2->y;
68 // }
2D floating point vector functions.
#define EXTENSION_INLINE
Definition: heavydbTypes.h:57
#define Vec2d(variable_name)
Definition: vec2d.h:28
#define X_INDEX
Definition: vec2d.h:26
#define Y_INDEX
Definition: vec2d.h:27
EXTENSION_INLINE double _v2dMag(const Vec2d(v))
Definition: vec2d.hpp:30