pub(crate) mod cap;
mod corner;
mod inputs;
mod layout;
#[cfg(test)]
mod layout_rows;
mod normals;
pub(crate) use inputs::ArcInputs;
pub(crate) use layout::layout;
use super::{Arithmetic, BarrelClient};
use crate::structures::tensor::culvert::Bounds;
use numr::dtype::DType;
use numr::ops::{BinaryOps, ConditionalOps};
use numr::runtime::Runtime;
use numr::tensor::Tensor;
use solvr::common::arithmetic::{ArithmeticResult, Interval};
pub(crate) struct ArcBand<R: Runtime<DType = DType>> {
pub(crate) centre_x: Bounds<R>,
pub(crate) centre_y: Bounds<R>,
pub(crate) radius: Bounds<R>,
pub(crate) start_angle: Bounds<R>,
pub(crate) start_sin: Bounds<R>,
pub(crate) start_cos: Bounds<R>,
pub(crate) start_depth: Bounds<R>,
pub(crate) start_area: Bounds<R>,
pub(crate) start_perimeter: Bounds<R>,
pub(crate) start_moment: Bounds<R>,
pub(crate) circle_low: Bounds<R>,
pub(crate) circle_high: Bounds<R>,
}
pub(crate) struct ArcLayout<R: Runtime<DType = DType>> {
pub(crate) bands: [ArcBand<R>; 3],
pub(crate) full_area: Bounds<R>,
pub(crate) full_perimeter: Bounds<R>,
pub(crate) full_radius: Bounds<R>,
pub(crate) full_moment: Bounds<R>,
pub(crate) widest_depth: Bounds<R>,
}
pub(crate) fn meet<R>(
a: &mut Arithmetic<'_, R>,
x: &Interval<R>,
y: &Interval<R>,
) -> ArithmeticResult<Interval<R>>
where
R: Runtime<DType = DType>,
R::Client: BarrelClient<R>,
{
let c = a.client();
let lower = c.maximum(x.lower(), y.lower())?;
let upper = c.minimum(x.upper(), y.upper())?;
a.bounds(&lower, &upper)
}
fn pick<R>(
a: &Arithmetic<'_, R>,
mask: &Tensor<R>,
on: &Interval<R>,
off: &Interval<R>,
) -> ArithmeticResult<Bounds<R>>
where
R: Runtime<DType = DType>,
R::Client: BarrelClient<R>,
{
let c = a.client();
Ok([
c.where_cond(mask, on.lower(), off.lower())?,
c.where_cond(mask, on.upper(), off.upper())?,
])
}