/usr/include/obs/graphics/vec2.h is in libobs-dev 21.0.2+dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | /******************************************************************************
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#pragma once
#include "../util/c99defs.h"
#include <math.h>
#ifdef __cplusplus
extern "C" {
#endif
struct vec2 {
union {
struct {
float x, y;
};
float ptr[2];
};
};
static inline void vec2_zero(struct vec2 *dst)
{
dst->x = 0.0f;
dst->y = 0.0f;
}
static inline void vec2_set(struct vec2 *dst, float x, float y)
{
dst->x = x;
dst->y = y;
}
static inline void vec2_copy(struct vec2 *dst, const struct vec2 *v)
{
dst->x = v->x;
dst->y = v->y;
}
static inline void vec2_add(struct vec2 *dst, const struct vec2 *v1,
const struct vec2 *v2)
{
vec2_set(dst, v1->x+v2->x, v1->y+v2->y);
}
static inline void vec2_sub(struct vec2 *dst, const struct vec2 *v1,
const struct vec2 *v2)
{
vec2_set(dst, v1->x-v2->x, v1->y-v2->y);
}
static inline void vec2_mul(struct vec2 *dst, const struct vec2 *v1,
const struct vec2 *v2)
{
vec2_set(dst, v1->x*v2->x, v1->y*v2->y);
}
static inline void vec2_div(struct vec2 *dst, const struct vec2 *v1,
const struct vec2 *v2)
{
vec2_set(dst, v1->x/v2->x, v1->y/v2->y);
}
static inline void vec2_addf(struct vec2 *dst, const struct vec2 *v,
float f)
{
vec2_set(dst, v->x+f, v->y+f);
}
static inline void vec2_subf(struct vec2 *dst, const struct vec2 *v,
float f)
{
vec2_set(dst, v->x-f, v->y-f);
}
static inline void vec2_mulf(struct vec2 *dst, const struct vec2 *v,
float f)
{
vec2_set(dst, v->x*f, v->y*f);
}
static inline void vec2_divf(struct vec2 *dst, const struct vec2 *v,
float f)
{
vec2_set(dst, v->x/f, v->y/f);
}
static inline void vec2_neg(struct vec2 *dst, const struct vec2 *v)
{
vec2_set(dst, -v->x, -v->y);
}
static inline float vec2_dot(const struct vec2 *v1, const struct vec2 *v2)
{
return v1->x*v2->x + v1->y*v2->y;
}
static inline float vec2_len(const struct vec2 *v)
{
return sqrtf(v->x*v->x + v->y*v->y);
}
static inline float vec2_dist(const struct vec2 *v1, const struct vec2 *v2)
{
struct vec2 temp;
vec2_sub(&temp, v1, v2);
return vec2_len(&temp);
}
static inline void vec2_minf(struct vec2 *dst, const struct vec2 *v,
float val)
{
if (v->x < val)
dst->x = val;
if (v->y < val)
dst->y = val;
}
static inline void vec2_min(struct vec2 *dst, const struct vec2 *v,
const struct vec2 *min_v)
{
if (v->x < min_v->x)
dst->x = min_v->x;
if (v->y < min_v->y)
dst->y = min_v->y;
}
static inline void vec2_maxf(struct vec2 *dst, const struct vec2 *v,
float val)
{
if (v->x > val)
dst->x = val;
if (v->y > val)
dst->y = val;
}
static inline void vec2_max(struct vec2 *dst, const struct vec2 *v,
const struct vec2 *max_v)
{
if (v->x > max_v->x)
dst->x = max_v->x;
if (v->y > max_v->y)
dst->y = max_v->y;
}
EXPORT void vec2_abs(struct vec2 *dst, const struct vec2 *v);
EXPORT void vec2_floor(struct vec2 *dst, const struct vec2 *v);
EXPORT void vec2_ceil(struct vec2 *dst, const struct vec2 *v);
EXPORT int vec2_close(const struct vec2 *v1, const struct vec2 *v2,
float epsilon);
EXPORT void vec2_norm(struct vec2 *dst, const struct vec2 *v);
#ifdef __cplusplus
}
#endif
|