Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Gemstone Computations

You can write scripts to analyze geometry.

// 1. Setup Stone
sym = Rotate(Z, 8)
// Pavilion (Negative)
P1 = Plane(Normal(-42.0, 0), 5) |> sym
P2 = Plane(Normal(-41.0, 6), 5) |> sym
// Crown (Positive)
C1 = Plane(Normal(35.0, 0), 5) |> sym
// Table (Z+, Height 6)
Table = Plane(Z, 6.0)

Stone_Planes = P1 + P2 + C1 + Table
// Assign to "Stone" to render and compute hull
Stone := Stone_Planes

// 2. Extract Coordinates
// unique ensures we don't count duplicate vertices
Verts = Stone_Planes.unique.vertices

Xs = Verts |> (v) => v.x
Ys = Verts |> (v) => v.y
Zs = Verts |> (v) => v.z

// 3. Analysis Helpers
import "std"

// Custom fold to find max/min
get_max = (arr) => arr.fold((acc, x) => max(acc, x), -1000.0)
get_min = (arr) => arr.fold((acc, x) => min(acc, x), 1000.0)

min_x = get_min(Xs)
max_x = get_max(Xs)
// ... same for Y and Z
_ := [min_x, max_x]

Optical Checks

Calculate critical angles to check for windowing.

import "std"

// Calculate Critical Angle for RI 1.54
crit_angle = asin(1.0 / 1.54) * (180.0 / PI)

// Check if a pavilion angle works
is_windowing = 40.0 < crit_angle
_ := [crit_angle, is_windowing]