Skip to documentation
SLOP

tiny.geometry.tolerance

Reference tiny.geometry tolerance

Defined in tiny.geometry.

Every tolerance the package compares against, in one place.

API (6)

Actions

Public operations.

Values and defaults

Public values and defaults.

No direct callersNo direct callstiny.geometrytolerance
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallsNo direct callsBvhoverlapCapsuleBvhoverlapSphereBvhraycastBvhraycastAnyBvhsweepCapsule+2 moretoleranceboxSlack
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsintersectrayPlaneintersectrayTriangleTriangleisDegenerateprivate sourcelib.geometry.src.sweepaxisEdgetest sourcelib.geometry.src.tolerancetest: parallel noise is judged relati...toleranceisParallel
Static calls · unresolved targets: 0 · external targets: 0.

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.

Audit

Definitions7
Public names7
Members0
Version26.7.0
Revisiondaab053ee433