Skip to documentation
SLOP

tiny.linear.Vec4

Reference tiny.linear Vec4

Defined in tiny.linear.

API (24)

Actions

Public operations.

Types and contracts

Public types and contracts.

Fields and members

Public fields and members.

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

Source

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

zig
pub const Vec4 = extern struct {    x: f32 = 0,    y: f32 = 0,    z: f32 = 0,    w: f32 = 0,    pub const zero: Vec4 = .{};    pub fn init(x: f32, y: f32, z: f32, w: f32) Vec4 {        return .{ .x = x, .y = y, .z = z, .w = w };    }    pub fn splat(value: f32) Vec4 {        return .{ .x = value, .y = value, .z = value, .w = value };    }    /// A homogeneous vector: `w = 1` for a point, `w = 0` for a direction.    pub fn fromVec3(v: Vec3, w: f32) Vec4 {        return .{ .x = v.x, .y = v.y, .z = v.z, .w = w };    }    pub fn fromArray(lanes: [4]f32) Vec4 {        return .{ .x = lanes[0], .y = lanes[1], .z = lanes[2], .w = lanes[3] };    }    pub fn toArray(v: Vec4) [4]f32 {        return .{ v.x, v.y, v.z, v.w };    }    pub fn xyz(v: Vec4) Vec3 {        return .{ .x = v.x, .y = v.y, .z = v.z };    }    pub fn add(a: Vec4, b: Vec4) Vec4 {        return .{ .x = a.x + b.x, .y = a.y + b.y, .z = a.z + b.z, .w = a.w + b.w };    }    pub fn sub(a: Vec4, b: Vec4) Vec4 {        return .{ .x = a.x - b.x, .y = a.y - b.y, .z = a.z - b.z, .w = a.w - b.w };    }    /// Lane-wise product.    pub fn mul(a: Vec4, b: Vec4) Vec4 {        return .{ .x = a.x * b.x, .y = a.y * b.y, .z = a.z * b.z, .w = a.w * b.w };    }    pub fn scale(v: Vec4, s: f32) Vec4 {        return .{ .x = v.x * s, .y = v.y * s, .z = v.z * s, .w = v.w * s };    }    pub fn negate(v: Vec4) Vec4 {        return .{ .x = -v.x, .y = -v.y, .z = -v.z, .w = -v.w };    }    pub fn dot(a: Vec4, b: Vec4) f32 {        return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;    }    pub fn lengthSq(v: Vec4) f32 {        return v.dot(v);    }    pub fn length(v: Vec4) f32 {        return @sqrt(v.lengthSq());    }    /// The unit vector along `v`, or null when its length is at most    /// `min_length` or is NaN.    pub fn normalized(v: Vec4, min_length: f32) ?Vec4 {        assert(min_length >= 0);        const len = v.length();        if (!(len > min_length)) return null;        return v.scale(1 / len);    }    /// `a` at `t = 0` and `b` at `t = 1`.    pub fn lerp(a: Vec4, b: Vec4, t: f32) Vec4 {        return a.add(b.sub(a).scale(t));    }    pub fn min(a: Vec4, b: Vec4) Vec4 {        return .{ .x = @min(a.x, b.x), .y = @min(a.y, b.y), .z = @min(a.z, b.z), .w = @min(a.w, b.w) };    }    pub fn max(a: Vec4, b: Vec4) Vec4 {        return .{ .x = @max(a.x, b.x), .y = @max(a.y, b.y), .z = @max(a.z, b.z), .w = @max(a.w, b.w) };    }    pub fn abs(v: Vec4) Vec4 {        return .{ .x = @abs(v.x), .y = @abs(v.y), .z = @abs(v.z), .w = @abs(v.w) };    }};

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

zig
pub const Vec4 = vector.Vec4;
Called byCallsNo direct callstest sourcelib.linear.src.affinetest: homogeneous matrix agrees with ...Mat4fromLinearTranslationtest sourcelib.linear.src.matrixtest: look-at places the eye at the o...private sourcelib.linear.src.testarithmeticDigesttest sourcelib.linear.src.vectortest: homogeneous vectors carry their...Vec4fromVec3
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.linear.src.matrixtest: identity matrices are the defau...test sourcelib.linear.src.matrixtest: inverse returns null for singul...test sourcelib.linear.src.matrixtest: inverse undoes an invertible ma...test sourcelib.linear.src.matrixtest: look-at places the eye at the o...test sourcelib.linear.src.matrixtest: orthographic maps its box onto ...+5 moreVec4init
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.linear.src.vectortest: lerp reaches both endpointsVec4lerp
Static calls · unresolved targets: 1 · external targets: 1.

Complete caller list for Vec4.init

10 direct callers.

Audit

Definitions21
Public names21
Members4
Version26.7.0
Revisiondaab053ee433