use crate::_bevy::*;
use crate::components::aero_coeff::AeroCoeff;
use avian3d::math::Scalar;
use serde::{Deserialize, Serialize};
#[derive(Reflect, Serialize, Deserialize, Clone, Debug)]
#[reflect(Serialize, Deserialize)]
pub struct AirfoilData {
pub cl: AeroCoeff,
pub cd: AeroCoeff,
pub cm: AeroCoeff,
}
impl Default for AirfoilData {
fn default() -> Self {
Self {
cl: AeroCoeff::Placeholder,
cd: AeroCoeff::Placeholder,
cm: AeroCoeff::Absent,
}
}
}
impl AirfoilData {
pub fn with_post_stall(self, aspect_ratio: Scalar) -> Self {
Self {
cl: self.cl.with_post_stall_lift(aspect_ratio),
cd: self.cd.with_post_stall_drag(aspect_ratio),
cm: self.cm,
}
}
pub fn validate(&self, label: &str) -> Vec<String> {
let mut problems = Vec::new();
problems.extend(self.cl.validate(&format!("{label}.cl")));
problems.extend(self.cd.validate(&format!("{label}.cd")));
problems.extend(self.cm.validate(&format!("{label}.cm")));
problems
}
}