use std::f32::consts::PI;
use glam::Vec3;
use super::StandardGemCuts;
use crate::geometry::plane::GpuFacetPlane;
pub const STANDARD_ROUND_BRILLIANT_GIRDLE_FACETS: std::ops::Range<usize> = 33..49;
impl StandardGemCuts {
#[must_use]
pub fn index_to_azimuth(index: f32, gear_teeth: f32, gear_reference_angle: f32) -> f32 {
2.0 * PI * (index + gear_reference_angle) / gear_teeth
}
#[must_use]
pub fn standard_round_brilliant() -> Vec<GpuFacetPlane> {
let mut planes = Vec::with_capacity(57);
let gear_teeth = 96.0f32;
planes.push(GpuFacetPlane::new(Vec3::new(0.0, 1.0, 0.0), -0.32));
let star_angle = 15.0f32.to_radians();
for &g in &[6.0, 18.0, 30.0, 42.0, 54.0, 66.0, 78.0, 90.0] {
let phi = Self::index_to_azimuth(g, gear_teeth, 0.0);
let n = Vec3::new(
star_angle.sin() * phi.cos(),
star_angle.cos(),
star_angle.sin() * phi.sin(),
);
planes.push(GpuFacetPlane::new(n, -0.45));
}
let crown_main_angle = 34.5f32.to_radians();
for &g in &[0.0, 12.0, 24.0, 36.0, 48.0, 60.0, 72.0, 84.0] {
let phi = Self::index_to_azimuth(g, gear_teeth, 0.0);
let n = Vec3::new(
crown_main_angle.sin() * phi.cos(),
crown_main_angle.cos(),
crown_main_angle.sin() * phi.sin(),
);
planes.push(GpuFacetPlane::new(n, -0.59));
}
let upper_girdle_angle = 41.0f32.to_radians();
for &g in &[
95.0, 1.0, 11.0, 13.0, 23.0, 25.0, 35.0, 37.0, 47.0, 49.0, 59.0, 61.0, 71.0, 73.0,
83.0, 85.0,
] {
let phi = Self::index_to_azimuth(g, gear_teeth, 0.0);
let n = Vec3::new(
upper_girdle_angle.sin() * phi.cos(),
upper_girdle_angle.cos(),
upper_girdle_angle.sin() * phi.sin(),
);
planes.push(GpuFacetPlane::new(n, -0.67));
}
for i in 0..16 {
let phi = 2.0 * PI * (i as f32) / 16.0;
let n = Vec3::new(phi.cos(), 0.0, phi.sin());
planes.push(GpuFacetPlane::new(n, -1.0));
}
let pav_main_angle = 41.0f32.to_radians();
for &g in &[0.0, 12.0, 24.0, 36.0, 48.0, 60.0, 72.0, 84.0] {
let phi = Self::index_to_azimuth(g, gear_teeth, 0.0);
let n = Vec3::new(
pav_main_angle.sin() * phi.cos(),
-pav_main_angle.cos(),
pav_main_angle.sin() * phi.sin(),
);
planes.push(GpuFacetPlane::new(n, -0.67));
}
let lower_girdle_angle = 42.5f32.to_radians();
for &g in &[
95.0, 1.0, 11.0, 13.0, 23.0, 25.0, 35.0, 37.0, 47.0, 49.0, 59.0, 61.0, 71.0, 73.0,
83.0, 85.0,
] {
let phi = Self::index_to_azimuth(g, gear_teeth, 0.0);
let n = Vec3::new(
lower_girdle_angle.sin() * phi.cos(),
-lower_girdle_angle.cos(),
lower_girdle_angle.sin() * phi.sin(),
);
planes.push(GpuFacetPlane::new(n, -0.68));
}
planes.push(GpuFacetPlane::new(Vec3::new(0.0, -1.0, 0.0), -0.88));
planes
}
}