brilliant function

GemSolid brilliant({
  1. double r = 7.5,
  2. double crown = 3.6,
  3. double table = 0.52,
  4. double pavilion = 8.0,
  5. double girdle = 0.8,
  6. int n = 8,
})

Implementation

GemSolid brilliant({
  double r = 7.5,
  double crown = 3.6,
  double table = 0.52,
  double pavilion = 8.0,
  double girdle = 0.8,
  int n = 8,
}) {
  final planes = <GemPlane>[
    GemPlane(const [0.0, 1.0, 0.0], crown + girdle / 2.0, 0),
  ];
  final cs = math.atan2(crown, r * (1.0 - table));
  final ps = math.atan2(pavilion, r);
  for (var i = 0; i < n * 2; i++) {
    final a = (i * math.pi) / n;
    final half = i % 2 != 0;
    final c = half ? math.min(1.45, cs + 0.22) : cs;
    final pv = half ? ps - 0.1 : ps;
    planes.add(GemPlane(
      [math.sin(c) * math.cos(a), math.cos(c), math.sin(c) * math.sin(a)],
      r * math.sin(c) * (half ? 1.012 : 1.0) + (girdle / 2.0) * math.cos(c),
      half ? 2 : 1,
    ));
    planes.add(GemPlane([math.cos(a), 0.0, math.sin(a)], r, 3));
    planes.add(GemPlane(
      [math.sin(pv) * math.cos(a), -math.cos(pv), math.sin(pv) * math.sin(a)],
      r * math.sin(pv) * (half ? 1.03 : 1.0) + (girdle / 2.0) * math.cos(pv),
      half ? 5 : 4,
    ));
  }
  return GemSolid(
    planes: planes,
    r: r,
    top: crown + girdle / 2.0,
    bottom: pavilion + girdle / 2.0,
  );
}