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

Linux Cross Reference
Tina6/tina-libs/tina/geometry/geomPlane_gen.c

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

  1 /**********
  2  * 
  3  * This file is part of the TINA Open Source Image Analysis Environment
  4  * henceforth known as TINA
  5  *
  6  * TINA is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU General Public License as 
  8  * published by the Free Software Foundation.
  9  *
 10  * TINA 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 General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU General Public License
 16  * along with TINA; if not, write to the Free Software Foundation, Inc., 
 17  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  *
 19  * ANY users of TINA who require exemption from the existing licence must
 20  * negotiate a new licence with Dr. Neil.A.Thacker, the sole agent for
 21  * the University of Manchester.
 22  *
 23  **********
 24  * 
 25  * Program :    TINA
 26  * File    :  $Source: /home/tina/cvs/tina-libs/tina/geometry/geomPlane_gen.c,v $
 27  * Date    :  $Date: 2005/01/09 17:49:25 $
 28  * Version :  $Revision: 1.2 $
 29  * CVS Id  :  $Id: geomPlane_gen.c,v 1.2 2005/01/09 17:49:25 paul Exp $
 30  *
 31  * Notes : functions for manipulating 3D planes
 32  *
 33  *********
 34 */
 35 
 36 
 37 #include "geomPlane_gen.h"
 38 
 39 #if HAVE_CONFIG_H
 40   #include <config.h>
 41 #endif
 42 
 43 #include <string.h>
 44 #include <stdio.h>
 45 #include <math.h>
 46 #include <stdlib.h>
 47 #include <tina/sys/sysDef.h>
 48 #include <tina/sys/sysPro.h>
 49 #include <tina/math/mathDef.h>
 50 #include <tina/math/mathPro.h>
 51 #include <tina/geometry/geom_PlaneDef.h>
 52 #ifdef _PCC
 53 #include <memory.h>
 54 #endif
 55 
 56 Plane  *plane_alloc(unsigned int type)
 57 {
 58     Plane  *plane = ts_ralloc(Plane);
 59 
 60     plane->type = type;
 61     plane->label = new_label();
 62     plane->p = vec3_zero();
 63     plane->n = vec3_ez();
 64     plane->props = NULL;
 65     return (plane);
 66 }
 67 
 68 Plane  *plane_make(Vec3 p, Vec3 n, int type)
 69 {
 70     Plane  *plane = ts_ralloc(Plane);
 71 
 72     plane->type = type;
 73     plane->label = new_label();
 74     plane->p = p;
 75     plane->n = vec3_unit(n);
 76     plane->props = NULL;
 77     return (plane);
 78 }
 79 
 80 void    plane_free(Plane * plane)
 81 {
 82     if (plane == NULL)
 83         return;
 84     proplist_freelist(plane->props);
 85     rfree((void *) plane);
 86 }
 87 
 88 Plane  *plane_copy(Plane * plane)
 89 {
 90     Plane  *copy;
 91     List   *proplist_copy();
 92 
 93     if (plane == NULL)
 94         return (NULL);
 95 
 96     copy = ts_ralloc(Plane);
 97     (void) memcpy((char *) copy, (char *) plane, sizeof(Plane));
 98     copy->props = proplist_copy(plane->props);
 99     return (copy);
100 }
101 
102 int     plane_number(List * planes)
103 {
104     List   *lptr;
105     int     n = 0;
106 
107     for (lptr = planes; lptr != NULL; lptr = lptr->next)
108         ((Plane *) (lptr->to))->label = n++;
109     return(n);
110 }
111 
112 Bool    plane_point_on_plane(Plane * plane, Vec3 p, double thres)
113 {
114     Vec3    dp = {Vec3_id};
115     double  dn;
116 
117     dp = vec3_diff(p, plane->p);
118     dn = vec3_dot(dp, plane->n);
119     return ((fabs(dn) < thres) ? true : false);
120 }
121 

~ [ 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.