// TRITIUM-PROVENANCE sha256=a4af0c1a6f563d7ad624f24d632fb24d3ef6c0c06154f56f461a6292bdbef133 lang=rust // TRITIUM-HEIGHT high=0.17 mid=0.69 low=0.13 fns=8 // TRITIUM-PSEUDO fn=fsin //| fn fsin(x): // TRITIUM-HEIGHT fn=fsin high=0.00 mid=0.59 low=0.41 fn fsin(x: f64) -> f64 { let mut pi = 3.141592653589793; let mut two = 6.283185307179586; let mut i = x; while i > pi { i = i - two; } while i <= (-pi) { i = i + two; } let mut x_6 = i * i; let mut x_7 = x_6 * 2.7557319223985893e-06; let mut x_2 = -0.0001984126984126984 + x_7; let mut x_5 = 0.008333333333333333 + (x_6 * x_2); let mut x_4 = -0.16666666666666666 + (x_6 * x_5); let mut x_3 = 1.0 + (x_6 * x_4); i * x_3 } // TRITIUM-PSEUDO fn=fcos //| fn fcos(x): // TRITIUM-HEIGHT fn=fcos high=0.00 mid=0.59 low=0.41 fn fcos(x: f64) -> f64 { let mut pi = 3.141592653589793; let mut two = 6.283185307179586; let mut i = x; while i > pi { i = i - two; } while i <= (-pi) { i = i + two; } let mut x_6 = i * i; let mut x_7 = x_6 * 2.48015873015873e-05; let mut x_5 = -0.001388888888888889 + x_7; let mut x_2 = 0.041666666666666664 + (x_6 * x_5); let mut x_4 = -0.5 + (x_6 * x_2); let mut x_3 = 1.0 + (x_6 * x_4); x_3 } // TRITIUM-PSEUDO fn=fsqrt //| fn fsqrt(x): //| return 0.0 //| return i_2 // TRITIUM-HEIGHT fn=fsqrt high=0.00 mid=0.75 low=0.25 fn fsqrt(x: f64) -> f64 { let mut i = 0; let mut i_2 = 0.0; let mut x_2 = 0.0; let mut fcmp4 = ((x) <= (0.0)) as i64; if (fcmp4) != 0 { return 0.0; } else { i_2 = x; i = 0; while i < 8 { x_2 = 0.5 * (i_2 + (x / i_2)); i_2 = x_2; i += 1; } return i_2; } } // TRITIUM-PSEUDO fn=haversine_f //| fn haversine_f(lat1, lon1, lat2, lon2): //| let mut x = (lat2 - lat1) / 2.0 //| let mut aa = fsin(x) //| let mut x_3 = (lon2 - lon1) / 2.0 //| let mut bb = fsin(x_3) //| let mut h = ((aa * aa) + (((fcos(lat1) * (fcos(lat2))) * bb) * bb)) //| let mut x_2 = 2.0 * (fsqrt(h)) //| x_2 // TRITIUM-HEIGHT fn=haversine_f high=0.71 mid=0.29 low=0.00 fn haversine_f(lat1: f64, lon1: f64, lat2: f64, lon2: f64) -> f64 { let mut x = (lat2 - lat1) / 2.0; let mut aa = fsin(x); let mut x_3 = (lon2 - lon1) / 2.0; let mut bb = fsin(x_3); let mut h = ((aa * aa) + (((fcos(lat1) * (fcos(lat2))) * bb) * bb)); let mut x_2 = 2.0 * (fsqrt(h)); x_2 } // TRITIUM-PSEUDO fn=_atan_unit //| fn _atan_unit(a): // TRITIUM-HEIGHT fn=_atan_unit high=0.00 mid=1.00 low=0.00 role=leaf_charset fn _atan_unit(a: f64) -> f64 { let mut x_7 = 0.0; let mut x_6 = 0.0; let mut x_9 = 0.0; let mut t8 = 0.41421356237309503; let mut folded = 0; let mut i = a; let mut fcmp9 = ((i) > (t8)) as i64; if (fcmp9) != 0 { x_7 = 1.0 - i; x_6 = 1.0 + i; i = x_7 / x_6; folded = 1; } let mut x_5 = i * i; let mut x_3 = x_5 * -0.09090909090909091; let mut x_10 = 0.1111111111111111 + x_3; let mut x_8 = -0.14285714285714285 + (x_5 * x_10); let mut x = 0.2 + (x_5 * x_8); let mut x_4 = -0.3333333333333333 + (x_5 * x); let mut x_11 = 1.0 + (x_5 * x_4); let mut x_2 = i * x_11; if folded == 1 { x_9 = 0.7853981633974483 - x_2; x_2 = x_9; } x_2 } // TRITIUM-PSEUDO fn=fatan_poly //| fn fatan_poly(z): //| _atan_unit(...) // TRITIUM-HEIGHT fn=fatan_poly high=0.09 mid=0.91 low=0.00 role=leaf_charset fn fatan_poly(z: f64) -> f64 { let mut x_4 = 0.0; let mut x_2 = 0.0; let mut x = 0.0; let mut x_3 = 0.0; let mut neg = 0; let mut i = z; let mut fcmp7 = ((i) < (0.0)) as i64; if (fcmp7) != 0 { x_4 = 0.0 - i; i = x_4; neg = 1; } let mut swapped = 0; let mut fcmp11 = ((i) > (1.0)) as i64; if (fcmp11) != 0 { x_2 = 1.0 / i; i = x_2; swapped = 1; } let mut r = _atan_unit(i); if swapped == 1 { x = 1.5707963267948966 - r; r = x; } if neg == 1 { x_3 = 0.0 - r; r = x_3; } r } // TRITIUM-PSEUDO fn=fatan2 //| fn fatan2(y, x): //| fatan_poly(...) //| return 0.0 //| return 0.0 //| return x_4 //| return x_6 //| return x_3 //| return fatan_poly_2 // TRITIUM-HEIGHT fn=fatan2 high=0.10 mid=0.90 low=0.00 role=leaf_charset fn fatan2(y: f64, x: f64) -> f64 { let mut x_7 = 0.0; let mut x_2 = 0.0; let mut fcmp18 = 0; let mut fatan_poly_2 = 0.0; let mut fcmp25 = 0; let mut x_5 = 0.0; let mut fcmp34 = 0; let mut x_4 = 0.0; let mut x_6 = 0.0; let mut fcmp40 = 0; let mut x_3 = 0.0; let mut i = y; let mut fcmp6 = ((i) < (0.0)) as i64; if (fcmp6) != 0 { x_7 = 0.0 - i; i = x_7; } let mut i_2 = x; let mut fcmp11 = ((i_2) < (0.0)) as i64; if (fcmp11) != 0 { x_2 = 0.0 - i_2; i_2 = x_2; } let mut fcmp16 = ((i_2) >= (i)) as i64; if (fcmp16) != 0 { fcmp18 = ((i_2) == (0.0)) as i64; if (fcmp18) != 0 { return 0.0; } else { fatan_poly_2 = fatan_poly(i / i_2); } } else { fcmp25 = ((i) == (0.0)) as i64; if (fcmp25) != 0 { return 0.0; } else { x_5 = 1.5707963267948966 - (fatan_poly(i_2 / i)); fatan_poly_2 = x_5; } } let mut fcmp32 = ((x) < (0.0)) as i64; if (fcmp32) != 0 { fcmp34 = ((y) < (0.0)) as i64; if (fcmp34) != 0 { x_4 = fatan_poly_2 - 3.141592653589793; return x_4; } else { x_6 = 3.141592653589793 - fatan_poly_2; return x_6; } } else { fcmp40 = ((y) < (0.0)) as i64; if (fcmp40) != 0 { x_3 = 0.0 - fatan_poly_2; return x_3; } else { return fatan_poly_2; } } } // TRITIUM-PSEUDO fn=bearing_f //| fn bearing_f(lat1, lon1, lat2, lon2): //| fsin(...) //| fcos(...) //| fatan2(...) // TRITIUM-HEIGHT fn=bearing_f high=0.49 mid=0.51 low=0.00 fn bearing_f(lat1: f64, lon1: f64, lat2: f64, lon2: f64) -> f64 { let mut l2 = lon2; let mut l1 = lon1; let mut dl = l2 - l1; let mut dlon1 = dl; let mut sd = fsin(dlon1); let mut lat2a = lat2; let mut cl2 = fcos(lat2a); let mut ya = sd * cl2; let mut lat1a = lat1; let mut cl1 = fcos(lat1a); let mut lat2b = lat2; let mut sl2 = fsin(lat2b); let mut t1 = cl1 * sl2; let mut lat1b = lat1; let mut sl1 = fsin(lat1b); let mut lat2c = lat2; let mut cl2b = fcos(lat2c); let mut dlon2 = dl; let mut cd = fcos(dlon2); let mut t2a = sl1 * cl2b; let mut t2 = t2a * cd; let mut xa = t1 - t2; let mut yy = ya; let mut xx = xa; let mut br = fatan2(yy, xx); br }