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/geomCurve_cone.c,v $
27 * Date : $Date: 2005/01/09 17:49:25 $
28 * Version : $Revision: 1.2 $
29 * CVS Id : $Id: geomCurve_cone.c,v 1.2 2005/01/09 17:49:25 paul Exp $
30 *
31 * Author : Legacy TINA
32 *
33 * Notes : functions for manipulating generic cones
34 *
35 *********
36 */
37
38 #include "geomCurve_cone.h"
39
40 #if HAVE_CONFIG_H
41 #include <config.h>
42 #endif
43
44 #include <math.h>
45 #include <string.h>
46 #include <tina/sys/sysDef.h>
47 #include <tina/sys/sysPro.h>
48 #include <tina/math/mathDef.h>
49 #include <tina/math/mathPro.h>
50 #include <tina/geometry/geom_CurveDef.h>
51 #include <tina/geometry/geomCurve_conic3.h>
52 #ifdef _PCC
53 #include <memory.h>
54 #endif
55
56 Cone *cone_alloc(int type)
57 {
58 Cone *cone = ts_ralloc(Cone);
59
60 cone->type = type;
61 cone->label = new_label();
62 cone->c1 = cone->c2 = NULL;
63 cone->offset = 0;
64 cone->props = NULL;
65 return (cone);
66 }
67
68 Cone *cone_make(Conic3 * c1, Conic3 * c2, double offset, int type)
69 {
70 Cone *cone = ts_ralloc(Cone);
71
72 cone->type = type;
73 cone->label = new_label();
74 cone->c1 = c1;
75 cone->c2 = c2;
76 cone->offset = offset;
77 cone->props = NULL;
78 return (cone);
79 }
80
81 void cone_free(Cone * cone)
82 {
83 if (cone == NULL)
84 return;
85 proplist_freelist(cone->props);
86 conic3_free(cone->c1);
87 conic3_free(cone->c2);
88 rfree((void *) cone);
89 }
90
91 Cone *cone_copy(Cone * cone)
92 {
93 Cone *copy;
94 List *proplist_copy();
95
96 if (cone == NULL)
97 return (NULL);
98
99 copy = ts_ralloc(Cone);
100 (void) memcpy((char *) copy, (char *) cone, sizeof(Cone));
101 copy->c1 = conic3_copy(cone->c1);
102 copy->c2 = conic3_copy(cone->c2);
103 copy->props = proplist_copy(cone->props);
104 return (copy);
105 }
106
107 Vec3 cone_point(Cone * cone, double u, double t)
108
109 /* cone parameters */
110 {
111 Vec3 p1 = {Vec3_id};
112 Vec3 p2 = {Vec3_id};
113
114 p1 = conic3_point(cone->c1, t);
115 p2 = conic3_point(cone->c2, t + cone->offset);
116
117 return (vec3_sum(vec3_times(1 - u, p1), vec3_times(u, p2)));
118 }
119
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.