use crate::symbolic::expr::SymExpr;
use once_cell::sync::Lazy;
use std::collections::HashMap;
use super::consts::{input::*, output::*, ONE, ONE_HALF, ZERO};
#[derive(PartialEq, Eq, Hash)]
pub struct TrigOut {
pub output: &'static SymExpr,
pub neg: bool,
}
impl From<&'static SymExpr> for TrigOut {
fn from(output: &'static SymExpr) -> Self {
Self {
output,
neg: false,
}
}
}
pub static SIN_TABLE: Lazy<HashMap<&SymExpr, TrigOut>> = Lazy::new(|| HashMap::from([
(&*ZERO, TrigOut::from(&*ZERO)),
(&*ONE_TWELFTH, TrigOut::from(&*ONE_HALF)),
(&*ONE_EIGHTH, TrigOut::from(&*SQRT_TWO_HALF)),
(&*ONE_SIXTH, TrigOut::from(&*SQRT_THREE_HALF)),
(&*ONE_FOURTH, TrigOut::from(&*ONE)),
(&*ONE_THIRD, TrigOut::from(&*SQRT_THREE_HALF)),
(&*THREE_EIGHTS, TrigOut::from(&*SQRT_TWO_HALF)),
(&*FIVE_TWELFTHS, TrigOut::from(&*ONE_HALF)),
(&*ONE_HALF, TrigOut::from(&*ZERO)),
(&*SEVEN_TWELFTHS, TrigOut { output: &ONE_HALF, neg: true }),
(&*FIVE_EIGHTHS, TrigOut { output: &SQRT_TWO_HALF, neg: true }),
(&*TWO_THIRDS, TrigOut { output: &SQRT_THREE_HALF, neg: true }),
(&*THREE_FOURTHS, TrigOut { output: &ONE, neg: true }),
(&*FIVE_SIXTHS, TrigOut { output: &SQRT_THREE_HALF, neg: true }),
(&*SEVEN_EIGHTHS, TrigOut { output: &SQRT_TWO_HALF, neg: true }),
(&*ELEVEN_TWELFTHS, TrigOut { output: &ONE_HALF, neg: true }),
(&*ONE, TrigOut::from(&*ZERO)),
]));
pub static COS_TABLE: Lazy<HashMap<&SymExpr, TrigOut>> = Lazy::new(|| HashMap::from([
(&*ZERO, TrigOut::from(&*ONE)),
(&*ONE_TWELFTH, TrigOut::from(&*SQRT_THREE_HALF)),
(&*ONE_EIGHTH, TrigOut::from(&*SQRT_TWO_HALF)),
(&*ONE_SIXTH, TrigOut::from(&*ONE_HALF)),
(&*ONE_FOURTH, TrigOut::from(&*ZERO)),
(&*ONE_THIRD, TrigOut { output: &ONE_HALF, neg: true }),
(&*THREE_EIGHTS, TrigOut { output: &SQRT_TWO_HALF, neg: true }),
(&*FIVE_TWELFTHS, TrigOut { output: &SQRT_THREE_HALF, neg: true }),
(&*ONE_HALF, TrigOut { output: &ONE, neg: true }),
(&*SEVEN_TWELFTHS, TrigOut { output: &SQRT_THREE_HALF, neg: true }),
(&*FIVE_EIGHTHS, TrigOut { output: &SQRT_TWO_HALF, neg: true }),
(&*TWO_THIRDS, TrigOut { output: &ONE_HALF, neg: true }),
(&*THREE_FOURTHS, TrigOut::from(&*ZERO)),
(&*FIVE_SIXTHS, TrigOut::from(&*ONE_HALF)),
(&*SEVEN_EIGHTHS, TrigOut::from(&*SQRT_TWO_HALF)),
(&*ELEVEN_TWELFTHS, TrigOut::from(&*SQRT_THREE_HALF)),
(&*ONE, TrigOut::from(&*ONE)),
]));
pub static TAN_TABLE: Lazy<HashMap<&SymExpr, TrigOut>> = Lazy::new(|| HashMap::from([
(&*ZERO, TrigOut::from(&*ZERO)),
(&*ONE_TWELFTH, TrigOut::from(&*SQRT_THREE_THIRD)),
(&*ONE_EIGHTH, TrigOut::from(&*ONE)),
(&*ONE_SIXTH, TrigOut::from(&*SQRT_THREE)),
(&*ONE_THIRD, TrigOut { output: &SQRT_THREE, neg: true }),
(&*THREE_EIGHTS, TrigOut { output: &ONE, neg: true }),
(&*FIVE_TWELFTHS, TrigOut { output: &SQRT_THREE_THIRD, neg: true }),
(&*ONE_HALF, TrigOut::from(&*ZERO)),
(&*SEVEN_TWELFTHS, TrigOut::from(&*SQRT_THREE_THIRD)),
(&*FIVE_EIGHTHS, TrigOut::from(&*ONE)),
(&*TWO_THIRDS, TrigOut::from(&*SQRT_THREE)),
(&*FIVE_SIXTHS, TrigOut { output: &SQRT_THREE, neg: true }),
(&*SEVEN_EIGHTHS, TrigOut { output: &ONE, neg: true }),
(&*ELEVEN_TWELFTHS, TrigOut { output: &SQRT_THREE_THIRD, neg: true }),
(&*ONE, TrigOut::from(&*ZERO)),
]));