1 /* nvc2pl.f -- translated by f2c (version 19980913).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include "f2c.h"
7
8 /* $Procedure NVC2PL ( Normal vector and constant to plane ) */
nvc2pl_(doublereal * normal,doublereal * const__,doublereal * plane)9 /* Subroutine */ int nvc2pl_(doublereal *normal, doublereal *const__,
10 doublereal *plane)
11 {
12 extern /* Subroutine */ int vequ_(doublereal *, doublereal *), chkin_(
13 char *, ftnlen), unorm_(doublereal *, doublereal *, doublereal *),
14 sigerr_(char *, ftnlen), chkout_(char *, ftnlen);
15 doublereal tmpvec[3];
16 extern /* Subroutine */ int setmsg_(char *, ftnlen);
17 extern logical return_(void);
18 extern /* Subroutine */ int vminus_(doublereal *, doublereal *);
19 doublereal mag;
20
21 /* $ Abstract */
22
23 /* Make a SPICELIB plane from a normal vector and a constant. */
24
25 /* $ Disclaimer */
26
27 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
28 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
29 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
30 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
31 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
32 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
33 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
34 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
35 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
36 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
37
38 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
39 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
40 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
41 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
42 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
43 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
44
45 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
46 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
47 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
48 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
49
50 /* $ Required_Reading */
51
52 /* PLANES */
53
54 /* $ Keywords */
55
56 /* GEOMETRY */
57 /* MATH */
58 /* PLANE */
59
60 /* $ Declarations */
61 /* $ Brief_I/O */
62
63 /* Variable I/O Description */
64 /* -------- --- -------------------------------------------------- */
65 /* NORMAL, */
66 /* CONST I A normal vector and constant defining a plane. */
67 /* PLANE O An array representing the plane. */
68
69 /* $ Detailed_Input */
70
71 /* NORMAL, */
72 /* CONST are, respectively, a normal vector and constant */
73 /* defining a plane. NORMAL need not be a unit */
74 /* vector. Let the symbol < a, b > indicate the inner */
75 /* product of vectors a and b; then the geometric */
76 /* plane is the set of vectors X in three-dimensional */
77 /* space that satisfy */
78
79 /* < X, NORMAL > = CONST. */
80
81 /* $ Detailed_Output */
82
83 /* PLANE is a SPICELIB plane that represents the geometric */
84 /* plane defined by NORMAL and CONST. */
85
86 /* $ Parameters */
87
88 /* None. */
89
90 /* $ Exceptions */
91
92 /* 1) If the input vector NORMAL is the zero vector, the error */
93 /* SPICE(ZEROVECTOR) is signalled. */
94
95 /* $ Files */
96
97 /* None. */
98
99 /* $ Particulars */
100
101 /* SPICELIB geometry routines that deal with planes use the `plane' */
102 /* data type to represent input and output planes. This data type */
103 /* makes the subroutine interfaces simpler and more uniform. */
104
105 /* The SPICELIB routines that produce SPICELIB planes from data that */
106 /* define a plane are: */
107
108 /* NVC2PL ( Normal vector and constant to plane ) */
109 /* NVP2PL ( Normal vector and point to plane ) */
110 /* PSV2PL ( Point and spanning vectors to plane ) */
111
112 /* The SPICELIB routines that convert SPICELIB planes to data that */
113 /* define a plane are: */
114
115 /* PL2NVC ( Plane to normal vector and constant ) */
116 /* PL2NVP ( Plane to normal vector and point ) */
117 /* PL2PSV ( Plane to point and spanning vectors ) */
118
119 /* Any of these last three routines may be used to convert this */
120 /* routine's output, PLANE, to another representation of a */
121 /* geometric plane. */
122
123 /* $ Examples */
124
125 /* 1) Apply a linear transformation represented by the matrix M to */
126 /* a plane represented by the normal vector N and the constant C. */
127 /* Find a normal vector and constant for the transformed plane. */
128
129 /* C */
130 /* C Make a SPICELIB plane from N and C, and then find a */
131 /* C point in the plane and spanning vectors for the */
132 /* C plane. N need not be a unit vector. */
133 /* C */
134 /* CALL NVC2PL ( N, C, PLANE ) */
135 /* CALL PL2PSV ( PLANE, POINT, SPAN1, SPAN2 ) */
136
137 /* C */
138 /* C Apply the linear transformation to the point and */
139 /* C spanning vectors. All we need to do is multiply */
140 /* C these vectors by M, since for any linear */
141 /* C transformation T, */
142 /* C */
143 /* C T ( POINT + t1 * SPAN1 + t2 * SPAN2 ) */
144 /* C */
145 /* C = T (POINT) + t1 * T(SPAN1) + t2 * T(SPAN2), */
146 /* C */
147 /* C which means that T(POINT), T(SPAN1), and T(SPAN2) */
148 /* C are a point and spanning vectors for the transformed */
149 /* C plane. */
150 /* C */
151 /* CALL MXV ( M, POINT, TPOINT ) */
152 /* CALL MXV ( M, SPAN1, TSPAN1 ) */
153 /* CALL MXV ( M, SPAN2, TSPAN2 ) */
154
155 /* C */
156 /* C Make a new SPICELIB plane TPLANE from the */
157 /* C transformed point and spanning vectors, and find a */
158 /* C unit normal and constant for this new plane. */
159 /* C */
160 /* CALL PSV2PL ( TPOINT, TSPAN1, TSPAN2, TPLANE ) */
161 /* CALL PL2NVC ( TPLANE, TN, TC ) */
162
163 /* $ Restrictions */
164
165 /* No checking is done to prevent arithmetic overflow. */
166
167 /* $ Literature_References */
168
169 /* [1] `Calculus and Analytic Geometry', Thomas and Finney. */
170
171 /* $ Author_and_Institution */
172
173 /* N.J. Bachman (JPL) */
174
175 /* $ Version */
176
177 /* - SPICELIB Version 1.1.1, 02-NOV-2009 (NJB) */
178
179 /* Corrected header typo. */
180
181 /* - SPICELIB Version 1.1.0, 30-AUG-2005 (NJB) */
182
183 /* Updated to remove non-standard use of duplicate arguments */
184 /* in VMINUS call. */
185
186 /* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
187
188 /* Comment section for permuted index source lines was added */
189 /* following the header. */
190
191 /* - SPICELIB Version 1.0.0, 01-NOV-1990 (NJB) */
192
193 /* -& */
194 /* $ Index_Entries */
195
196 /* normal vector and constant to plane */
197
198 /* -& */
199 /* $ Revisions */
200
201 /* - SPICELIB Version 1.1.0, 30-AUG-2005 (NJB) */
202
203 /* Updated to remove non-standard use of duplicate arguments */
204 /* in VMINUS call. */
205
206 /* -& */
207
208 /* SPICELIB functions */
209
210
211 /* Local parameters */
212
213
214 /* The contents of SPICELIB planes are as follows: */
215
216 /* Elements NMLPOS through NMLPOS + 2 contain a unit normal */
217 /* vector for the plane. */
218
219 /* Element CONPOS contains a constant for the plane; every point */
220 /* X in the plane satisifies */
221
222 /* < X, PLANE(NMLPOS) > = PLANE(CONPOS). */
223
224 /* The plane constant is the distance of the plane from the */
225 /* origin; the normal vector, scaled by the constant, is the */
226 /* closest point in the plane to the origin. */
227
228
229
230 /* Local variables */
231
232
233 /* This routine checks in only if an error is discovered. */
234
235 if (return_()) {
236 return 0;
237 }
238 unorm_(normal, plane, &mag);
239
240 /* The normal vector must be non-zero. */
241
242 if (mag == 0.) {
243 chkin_("NVC2PL", (ftnlen)6);
244 setmsg_("Plane's normal must be non-zero.", (ftnlen)32);
245 sigerr_("SPICE(ZEROVECTOR)", (ftnlen)17);
246 chkout_("NVC2PL", (ftnlen)6);
247 return 0;
248 }
249
250 /* To find the plane constant corresponding to the unitized normal */
251 /* vector, we observe that */
252
253 /* < X, NORMAL > = CONST, */
254
255 /* so */
256
257 /* < X, NORMAL / || NORMAL || > = CONST / || NORMAL || */
258
259
260 plane[3] = *const__ / mag;
261
262 /* The constant should be the distance of the plane from the */
263 /* origin. If the constant is negative, negate both it and the */
264 /* normal vector. */
265
266 if (plane[3] < 0.) {
267 plane[3] = -plane[3];
268 vminus_(plane, tmpvec);
269 vequ_(tmpvec, plane);
270 }
271 return 0;
272 } /* nvc2pl_ */
273
274