Skip to documentation
SLOP

tiny.geometry.Triangle

Reference tiny.geometry Triangle

Defined in tiny.geometry.

A triangle with counter-clockwise winding around its normal.

API (9)

Actions

Public operations.

Fields and members

Public fields and members.

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

Source

Source: lib/geometry/src/primitive.zig:146

zig
/// A triangle with counter-clockwise winding around its normal.pub const Triangle = extern struct {    a: Vec3,    b: Vec3,    c: Vec3,    /// The unnormalized normal, twice the area in length.    pub fn areaNormal(triangle: Triangle) Vec3 {        return triangle.b.sub(triangle.a).cross(triangle.c.sub(triangle.a));    }    /// Whether the corners are collinear, or so close to it that the area    /// normal is rounding noise.    pub fn isDegenerate(triangle: Triangle) bool {        const edge1 = triangle.b.sub(triangle.a);        const edge2 = triangle.c.sub(triangle.a);        return tolerance.isParallel(edge1.cross(edge2).lengthSq(), edge1.lengthSq() * edge2.lengthSq());    }    /// The unit normal, or null for a degenerate triangle.    pub fn normal(triangle: Triangle) ?Vec3 {        if (triangle.isDegenerate()) return null;        return triangle.areaNormal().normalized(0);    }    pub fn centroid(triangle: Triangle) Vec3 {        return triangle.a.add(triangle.b).add(triangle.c).scale(1.0 / 3.0);    }    pub fn bounds(triangle: Triangle) Aabb {        return Aabb.fromPoint(triangle.a).joinPoint(triangle.b).joinPoint(triangle.c);    }    pub fn vertex(triangle: Triangle, index: usize) Vec3 {        assert(index < 3);        return switch (index) {            0 => triangle.a,            1 => triangle.b,            else => triangle.c,        };    }};

Source: lib/geometry/src/root.zig:19

zig
pub const Triangle = primitive.Triangle;
Called byCallsNo direct callersAabbfromPointTrianglebounds
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callerstoleranceisParallelTriangleisDegenerate
Static calls · unresolved targets: 0 · external targets: 5.
Called byCallsNo direct callstest sourcelib.choir.src.backends.gpu.cpu.testtest: lowered block reads run through...test sourcelib.choir.src.backends.gpu.cpu.testtest: lowered textured stages run thr...Trianglevertex
Static calls · unresolved targets: 0 · external targets: 0.

Audit

Definitions7
Public names7
Members3
Version26.7.0
Revisiondaab053ee433