tiny.geometry.tolerance
Defined in tiny.geometry.
Every tolerance the package compares against, in one place.
API (6)
Actions
Public operations.
boxSlack: The margin tree box tests add on every side, for coordinates no larger thanmagnitudein absolute value.isParallel: Whether a product of squared magnitudeproduct_sqis parallel noise next tofactors_sq, the product of its factors' squared lengths.
Values and defaults
Public values and defaults.
closing_sq_floor: A closing speed squared at or below this cannot reach a feature within the sweep, so the feature contributes no contact.direction_component_floor: A ray direction component at or below this magnitude is parallel to the matching slab, so its reciprocal is never formed.length_sq_floor: A squared length at or below this has no direction, so a segment this short is a point.sine_floor: Two directions whose angle has a sine at or below this are parallel.
Source
Source: lib/geometry/src/root.zig:11
zig
pub const tolerance = @import("tolerance.zig");Source: lib/geometry/src/tolerance.zig
zig
//! Every tolerance the package compares against, in one place.//!//! Primitive queries are exact computations in strict float mode that reject//! only degenerate input through the floors below. Tree queries add//! one relative slack to their box tests so a node box never culls a triangle//! that the primitive test would accept.const std = @import("std");/// Two directions whose angle has a sine at or below this are parallel. A/// cross or triple product this small next to its factors' lengths is mostly/// rounding, which is about 2^-22 of those lengths in f32, so every answer/// built on one would be noise. The test is relative, so it reads the same at/// every coordinate scale.pub const sine_floor: f32 = 0x1p-16;/// A squared length at or below this has no direction, so a segment this/// short is a point.pub const length_sq_floor: f32 = 1e-20;/// A ray direction component at or below this magnitude is parallel to the/// matching slab, so its reciprocal is never formed.pub const direction_component_floor: f32 = 1e-30;/// Whether a product of squared magnitude `product_sq` is parallel noise next/// to `factors_sq`, the product of its factors' squared lengths. A triangle/// is degenerate when its area normal is parallel noise next to its two/// edges, and a ray grazes a triangle when their determinant is parallel/// noise next to the ray and both edges.pub fn isParallel(product_sq: f32, factors_sq: f32) bool { return product_sq <= sine_floor * sine_floor * factors_sq;}/// A closing speed squared at or below this cannot reach a feature within the/// sweep, so the feature contributes no contact.pub const closing_sq_floor: f32 = 1e-24;/// The margin tree box tests add on every side, for coordinates no larger than/// `magnitude` in absolute value. Sixteen units in the last place of the/// largest coordinate bound the rounding of a slab or closest-point test.pub fn boxSlack(magnitude: f32) f32 { std.debug.assert(magnitude >= 0); return 16 * std.math.floatEps(f32) * magnitude;}test "parallel noise is judged relative to the factors" { try std.testing.expect(isParallel(0, 0)); try std.testing.expect(isParallel(1, 1e12)); try std.testing.expect(!isParallel(1e-6, 1)); try std.testing.expect(!isParallel(1e6, 1e12));}test "box slack scales with the coordinate magnitude" { try std.testing.expectEqual(@as(f32, 0), boxSlack(0)); try std.testing.expect(boxSlack(1000) > boxSlack(1)); try std.testing.expect(boxSlack(1) < 1e-5);}Complete caller list for tolerance.boxSlack
7 direct callers.
tiny.geometry.Bvh.overlapCapsule[function] atlib/geometry/src/bvh.zig:424tiny.geometry.Bvh.overlapSphere[function] atlib/geometry/src/bvh.zig:399tiny.geometry.Bvh.raycast[function] atlib/geometry/src/bvh.zig:343tiny.geometry.Bvh.raycastAny[function] atlib/geometry/src/bvh.zig:375tiny.geometry.Bvh.sweepCapsule[function] atlib/geometry/src/bvh.zig:464tiny.geometry.Bvh.sweepSphere[function] atlib/geometry/src/bvh.zig:449lib.geometry.src.tolerance.test_box_slack_scales_with_the_coordinate_magnitude[function] — test source atlib/geometry/src/tolerance.zig:52in nearest public ownertiny.geometry.tolerance
Audit
| Definitions | 7 |
|---|---|
| Public names | 7 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |