1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
const RNAME: &[u8] = b"T_TSTBOX";
//
// Utility routine T_TSTBOX: create latitude bounding
// box for testing. The bounds of segment may span the
// X-Y plane.
//
pub fn T_TSTBOX(
BOUNDS: &[f64],
CENTER: &mut [f64],
LR: &mut f64,
LT: &mut f64,
LZ: &mut f64,
RADIUS: &mut f64,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let BOUNDS = DummyArray2D::new(BOUNDS, 1..=2, 1..=3);
let mut CENTER = DummyArrayMut::new(CENTER, 1..=3);
let mut CTR = StackArray2D::<f64, 6>::new(1..=3, 1..=2);
let mut DIAG = StackArray::<f64, 3>::new(1..=3);
let mut EXTENT = StackArray2D::<f64, 6>::new(1..=3, 1..=2);
let mut H: f64 = 0.0;
let mut LOCBDS = StackArray2D::<f64, 6>::new(1..=2, 1..=3);
let mut LON: f64 = 0.0;
let mut MAXLAT: f64 = 0.0;
let mut MAXRC: f64 = 0.0;
let mut MAXZ: f64 = 0.0;
let mut MINLAT: f64 = 0.0;
let mut MINRC: f64 = 0.0;
let mut MINZ: f64 = 0.0;
let mut R: f64 = 0.0;
let mut R1: f64 = 0.0;
let mut R2: f64 = 0.0;
//
// SPICELIB Functions
//
//
// Local parameters
//
//
// Local variables
//
if spicelib::RETURN(ctx) {
return Ok(());
}
spicelib::CHKIN(RNAME, ctx)?;
MINLAT = BOUNDS[[1, 2]];
MAXLAT = BOUNDS[[2, 2]];
if ((MINLAT >= 0.0) || (MAXLAT < 0.0)) {
//
// The volume element doesn't cross the X-Y plane.
// We can delegate the job.
//
T_MKBOX(
BOUNDS.as_slice(),
CENTER.as_slice_mut(),
LR,
LT,
LZ,
RADIUS,
ctx,
)?;
spicelib::CHKOUT(RNAME, ctx)?;
return Ok(());
}
//
// The volume element crosses the X-Y plane. Divide the
// element into upper and lower parts; find bounding boxes
// for each.
//
for I in 1..=2 {
spicelib::MOVED(BOUNDS.as_slice(), 6, LOCBDS.as_slice_mut());
LOCBDS[[I, 2]] = 0.0;
let [arg2, arg3, arg4] = EXTENT
.get_disjoint_mut([[1, I], [2, I], [3, I]])
.expect("mutable array elements passed to function must have disjoint indexes");
T_MKBOX(
LOCBDS.as_slice(),
CTR.subarray_mut([1, I]),
arg2,
arg3,
arg4,
&mut R,
ctx,
)?;
}
//
// At this point the longitude of the center and the tangential
// extent of the box are known. We'll need to recompute the
// radius and Z component of the center and the radial and Z
// extents of the box.
//
*LT = EXTENT[[2, 1]];
//
// Start with the Z values. Recall that the two boxes
// are bounded by the X-Y plane, which simplifies our
// calculations. The box at index 1 is the upper box.
//
MAXZ = EXTENT[[3, 1]];
MINZ = -EXTENT[[3, 2]];
*LZ = intrinsics::DMAX1(&[0.0, (MAXZ - MINZ)]);
CENTER[3] = (MAXZ - (*LZ / 2 as f64));
//
// Both boxes have the maximum radial component, so we can
// compute this component using the first box alone. The
// minimum radial component must be derived using both boxes.
//
// Note the radial component of the box center is always
// positive, and the longitude of the box center is always
// the same as that of the midpoint of the centers of any
// arc of constant latitude on the outer bounding sphere.
//
spicelib::RECCYL(CTR.subarray([1, 1]), &mut R1, &mut LON, &mut H, ctx);
MAXRC = (R1 + (EXTENT[[1, 1]] / 2 as f64));
spicelib::RECCYL(CTR.subarray([1, 2]), &mut R2, &mut LON, &mut H, ctx);
MINRC = intrinsics::DMIN1(&[
(R1 - (EXTENT[[1, 1]] / 2 as f64)),
(R2 - (EXTENT[[1, 2]] / 2 as f64)),
]);
*LR = intrinsics::DMAX1(&[0.0, (MAXRC - MINRC)]);
H = CENTER[3];
spicelib::CYLREC((MAXRC - (*LR / 2 as f64)), LON, H, CENTER.as_slice_mut());
spicelib::VPACK(
(*LT / 2 as f64),
(*LR / 2 as f64),
(*LZ / 2 as f64),
DIAG.as_slice_mut(),
);
*RADIUS = spicelib::VNORM(DIAG.as_slice());
spicelib::CHKOUT(RNAME, ctx)?;
Ok(())
}