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
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
//$Procedure ZZINRYPL ( Simplified intersection of ray and plane )
pub fn ZZINRYPL(
VERTEX: &[f64],
UDIR: &[f64],
UPLNML: &[f64],
CONST: f64,
MAXD: f64,
NXPTS: &mut i32,
XPT: &mut [f64],
) {
let VERTEX = DummyArray::new(VERTEX, 1..=3);
let UDIR = DummyArray::new(UDIR, 1..=3);
let UPLNML = DummyArray::new(UPLNML, 1..=3);
let mut XPT = DummyArrayMut::new(XPT, 1..=3);
let mut DIRCON: f64 = 0.0;
let mut H: f64 = 0.0;
let mut LPAR: f64 = 0.0;
let mut S: f64 = 0.0;
let mut VTXCON: f64 = 0.0;
//
// SPICELIB functions
//
//
// Local variables
//
//
// Start out indicating no intersection.
//
*NXPTS = 0;
//
// VTXCON is the plane constant of the ray's vertex.
//
VTXCON = VDOT(VERTEX.as_slice(), UPLNML.as_slice());
//
// DIRCON is the length of the component of the ray's
// direction vector in the direction of UPLNML.
//
DIRCON = VDOT(UDIR.as_slice(), UPLNML.as_slice());
//
// Dispose of the easy non-intersection cases. (The ray
// lying in the plane is considered a non-intersection case,
// by the way.)
//
if ((VTXCON > CONST) && (DIRCON > 0.0)) {
return;
}
if ((VTXCON < CONST) && (DIRCON < 0.0)) {
return;
}
if (VTXCON == CONST) {
//
// The ray's vertex lies in the plane.
//
if (DIRCON != 0.0) {
//
// The ray does not lie in the plane. The
// intercept is the ray's vertex.
//
*NXPTS = 1;
VEQU(VERTEX.as_slice(), XPT.as_slice_mut());
}
return;
}
//
// Let UPAR and UPERP be, respectively, the components of UDIR
// parallel to and perpendicular to UPLNML.
//
// Compute the maximum allowed length of UPERP.
//
//
H = f64::abs((VTXCON - CONST));
LPAR = f64::abs(DIRCON);
//
// To prevent overflow, we require
//
// H
// ---- <= MAXD
// LPAR
//
// or equivalently
//
// H <= MAXD * LPAR
//
if (H > (MAXD * LPAR)) {
return;
}
//
// For safety, return if we could have a divide-by-zero error.
//
if (LPAR == 0.0) {
return;
}
//
// Still being here means we can compute XPT, provided
// the given value of MAXD was reasonable.
//
// Note that the earlier tests we performed should
// rule out the case
//
// DIRCON = 0
//
// We have also ruled out overflow in the computation below.
//
S = (H / LPAR);
XPT[1] = (VERTEX[1] + (S * UDIR[1]));
XPT[2] = (VERTEX[2] + (S * UDIR[2]));
XPT[3] = (VERTEX[3] + (S * UDIR[3]));
*NXPTS = 1;
}