istereo2

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/vmath/geom.h	Sat Sep 19 05:51:51 2015 +0300
     1.3 @@ -0,0 +1,73 @@
     1.4 +/*
     1.5 +libvmath - a vector math library
     1.6 +Copyright (C) 2004-2011 John Tsiombikas <nuclear@member.fsf.org>
     1.7 +
     1.8 +This program is free software: you can redistribute it and/or modify
     1.9 +it under the terms of the GNU Lesser General Public License as published
    1.10 +by the Free Software Foundation, either version 3 of the License, or
    1.11 +(at your option) any later version.
    1.12 +
    1.13 +This program is distributed in the hope that it will be useful,
    1.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.16 +GNU Lesser General Public License for more details.
    1.17 +
    1.18 +You should have received a copy of the GNU Lesser General Public License
    1.19 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.20 +*/
    1.21 +
    1.22 +#ifndef GEOM_H_
    1.23 +#define GEOM_H_
    1.24 +
    1.25 +#include "vector.h"
    1.26 +#include "ray.h"
    1.27 +
    1.28 +typedef struct {
    1.29 +	vec3_t norm;
    1.30 +	scalar_t d;
    1.31 +} plane_t;
    1.32 +
    1.33 +typedef struct {
    1.34 +	vec3_t pos;
    1.35 +	scalar_t rad;
    1.36 +} sphere_t;
    1.37 +
    1.38 +typedef struct {
    1.39 +	vec3_t min, max;
    1.40 +} aabox_t;
    1.41 +
    1.42 +#ifdef __cplusplus
    1.43 +extern "C" {
    1.44 +#endif
    1.45 +
    1.46 +/* planes are good... you need planes, yes you do */
    1.47 +plane_t plane_cons(scalar_t nx, scalar_t ny, scalar_t nz, scalar_t d);
    1.48 +plane_t plane_poly(vec3_t v0, vec3_t v1, vec3_t v2);
    1.49 +plane_t plane_ptnorm(vec3_t pt, vec3_t normal);
    1.50 +
    1.51 +plane_t plane_invert(plane_t p);
    1.52 +
    1.53 +scalar_t plane_signed_dist(plane_t plane, vec3_t pt);
    1.54 +scalar_t plane_dist(plane_t plane, vec3_t pt);
    1.55 +vec3_t plane_point(plane_t plane);
    1.56 +
    1.57 +int plane_ray_intersect(ray_t ray, plane_t plane, scalar_t *pos);
    1.58 +
    1.59 +/* spheres always come in handy */
    1.60 +sphere_t sphere_cons(scalar_t x, scalar_t y, scalar_t z, scalar_t rad);
    1.61 +
    1.62 +int sphere_ray_intersect(ray_t ray, sphere_t sph, scalar_t *pos);
    1.63 +int sphere_sphere_intersect(sphere_t sph1, sphere_t sph2, scalar_t *pos, scalar_t *rad);
    1.64 +
    1.65 +#ifdef __cplusplus
    1.66 +}
    1.67 +
    1.68 +/* TODO
    1.69 +class Plane : public plane_t {
    1.70 +public:
    1.71 +};
    1.72 +*/
    1.73 +
    1.74 +#endif
    1.75 +
    1.76 +#endif	/* GEOM_H_ */