Expand description
§ALICE-LOL: Law-Oriented Language
A text language for signed distance fields: the lol! macro (compile time)
and runtime_parser (run time) turn the same text into an
SdfNode tree, which can be evaluated on the CPU, transpiled to
GLSL / WGSL / HLSL, exported for 3D printing, and checked against
geometric constraints (law). research_law holds unit-checked
formulas with valid ranges, residuals and provenance.
use alice_lol::lol;
use alice_lol::runtime_parser::parse_lol;
use alice_lol::Vec3;
// Compile time: the macro builds the tree
let scene = lol! {
smooth_union(0.2,
sphere(1.0),
translate(2.0, 0.0, 0.0, box3d(0.5, 0.5, 0.5))
)
};
// Run time: the same text through the parser (from a file or a language model)
let parsed = parse_lol(
"smooth_union(0.2, sphere(1.0), translate(2.0, 0.0, 0.0, box3d(0.5, 0.5, 0.5)))",
)
.unwrap();
// Both are the same field; the origin is inside the sphere
let p = Vec3::new(0.3, 0.1, 0.0);
assert_eq!(alice_lol::eval(&scene, p), alice_lol::eval(&parsed, p));
assert!(alice_lol::eval(&scene, Vec3::ZERO) < 0.0);
// GLSL source for a shader (default feature `glsl`)
let glsl = alice_lol::to_glsl(&scene);
assert!(!glsl.is_empty());Modules§
- angle
- Canonicalizing a user-supplied angle before it is converted to radians Reducing a user-supplied angle, in degrees, to a numerically well-conditioned range before it is ever converted to radians.
- audit_
law - 監査の Law — 検査を「何が成立すべきか」として書く.
- emit
SdfNode→ LOL text (runtime parser の逆変換、Track C0)SdfNode→ LOL text (Track C0、runtime_parser::parse_lolの逆変換)- geometry_
id - The geometry evaluation’s identifier —
.loltext →SdfNodetree → evaluation result, and the reverse (emit’s canonical form). - intent
- Intent Layer (Milestone B.1:
IntentNode独立 enum + Program 構造) - laser_
pattern - レーザー彫刻向け2Dパターン生成
- law
- 法則(Law)制約チェッカー
- law_id
- Law の識別子 — 同じ主張に同じ名前を付ける.
- law_
input - 入力の読み方 — 型を持つ
x-inputと、request の JSON の読み. - limits
- Named resource limits for user-controlled parameters, and the error types that report a refusal.
- parity
- When two evaluations of a field agree (IEEE-total: ±∞ and NaN are results) When two evaluations of a field agree
- print_
export - 3Dプリント向けエクスポートモジュール
- pruned_
compile - 空間枝刈りコンパイラ
- research_
law - Research laws: multi-variable formulas with units, a valid range, measured residuals, provenance and reference values
- runtime_
parser - ランタイム LOL パーサー
- stdlib
- Standard Library — LOL 標準パターンライブラリ
Macros§
- lol
- LOL (Law-Oriented Language)
proc_macro.
Structs§
- Aabb
Packed - SIMD-friendly AABB structure (32 bytes, cache-aligned)
- Compiled
Sdf - Compiled SDF representation
- Compiled
SdfBvh - Compiled SDF with BVH acceleration data
- Dual
- 1D dual number:
val + eps * dot. - Dual3
- 3D dual number: value + gradient (∂f/∂x, ∂f/∂y, ∂f/∂z).
- Interval
- A closed interval [lo, hi] representing a range of possible values
- Quat
- A quaternion representing an orientation.
- Render
Config - レンダリング設定
- Vec2
- A 2-dimensional vector.
- Vec3
- A 3-dimensional vector.
- Vec3
Interval - 3D interval representing an axis-aligned box region
- Vec3x8
- 8 3D vectors packed for SIMD processing
Enums§
- Compile
Error - Error type for SDF compilation failures.
- Euler
Rot - Rotation Helper Euler rotation sequences.
- SdfNode
- Signed Distance Function Node
Constants§
- LOL_
GBNF - The LOL DSL grammar (
lol.gbnf, GBNF) as shipped with this crate version.
Functions§
- eval
- Evaluate the SDF distance at a single point (CPU).
- eval_
compiled - Evaluate a compiled SDF at a point
- eval_
compiled_ batch_ simd - Batch evaluate compiled SDF using SIMD (8 points at a time)
- eval_
compiled_ batch_ simd_ parallel - Parallel batch evaluate compiled SDF using SIMD
- eval_
compiled_ batch_ soa - Evaluate compiled SDF at many points using SoA layout (single-threaded)
- eval_
compiled_ batch_ soa_ parallel - Evaluate compiled SDF at many points using SoA layout (multi-threaded)
- eval_
compiled_ bvh - Evaluate compiled SDF with BVH annotations.
- eval_
compiled_ distance_ and_ normal - Combined distance + normal from 4 evaluations (tetrahedral method).
- eval_
compiled_ normal - Evaluate compiled SDF and compute normal using finite differences
- eval_
compiled_ simd - Evaluate compiled SDF at 8 points simultaneously
- eval_
hessian - Compute the Hessian (second derivatives) at a point via finite differences on the gradient.
- eval_
interval - Evaluate an SDF tree over a spatial region, returning distance bounds.
- eval_
with_ gradient - Evaluate SDF value and gradient simultaneously.
- gaussian_
curvature - Compute Gaussian curvature K = k1 * k2 at a surface point.
- get_
scene_ aabb - Get the AABB for the entire compiled SDF
- mean_
curvature - Compute mean curvature at a point on the surface.
- principal_
curvatures - Compute principal curvatures (k1, k2) at a surface point.
- to_glsl
- Transpile an
SdfNodetree to GLSL (hardcoded constants). - to_
glsl_ dynamic - Transpile an
SdfNodetree to GLSL with dynamic parameters (uniform block). - to_
glsl_ full - フルレンダリングパイプライン付きGLSLを生成