Skip to documentation
SLOP

tiny.linear.Vec3

Reference tiny.linear Vec3

Defined in tiny.linear.

API (27)

Actions

Public operations.

Types and contracts

Public types and contracts.

Fields and members

Public fields and members.

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

Source

Source: lib/linear/src/vector.zig:102

zig
pub const Vec3 = extern struct {    x: f32 = 0,    y: f32 = 0,    z: f32 = 0,    pub const zero: Vec3 = .{};    pub fn init(x: f32, y: f32, z: f32) Vec3 {        return .{ .x = x, .y = y, .z = z };    }    pub fn splat(value: f32) Vec3 {        return .{ .x = value, .y = value, .z = value };    }    pub fn fromArray(lanes: [3]f32) Vec3 {        return .{ .x = lanes[0], .y = lanes[1], .z = lanes[2] };    }    pub fn toArray(v: Vec3) [3]f32 {        return .{ v.x, v.y, v.z };    }    pub fn add(a: Vec3, b: Vec3) Vec3 {        return .{ .x = a.x + b.x, .y = a.y + b.y, .z = a.z + b.z };    }    pub fn sub(a: Vec3, b: Vec3) Vec3 {        return .{ .x = a.x - b.x, .y = a.y - b.y, .z = a.z - b.z };    }    /// Lane-wise product.    pub fn mul(a: Vec3, b: Vec3) Vec3 {        return .{ .x = a.x * b.x, .y = a.y * b.y, .z = a.z * b.z };    }    pub fn scale(v: Vec3, s: f32) Vec3 {        return .{ .x = v.x * s, .y = v.y * s, .z = v.z * s };    }    pub fn negate(v: Vec3) Vec3 {        return .{ .x = -v.x, .y = -v.y, .z = -v.z };    }    pub fn dot(a: Vec3, b: Vec3) f32 {        return a.x * b.x + a.y * b.y + a.z * b.z;    }    pub fn cross(a: Vec3, b: Vec3) Vec3 {        return .{            .x = a.y * b.z - a.z * b.y,            .y = a.z * b.x - a.x * b.z,            .z = a.x * b.y - a.y * b.x,        };    }    pub fn lengthSq(v: Vec3) f32 {        return v.dot(v);    }    pub fn length(v: Vec3) f32 {        return @sqrt(v.lengthSq());    }    pub fn distanceSq(a: Vec3, b: Vec3) f32 {        return a.sub(b).lengthSq();    }    pub fn distance(a: Vec3, b: Vec3) f32 {        return @sqrt(a.distanceSq(b));    }    /// The unit vector along `v`, or null when its length is at most    /// `min_length` or is NaN.    pub fn normalized(v: Vec3, min_length: f32) ?Vec3 {        assert(min_length >= 0);        const len = v.length();        if (!(len > min_length)) return null;        return v.scale(1 / len);    }    /// `v` shortened to `max_length` when it is longer, else `v` unchanged.    pub fn clampLength(v: Vec3, max_length: f32) Vec3 {        assert(max_length >= 0);        const len = v.length();        if (len > max_length) return v.scale(max_length / len);        return v;    }    /// `a` at `t = 0` and `b` at `t = 1`.    pub fn lerp(a: Vec3, b: Vec3, t: f32) Vec3 {        return a.add(b.sub(a).scale(t));    }    pub fn min(a: Vec3, b: Vec3) Vec3 {        return .{ .x = @min(a.x, b.x), .y = @min(a.y, b.y), .z = @min(a.z, b.z) };    }    pub fn max(a: Vec3, b: Vec3) Vec3 {        return .{ .x = @max(a.x, b.x), .y = @max(a.y, b.y), .z = @max(a.z, b.z) };    }    pub fn abs(v: Vec3) Vec3 {        return .{ .x = @abs(v.x), .y = @abs(v.y), .z = @abs(v.z) };    }    pub fn minComponent(v: Vec3) f32 {        return @min(v.x, @min(v.y, v.z));    }    pub fn maxComponent(v: Vec3) f32 {        return @max(v.x, @max(v.y, v.z));    }};

Source: lib/linear/src/root.zig:9

zig
pub const Vec3 = vector.Vec3;
Called byCallsNo direct callstest sourcelib.linear.src.vectortest: vector arithmetic evaluates eac...Vec3add
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate; no linkfun.sdfii.src.navigation.boidstepBoidsprivate sourcelib.linear.src.testarithmeticDigestVec3clampLength
Static calls · unresolved targets: 0 · external targets: 2.
Called byCallsNo direct callsprivate; no linkfun.sdfii.src.audio.spatialcomputePanprivate; no linkfun.sdfii.src.engine.system.audio.runtimevalidListenerprivate; no linkfun.sdfii.src.sdf.gradientinverseOrientVecprivate; no linkfun.sdfii.src.sdf.gradientorientPointprivate; no linkfun.sdfii.src.sdf.vjpaccumulateSlotGradient+4 moreVec3cross
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate; no linkfun.sdfii.src.audio.late.BoundaryCacheisValidprivate; no linkfun.sdfii.src.validation.audiomixForVec3distanceSq
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callstest sourcelib.linear.src.vectortest: vector arithmetic evaluates eac...Vec3dot
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate; no linkfun.sdfii.src.audio.late.BoundaryCachemeanBoundaryDistanceprivate; no linkfun.sdfii.src.engine.abi.physicssdfii quat from axis angleprivate; no linkfun.sdfii.src.engine.abi.physicssdfii quat integrateprivate; no linkfun.sdfii.src.engine.abi.querysdfii engine core query box contactprivate; no linkfun.sdfii.src.engine.abi.querysdfii engine core query distance+25 moreVec3fromArray
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.linear.src.vectortest: clampLength shortens only longe...test sourcelib.linear.src.vectortest: cross product follows the right...test sourcelib.linear.src.vectortest: homogeneous vectors carry their...test sourcelib.linear.src.vectortest: normalized multiplies by the re...test sourcelib.linear.src.vectortest: normalized returns null at or b...+2 moreVec3init
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate; no linkfun.sdfii.src.audio.spatialcomputePanprivate; no linkfun.sdfii.src.engine.system.audio.runtimevalidListenerVec3lengthSq
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callsprivate sourcelib.linear.src.testarithmeticDigestVec3lerp
Static calls · unresolved targets: 1 · external targets: 1.
Called byCallsNo direct callsprivate; no linkfun.sdfii.src.navigation.graph.scenessignedDistanceInsideBoxprivate; no linkfun.sdfii.src.navigation.scenessampleInsideBoxtest sourcelib.linear.src.vectortest: vector arithmetic evaluates eac...Vec3maxComponent
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.linear.src.vectortest: vector arithmetic evaluates eac...Vec3minComponent
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.linear.src.vectortest: vector arithmetic evaluates eac...Vec3mul
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate; no linkfun.sdfii.src.audio.late.LateFieldServicebuildCacheprivate; no linkfun.sdfii.src.audio.spatialcomputePanprivate; no linkfun.sdfii.src.audio.spatialsegmentMarchprivate; no linkfun.sdfii.src.navigation.flowgenerateFlowFieldprivate; no linkfun.sdfii.src.navigation.harmonic.HarmonicNav...extractPath+16 moreVec3normalized
Static calls · unresolved targets: 0 · external targets: 2.
Called byCallsNo direct callstest sourcelib.linear.src.vectortest: vector arithmetic evaluates eac...Vec3scale
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.linear.src.vectortest: vector arithmetic evaluates eac...Vec3sub
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest; no linkfun.sdfii.src.physics.bodytest: axis-angle round-trip through q...private; no linkfun.sdfii.src.physics.contactcomputeBatchContactForcestest sourcelib.linear.src.vectortest: vector arithmetic evaluates eac...Vec3toArray
Static calls · unresolved targets: 0 · external targets: 0.

Complete caller list for Vec3.cross

9 direct callers.

Complete caller list for Vec3.fromArray

30 direct callers.

Complete caller list for Vec3.init

7 direct callers.

Complete caller list for Vec3.normalized

21 direct callers.

Audit

Definitions25
Public names25
Members3
Version26.7.0
Revisiondaab053ee433