~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/vision/plane/plane.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2 **/
  3 /* plane.c functions for manipulating 3D planes
  4  * 
  5  * typedef struct plane { int type; struct vec3 p; struct vec3 n; struct
  6  * list *props; } Plane;
  7  * 
  8  */
  9 
 10 #include <math.h>
 11 #include <tina/sys.h>
 12 #include <tina/sysfuncs.h>
 13 #include <tina/math.h>
 14 #include <tina/mathfuncs.h>
 15 #include <tina/vision.h>
 16 #include <tina/visionfuncs.h>
 17 #ifdef _PCC
 18 #include <memory.h>
 19 #endif
 20 
 21 Plane  *plane_alloc(unsigned int type)
 22 {
 23     Plane  *plane = ts_ralloc(Plane);
 24 
 25     plane->type = type;
 26     plane->label = new_label();
 27     plane->p = vec3_zero();
 28     plane->n = vec3_ez();
 29     plane->props = NULL;
 30     return (plane);
 31 }
 32 
 33 Plane  *plane_make(Vec3 p, Vec3 n, int type)
 34 {
 35     Plane  *plane = ts_ralloc(Plane);
 36 
 37     plane->type = type;
 38     plane->label = new_label();
 39     plane->p = p;
 40     plane->n = vec3_unit(n);
 41     plane->props = NULL;
 42     return (plane);
 43 }
 44 
 45 void    plane_free(Plane * plane)
 46 {
 47     if (plane == NULL)
 48         return;
 49     proplist_freelist(plane->props);
 50     rfree((void *) plane);
 51 }
 52 
 53 Plane  *plane_copy(Plane * plane)
 54 {
 55     Plane  *copy;
 56     List   *proplist_copy();
 57 
 58     if (plane == NULL)
 59         return (NULL);
 60 
 61     copy = ts_ralloc(Plane);
 62     (void) memcpy((char *) copy, (char *) plane, sizeof(Plane));
 63     copy->props = proplist_copy(plane->props);
 64     return (copy);
 65 }
 66 
 67 int     plane_number(List * planes)
 68 {
 69     List   *lptr;
 70     int     n = 0;
 71 
 72     for (lptr = planes; lptr != NULL; lptr = lptr->next)
 73         ((Plane *) (lptr->to))->label = n++;
 74     return(n);
 75 }
 76 
 77 Bool    plane_point_on_plane(Plane * plane, Vec3 p, double thres)
 78 {
 79     Vec3    dp = {Vec3_id};
 80     double  dn;
 81 
 82     dp = vec3_diff(p, plane->p);
 83     dn = vec3_dot(dp, plane->n);
 84     return ((fabs(dn) < thres) ? true : false);
 85 }
 86 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.