istereo2

view libs/vmath/geom.h @ 2:81d35769f546

added the tunnel effect source
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 19 Sep 2015 05:51:51 +0300
parents
children
line source
1 /*
2 libvmath - a vector math library
3 Copyright (C) 2004-2011 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 */
19 #ifndef GEOM_H_
20 #define GEOM_H_
22 #include "vector.h"
23 #include "ray.h"
25 typedef struct {
26 vec3_t norm;
27 scalar_t d;
28 } plane_t;
30 typedef struct {
31 vec3_t pos;
32 scalar_t rad;
33 } sphere_t;
35 typedef struct {
36 vec3_t min, max;
37 } aabox_t;
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
43 /* planes are good... you need planes, yes you do */
44 plane_t plane_cons(scalar_t nx, scalar_t ny, scalar_t nz, scalar_t d);
45 plane_t plane_poly(vec3_t v0, vec3_t v1, vec3_t v2);
46 plane_t plane_ptnorm(vec3_t pt, vec3_t normal);
48 plane_t plane_invert(plane_t p);
50 scalar_t plane_signed_dist(plane_t plane, vec3_t pt);
51 scalar_t plane_dist(plane_t plane, vec3_t pt);
52 vec3_t plane_point(plane_t plane);
54 int plane_ray_intersect(ray_t ray, plane_t plane, scalar_t *pos);
56 /* spheres always come in handy */
57 sphere_t sphere_cons(scalar_t x, scalar_t y, scalar_t z, scalar_t rad);
59 int sphere_ray_intersect(ray_t ray, sphere_t sph, scalar_t *pos);
60 int sphere_sphere_intersect(sphere_t sph1, sphere_t sph2, scalar_t *pos, scalar_t *rad);
62 #ifdef __cplusplus
63 }
65 /* TODO
66 class Plane : public plane_t {
67 public:
68 };
69 */
71 #endif
73 #endif /* GEOM_H_ */