istereo
view libs/vmath/geom.h @ 28:c0ae8e668447
added vmath library
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Thu, 08 Sep 2011 08:30:42 +0300 |
parents | |
children | ff055bff6a15 |
line source
1 #ifndef GEOM_H_
2 #define GEOM_H_
4 #include "vector.h"
5 #include "ray.h"
7 typedef struct {
8 vec3_t norm;
9 scalar_t d;
10 } plane_t;
12 typedef struct {
13 vec3_t pos;
14 scalar_t rad;
15 } sphere_t;
17 typedef struct {
18 vec3_t min, max;
19 } aabox_t;
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
25 /* planes are good... you need planes, yes you do */
26 plane_t plane_cons(scalar_t nx, scalar_t ny, scalar_t nz, scalar_t d);
27 plane_t plane_poly(vec3_t v0, vec3_t v1, vec3_t v2);
28 plane_t plane_ptnorm(vec3_t pt, vec3_t normal);
30 plane_t plane_invert(plane_t p);
32 scalar_t plane_signed_dist(plane_t plane, vec3_t pt);
33 scalar_t plane_dist(plane_t plane, vec3_t pt);
34 vec3_t plane_point(plane_t plane);
36 int plane_ray_intersect(ray_t ray, plane_t plane, scalar_t *pos);
38 /* spheres always come in handy */
39 sphere_t sphere_cons(scalar_t x, scalar_t y, scalar_t z, scalar_t rad);
41 int sphere_ray_intersect(ray_t ray, sphere_t sph, scalar_t *pos);
42 int sphere_sphere_intersect(sphere_t sph1, sphere_t sph2, scalar_t *pos, scalar_t *rad);
44 #ifdef __cplusplus
45 }
47 /* TODO
48 class Plane : public plane_t {
49 public:
50 };
51 */
53 #endif
55 #endif /* GEOM_H_ */