goat3d

diff libs/vmath/geom.h @ 27:4deb0b12fe14

wtf... corrupted heap?
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 29 Sep 2013 08:20:19 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/vmath/geom.h	Sun Sep 29 08:20:19 2013 +0300
     1.3 @@ -0,0 +1,72 @@
     1.4 +/*
     1.5 +libvmath - a vector math library
     1.6 +Copyright (C) 2004-2012 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 +#ifndef LIBVMATH_GEOM_H_
    1.22 +#define LIBVMATH_GEOM_H_
    1.23 +
    1.24 +#include "vector.h"
    1.25 +#include "ray.h"
    1.26 +
    1.27 +typedef struct {
    1.28 +	vec3_t norm;
    1.29 +	scalar_t d;
    1.30 +} plane_t;
    1.31 +
    1.32 +typedef struct {
    1.33 +	vec3_t pos;
    1.34 +	scalar_t rad;
    1.35 +} sphere_t;
    1.36 +
    1.37 +typedef struct {
    1.38 +	vec3_t min, max;
    1.39 +} aabox_t;
    1.40 +
    1.41 +#ifdef __cplusplus
    1.42 +extern "C" {
    1.43 +#endif
    1.44 +
    1.45 +/* planes are good... you need planes, yes you do */
    1.46 +plane_t plane_cons(scalar_t nx, scalar_t ny, scalar_t nz, scalar_t d);
    1.47 +plane_t plane_poly(vec3_t v0, vec3_t v1, vec3_t v2);
    1.48 +plane_t plane_ptnorm(vec3_t pt, vec3_t normal);
    1.49 +
    1.50 +plane_t plane_invert(plane_t p);
    1.51 +
    1.52 +scalar_t plane_signed_dist(plane_t plane, vec3_t pt);
    1.53 +scalar_t plane_dist(plane_t plane, vec3_t pt);
    1.54 +vec3_t plane_point(plane_t plane);
    1.55 +
    1.56 +int plane_ray_intersect(ray_t ray, plane_t plane, scalar_t *pos);
    1.57 +
    1.58 +/* spheres always come in handy */
    1.59 +sphere_t sphere_cons(scalar_t x, scalar_t y, scalar_t z, scalar_t rad);
    1.60 +
    1.61 +int sphere_ray_intersect(ray_t ray, sphere_t sph, scalar_t *pos);
    1.62 +int sphere_sphere_intersect(sphere_t sph1, sphere_t sph2, scalar_t *pos, scalar_t *rad);
    1.63 +
    1.64 +#ifdef __cplusplus
    1.65 +}
    1.66 +
    1.67 +/* TODO
    1.68 +class Plane : public plane_t {
    1.69 +public:
    1.70 +};
    1.71 +*/
    1.72 +
    1.73 +#endif
    1.74 +
    1.75 +#endif	/* LIBVMATH_GEOM_H_ */