Bivariate Linear Piecewise Function
BivariateLinearPiecewiseFunction represents a piecewise-planar surface over a triangulation. Every cell has three vertices
Solver mathematical model
Let
Rust ties each weight group to its selector with the per-triangle equality resultPolynomial; for binary
Only one triangle may carry nonzero weights. This is different from an unrestricted convex hull over all vertices and therefore preserves the piecewise surface across non-coplanar cells.
Direct evaluation
For each triangle, the evaluator computes barycentric coordinates 1e-12: weights down to -1e-12 are accepted. The first triangle for which every weight is within that tolerance contains the input, and
Inputs outside every triangle return null/None. Construction rejects every triangle with a non-finite coordinate or an absolute 2-D determinant at or below 1e-12; degenerate triangles therefore cannot reach evaluation in either implementation.
Kotlin/Rust example
val surface = BivariateLinearPiecewiseFunction(
x = xPolynomial,
y = yPolynomial,
triangles = triangles,
converter = IntoValue.Identity,
name = "surface"
)let surface = BivariateLinearPiecewiseFunction::new(
1,
"surface",
x_input,
y_input,
vec![Triangle3::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 0.0, 10.0),
Point3::new(0.0, 1.0, 20.0),
)],
);
assert_eq!(surface.selector_variables().len(), 1);Tests and references
- Kotlin implementation:
BivariateLinearPiecewise.kt - Kotlin dedicated test:
BivariateLinearPiecewiseFunctionDedicatedTest.kt - Rust implementation:
bivariate_linear_piecewise.rs - Rust dedicated test:
function_symbol_bivariate_linear_piecewise.rs