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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
/// arc cosine of bracketed argument
///
/// Compute arc cosine of a bracketed argument.
///
/// This routine produces a SPICE error if the |argument| exceeds
/// 1.D0 by more than TOL. If ARG exceeds 1.D0, the argument is
/// evaluated as if it equaled 1.D0, if ARG is less than -1.,
/// the argument is evaluated as if it equaled -1.D0.
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// ARG I Argument to be evaluated.
/// TOL I Tolerance.
///
/// The function returns the arc cosine of ARG.
/// ```
///
/// # Detailed Input
///
/// ```text
/// ARG is the arc cosine argument that is to be evaluated such
/// that if it is less than -1.D0 by more than TOL or greater
/// than 1.D0 by more than TOL, an error results.
///
/// TOL is a tolerance such that |ARG| is considered to be equal
/// to 1.D0 if |ARG| <= 1.D0 + TOL. TOL must be non-negative.
/// ```
///
/// # Detailed Output
///
/// ```text
/// The function returns the arc cosine of ARG. If
///
/// |ARG| >= 1.D0,
///
/// it returns DACOS (1.D0) or DACOS (-1.D0) as appropriate. Values
/// range from 0 to PI.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If |ARG| > 1.D0 + TOL, the error SPICE(INPUTOUTOFBOUNDS) is
/// signaled.
///
/// 2) If TOL is less than zero, the error SPICE(VALUEOUTOFRANGE) is
/// signaled.
/// ```
///
/// # Particulars
///
/// ```text
/// This routine determines whether |ARG| > 1.D0 + TOL. If it is, an
/// error will be flagged. In addition, the values of ARG are
/// constrained to [-1.D0, 1.D0].
/// ```
///
/// # Examples
///
/// ```text
/// The following illustrate the operation of DACOSN.
///
/// DACOSN ( -1.D0, 1.D-7 ) = PI
/// DACOSN ( -1.00001D0, 1.D-3 ) = PI
/// DACOSN ( -1.00001D0, 1.D-7 ) = PI (error flagged)
/// DACOSN ( 0.D0, 1.D-7 ) = PI/2
/// DACOSN ( 1.00001D0, 1.D-3 ) = 0.
/// DACOSN ( 1.00001D0, 1.D-7 ) = 0. (error flagged)
/// ```
///
/// # Author and Institution
///
/// ```text
/// J. Diaz del Rio (ODC Space)
/// L.S. Elson (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.1.0, 26-OCT-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard.
///
/// - SPICELIB Version 1.0.0, 28-FEB-2006 (LSE)
/// ```
pub fn dacosn(ctx: &mut SpiceContext, arg: f64, tol: f64) -> crate::Result<f64> {
let ret = DACOSN(arg, tol, ctx.raw_context())?;
ctx.handle_errors()?;
Ok(ret)
}
//$Procedure DACOSN (arc cosine of bracketed argument)
pub fn DACOSN(ARG: f64, TOL: f64, ctx: &mut Context) -> f2rust_std::Result<f64> {
let mut DACOSN: f64 = 0.0;
//
// Bracket ARG.
//
DACOSN = f64::acos(intrinsics::DMAX1(&[-1.0, intrinsics::DMIN1(&[1.0, ARG])]));
//
// Check that tolerance is non negative.
//
if (TOL < 0.0) {
CHKIN(b"DACOSN", ctx)?;
SETMSG(b"TOL was #; must be non-negative.", ctx);
ERRDP(b"#", TOL, ctx);
SIGERR(b"SPICE(VALUEOUTOFRANGE)", ctx)?;
CHKOUT(b"DACOSN", ctx)?;
return Ok(DACOSN);
}
//
// Check to see if |ARG| is within TOL of 1.D0. Signal error if
// appropriate.
//
if ((f64::abs(ARG) - TOL) > 1.0) {
CHKIN(b"DACOSN", ctx)?;
SETMSG(b"The |argument| specified was greater than 1.D0 by more than #. The value of the argument is #. ", ctx);
ERRDP(b"#", TOL, ctx);
ERRDP(b"#", ARG, ctx);
SIGERR(b"SPICE(INPUTOUTOFBOUNDS)", ctx)?;
CHKOUT(b"DACOSN", ctx)?;
return Ok(DACOSN);
}
Ok(DACOSN)
}