dbf-halloween2015

view libs/vmath/geom.h @ 3:c37fe5d8a4ed

windows port
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 01 Nov 2015 06:04:28 +0200
parents
children
line source
1 /*
2 libvmath - a vector math library
3 Copyright (C) 2004-2012 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published
7 by the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef LIBVMATH_GEOM_H_
19 #define LIBVMATH_GEOM_H_
21 #include "vector.h"
22 #include "ray.h"
24 typedef struct {
25 vec3_t norm;
26 scalar_t d;
27 } plane_t;
29 typedef struct {
30 vec3_t pos;
31 scalar_t rad;
32 } sphere_t;
34 typedef struct {
35 vec3_t min, max;
36 } aabox_t;
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
42 /* planes are good... you need planes, yes you do */
43 plane_t plane_cons(scalar_t nx, scalar_t ny, scalar_t nz, scalar_t d);
44 plane_t plane_poly(vec3_t v0, vec3_t v1, vec3_t v2);
45 plane_t plane_ptnorm(vec3_t pt, vec3_t normal);
47 plane_t plane_invert(plane_t p);
49 scalar_t plane_signed_dist(plane_t plane, vec3_t pt);
50 scalar_t plane_dist(plane_t plane, vec3_t pt);
51 vec3_t plane_point(plane_t plane);
53 int plane_ray_intersect(ray_t ray, plane_t plane, scalar_t *pos);
55 /* spheres always come in handy */
56 sphere_t sphere_cons(scalar_t x, scalar_t y, scalar_t z, scalar_t rad);
58 int sphere_ray_intersect(ray_t ray, sphere_t sph, scalar_t *pos);
59 int sphere_sphere_intersect(sphere_t sph1, sphere_t sph2, scalar_t *pos, scalar_t *rad);
61 #ifdef __cplusplus
62 }
64 /* TODO
65 class Plane : public plane_t {
66 public:
67 };
68 */
70 #endif
72 #endif /* LIBVMATH_GEOM_H_ */