1 /* zzvox2id.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 ZZVOX2ID ( Return voxel index from coords ) */
zzvox2id_(integer * vixyz,integer * nvox)9 integer zzvox2id_(integer *vixyz, integer *nvox)
10 {
11     /* System generated locals */
12     integer ret_val;
13 
14 /* $ Abstract */
15 
16 /*     SPICE Private routine intended solely for the support of SPICE */
17 /*     routines. Users should not call this routine directly due */
18 /*     to the volatile nature of this routine. */
19 
20 /*     Given a voxel's grid coordinates and the voxel grid */
21 /*     dimensions, return the voxel's 1-dimensional index. */
22 
23 /* $ Disclaimer */
24 
25 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
26 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
27 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
28 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
29 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
30 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
31 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
32 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
33 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
34 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
35 
36 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
37 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
38 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
39 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
40 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
41 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
42 
43 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
44 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
45 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
46 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
47 
48 /* $ Required_Reading */
49 
50 /*     None. */
51 
52 /* $ Keywords */
53 
54 /*     COORDINATE */
55 /*     DSK */
56 /*     INDEX */
57 /*     VOXEL */
58 
59 /* $ Declarations */
60 /* $ Brief_I/O */
61 
62 /*     VARIABLE  I/O  DESCRIPTION */
63 /*     --------  ---  -------------------------------------------------- */
64 /*     VIXYZ      I   Voxel's grid coordinates stored in a */
65 /*                    three-dimensional vector. */
66 /*     NVOX       I   Number of voxels in each coordinate direction. */
67 
68 /*     The function returns the voxel index. */
69 
70 /* $ Detailed_Input */
71 
72 /*     VIXYZ      An integer 3-vector storing the voxel grid coordinates */
73 /*                for the point of interest. */
74 
75 /*     NVOX       An array of three positive integers defining a voxel */
76 /*                grid's extents in the X, Y, and Z directions. */
77 
78 /* $ Detailed_Output */
79 
80 /*     The function returns the value of the voxel index. */
81 
82 /* $ Parameters */
83 
84 /*     None. */
85 
86 /* $ Exceptions */
87 
88 /*     Error free. */
89 
90 /* $ Files */
91 
92 /*     None. */
93 
94 /* $ Particulars */
95 
96 /*     None. */
97 
98 /* $ Examples */
99 
100 /*     See usage in ZZMKSPIN. */
101 
102 /* $ Restrictions */
103 
104 /*     None. */
105 
106 /* $ Literature_References */
107 
108 /*     None. */
109 
110 /* $ Author_and_Institution */
111 
112 /*     N.J. Bachman    (JPL) */
113 /*     J.A. Bytof      (JPL) */
114 /*     E.D. Wright     (JPL) */
115 
116 /* $ Version */
117 
118 /* -    SPICELIB Version 1.0.0, 08-FEB-2017 (NJB) */
119 
120 /*        Updated version info. */
121 
122 /*        17-JAN-2016 (NJB) */
123 
124 /*           Re-wrote portions of header. */
125 
126 /*        08-OCT-2009 (NJB) */
127 
128 /*           Re-ordered header sections. */
129 
130 /*        23-SEP-2004 (EDW) */
131 
132 /*           Recast equation to improve runtime performance. */
133 /*           Edited comments for clarity. */
134 
135 /*           Subroutine renamed from GETXYZ. */
136 
137 /*        19-FEB-2000 (JAB) */
138 
139 /*           Removed SAVED variables. */
140 
141 /*        04-FEB-1999 (JAB) */
142 
143 /* -& */
144 /* $ Index_Entries */
145 
146 /*     given a voxel's coordinates return the voxel index */
147 
148 /* -& */
149 
150 /*     Convert from voxel coordinates to voxel index. A more */
151 /*     readable form for the following function: */
152 
153 /*        NX   = NVOX(1) */
154 /*        NY   = NVOX(2) */
155 /*        NXNY = NX * NY */
156 
157 /*        ZZVOX2ID = VIXYZ(1) + (VIXYZ(2)-1)*NX + (VIXYZ(3)-1)*NXNY */
158 
159 /*     Expressing the function in this format improves runtime */
160 /*     performance as per Horner's Rule. */
161 
162     ret_val = vixyz[0] + nvox[0] * (vixyz[1] - 1 + (vixyz[2] - 1) * nvox[1]);
163     return ret_val;
164 } /* zzvox2id_ */
165 
166