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

Linux Cross Reference
Tina4/src/geomstat/geom/gstat_geom.c

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

  1 /**@(#)
  2 **/
  3 #include <tina/sys.h>
  4 #include <tina/sysfuncs.h>
  5 #include <tina/math.h>
  6 #include <tina/mathfuncs.h>
  7 #include <tina/vision.h>
  8 #include <tina/visionfuncs.h>
  9 
 10 void   *scalar_basis();
 11 Basis2 *point2_basis();
 12 Basis2 *line2_basis();
 13 Basis3 *point3_basis();
 14 Basis3 *line3_basis();
 15 Basis3 *plane_basis();
 16 
 17 int     geom_df(int type)
 18 {
 19     switch (type)
 20     {
 21         case SCALAR:
 22         return (1);
 23     case POINT2:
 24         return (2);
 25     case LINE2:
 26         return (2);
 27     case POINT3:
 28         return (3);
 29     case LINE3:
 30         return (4);
 31     case PLANE:
 32         return (3);
 33     case TRANSF3:
 34         return (4);
 35     }
 36     return (0);
 37 }
 38 
 39 void   *geom_basis(void *geom, int type)
 40 {
 41     switch (type)
 42     {
 43         case SCALAR:
 44         return (NULL);
 45     case POINT2:
 46         return ((void *) point2_basis((Point2 *) geom));
 47     case LINE2:
 48         return ((void *) line2_basis((Line2 *) geom));
 49     case POINT3:
 50         return ((void *) point3_basis((Point3 *) geom));
 51     case LINE3:
 52         return ((void *) line3_basis((Line3 *) geom));
 53     case PLANE:
 54         return ((void *) plane_basis((Plane *) geom));
 55     case TRANSF3:
 56         return (NULL);
 57     }
 58     return (NULL);
 59 }
 60 
 61 void    geom_set_infcov(int type, Matrix * s, double lscale)
 62 {
 63     double  big = 1, lbig;
 64 
 65     lbig = big * lscale;
 66 
 67     switch (type)
 68     {
 69     case SCALAR:
 70         matrix_putf(big, s, 0, 0);
 71         break;
 72     case POINT2:
 73         matrix_putf(lbig, s, 0, 0);
 74         matrix_putf(lbig, s, 1, 1);
 75         break;
 76     case LINE2:
 77         matrix_putf(lbig, s, 0, 0);
 78         matrix_putf(big, s, 1, 1);
 79         break;
 80     case POINT3:
 81         matrix_putf(lbig, s, 0, 0);
 82         matrix_putf(lbig, s, 1, 1);
 83         matrix_putf(lbig, s, 2, 2);
 84         break;
 85     case LINE3:
 86         matrix_putf(lbig, s, 0, 0);
 87         matrix_putf(lbig, s, 1, 1);
 88         matrix_putf(big, s, 2, 2);
 89         matrix_putf(big, s, 3, 3);
 90         break;
 91     case PLANE:
 92         matrix_putf(lbig, s, 0, 0);
 93         matrix_putf(big, s, 1, 1);
 94         matrix_putf(big, s, 2, 2);
 95         break;
 96     case TRANSF3:
 97         matrix_putf(big, s, 0, 0);
 98         matrix_putf(big, s, 1, 1);
 99         matrix_putf(big, s, 2, 2);
100         matrix_putf(lbig, s, 0, 3);
101         matrix_putf(lbig, s, 1, 4);
102         matrix_putf(lbig, s, 2, 5);
103         break;
104     }
105 }
106 
107 void    geom_correct(void *geom, int type, void *basis, Vector * x)
108 {
109     if (x == NULL)
110         return;
111     switch (type)
112     {
113     case SCALAR:
114         scalar_correct((Scalar *) geom, NULL, x);
115         return;
116     case POINT2:
117         point2_correct((Point2 *) geom, (Basis2 *) basis, x);
118         return;
119     case LINE2:
120         line2_correct((Line2 *) geom, (Basis2 *) basis, x);
121         return;
122     case POINT3:
123         point3_correct((Point3 *) geom, (Basis3 *) basis, x);
124         return;
125     case LINE3:
126         line3_correct((Line3 *) geom, (Basis3 *) basis, x);
127         return;
128     case PLANE:
129         plane_correct((Plane *) geom, (Basis3 *) basis, x);
130         return;
131     case TRANSF3:
132         transf3_correct((Transf3 *) geom, (Basis3 *) NULL, x);
133         return;
134     }
135 }
136 
137 int     geom_rank(int type)
138 {
139     switch (type)
140     {
141         case SCALAR:
142         return (1);
143     case POINT2:
144         return (2);
145     case POINT3:
146         return (3);
147     case LINE2:
148         return (4);
149     case LINE3:
150         return (5);
151     case PLANE:
152         return (6);
153     case TRANSF3:
154         return (7);
155     default:
156         return (0);
157     }
158 }
159 
160 Bool    geom_reorder(int *index1, int *index2, int *type1, int *type2)
161 {
162     if (geom_rank(*type1) > geom_rank(*type2))
163     {
164         int     s;
165 
166         s = *index1;
167         *index1 = *index2;
168         *index2 = s;
169         s = *type1;
170         *type1 = *type2;
171         *type2 = s;
172         return (true);
173     }
174     return (false);
175 }
176 
177 double  geom_angle(void *geom1, int type1, void *geom2, int type2)
178 {
179     if (geom_rank(type1) > geom_rank(type2))
180     {
181         SWAP(void *, geom1, geom2);
182         SWAP(int, type1, type2);
183     }
184     switch (OPAIR(type1, type2))
185     {
186     case OPAIR(LINE3, LINE3):
187         {
188             Line3  *line1 = (Line3 *) geom1;
189             Line3  *line2 = (Line3 *) geom2;
190 
191             return (vec3_angle(line1->v, line2->v));
192         }
193     case OPAIR(LINE3, PLANE):
194         {
195             Line3  *line = (Line3 *) geom1;
196             Plane  *plane = (Plane *) geom2;
197 
198             return (vec3_angle(line->v, plane->n));
199         }
200     case OPAIR(PLANE, PLANE):
201         {
202             Plane  *plane1 = (Plane *) geom1;
203             Plane  *plane2 = (Plane *) geom2;
204 
205             return (vec3_angle(plane1->n, plane2->n));
206         }
207     default:
208         error("geom_angle: bad type", non_fatal);
209         return (1e10);
210     }
211 }
212 
213 double  geom_dist(void *geom1, int type1, void *geom2, int type2)
214 {
215     if (geom_rank(type1) > geom_rank(type2))
216     {
217         SWAP(void *, geom1, geom2);
218         SWAP(int, type1, type2);
219     }
220     switch (OPAIR(type1, type2))
221     {
222     case OPAIR(POINT3, POINT3):
223         {
224             Point3 *point1 = (Point3 *) geom1;
225             Point3 *point2 = (Point3 *) geom2;
226 
227             return (vec3_dist(point1->p, point2->p));
228         }
229     case OPAIR(POINT3, LINE3):
230         {
231             Point3 *point = (Point3 *) geom1;
232             Line3  *line = (Line3 *) geom2;
233 
234             return (vec3_dist_point_line(point->p, line->p, line->v));
235         }
236     case OPAIR(POINT3, PLANE):
237         {
238             Point3 *point = (Point3 *) geom1;
239             Plane  *plane = (Plane *) geom2;
240 
241             return (vec3_dist_point_plane(point->p, plane->p, plane->n));
242         }
243     case OPAIR(LINE3, LINE3):
244         {
245             Line3  *line1 = (Line3 *) geom1;
246             Line3  *line2 = (Line3 *) geom2;
247 
248             return (vec3_dist_lines(line1->p, line1->v, line2->p, line2->v));
249         }
250     default:
251         error("geom_angle: bad type", non_fatal);
252         return (1e10);
253     }
254 }
255 

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