1 /*
2  * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT,
3  * Applied Mathematics, Norway.
4  *
5  * Contact information: E-mail: tor.dokken@sintef.no
6  * SINTEF ICT, Department of Applied Mathematics,
7  * P.O. Box 124 Blindern,
8  * 0314 Oslo, Norway.
9  *
10  * This file is part of SISL.
11  *
12  * SISL is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Affero General Public License as
14  * published by the Free Software Foundation, either version 3 of the
15  * License, or (at your option) any later version.
16  *
17  * SISL is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU Affero General Public License for more details.
21  *
22  * You should have received a copy of the GNU Affero General Public
23  * License along with SISL. If not, see
24  * <http://www.gnu.org/licenses/>.
25  *
26  * In accordance with Section 7(b) of the GNU Affero General Public
27  * License, a covered work must retain the producer line in every data
28  * file that is created or manipulated using SISL.
29  *
30  * Other Usage
31  * You can be released from the requirements of the license by purchasing
32  * a commercial license. Buying such a license is mandatory as soon as you
33  * develop commercial activities involving the SISL library without
34  * disclosing the source code of your own applications.
35  *
36  * This file may be used in accordance with the terms contained in a
37  * written agreement between you and SINTEF ICT.
38  */
39 
40 #include "sisl-copyright.h"
41 
42 /*
43  *
44  * $Id: s1324.c,v 1.1 1994-04-21 12:10:42 boh Exp $
45  *
46  */
47 
48 
49 #define S1324
50 
51 #include "sislP.h"
52 
53 #if defined(SISLNEEDPROTOTYPES)
54 void
s1324(double ecentr[],double aradiu,double enorm[],int idim,double carray[],int * jstat)55 s1324(double ecentr[],double aradiu,double enorm[],int idim,
56 	   double carray[],int *jstat)
57 #else
58 void s1324(ecentr,aradiu,enorm,idim,carray,jstat)
59      double ecentr[];
60      double aradiu;
61      double enorm[];
62      int    idim;
63      double carray[];
64      int    *jstat;
65 #endif
66 /*
67 *********************************************************************
68 *
69 * PURPOSE    : To make two matrix of dimension 4x4
70 *              describing a 3-D circle as two implicit functions.
71 *
72 *
73 * INPUT      : ecentr - Center of the circle
74 *              aradiu - Radius of the circle
75 *              enorm  - Normal vector of circle plane
76 *              idim   - The dimension of the space the cirle lies in
77 *
78 *
79 *
80 * OUTPUT     : carray - The description of the circle. Outside
81 *                       this function the space for this array must be
82 *                       allocated. The need is 32 double variables.
83 *                       First the matrix for the sphere is stored,
84 *                       then the matrix of the plane.
85 *              jstat  - status messages
86 *                                         > 0      : warning
87 *                                         = 0      : ok
88 *                                         < 0      : error
89 *
90 *
91 * METHOD     : The circle is described as an intersection between a
92 *              cylinder and the plane. The matrix describing the
93 *              cylinder is put first in the output array, the matrix
94 *              describing the plane follows then.
95 *
96 *
97 * REFERENCES :
98 *
99 *-
100 * CALLS      :
101 *
102 * WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 29-June-1988
103 *
104 *********************************************************************
105 */
106 {
107   int kdimp1;         /* Dimension of matrix kdimp1 = idim + 1         */
108   int kdimp2;         /* idim + 2                                      */
109   int kstop;          /* Stop condition for for loop                   */
110   int ki;             /* Running variables in loop                     */
111   int kpos=0;         /* Position of error                             */
112   int kstat;          /* Status variable                               */
113 
114 
115 
116   /* Test i legal input */
117   if (idim != 3) goto err104;
118 
119   kdimp1 = idim + 1;
120   kdimp2 = idim + 2;
121   kstop  = 2*kdimp1*kdimp1;
122 
123   for (ki=0;ki<kstop;ki++)
124     {
125       carray[ki] = (double)0.0;
126     }
127 
128   /* Make description of cylinder */
129 
130   s1322(ecentr,enorm,aradiu,idim,1,carray,&kstat);
131   if (kstat<0) goto error;
132 
133 
134   /* Make description of plane, element (1,4), (2,4) and (3,4) */
135 
136   carray[28] = enorm[0];
137   carray[29] = enorm[1];
138   carray[30] = enorm[2];
139 
140   /* Make element (4,4) */
141 
142   carray[31] = -s6scpr(enorm,ecentr,idim);
143 
144   *jstat = 0;
145   goto out;
146 
147   /* Dimension not 3 */
148  err104: *jstat = -104;
149   s6err("s1324",*jstat,kpos);
150   goto out;
151 
152   /* Error in lower level routine */
153  error: *jstat = kstat;
154   goto out;
155 
156 
157  out:
158   return;
159 }
160