tiny.linear.Affine
Defined in tiny.linear.
API (11)
Actions
Public operations.
fromScaleRotationTranslation: Scale, then rotate by the unit quaternionrotation, then translate.fromTranslationinverse: The inverse transform, or null when the linear part is singular.mul:a b: applyingb, thena.normalMatrix: The matrix that carries surface normals througha, or null when the linear part is singular.toMat4transformPointtransformVector
Types and contracts
Public types and contracts.
Fields and members
Public fields and members.
Source
Source: lib/linear/src/affine.zig:15
zig
pub const Affine = extern struct { linear: Mat3 = .{}, translation: Vec3 = .{}, pub const identity: Affine = .{}; pub fn fromTranslation(translation: Vec3) Affine { return .{ .translation = translation }; } /// Scale, then rotate by the unit quaternion `rotation`, then translate. pub fn fromScaleRotationTranslation(s: Vec3, rotation: Quat, translation: Vec3) Affine { return .{ .linear = Mat3.fromQuat(rotation).mul(Mat3.fromScale(s)), .translation = translation, }; } /// `a b`: applying `b`, then `a`. pub fn mul(a: Affine, b: Affine) Affine { return .{ .linear = a.linear.mul(b.linear), .translation = a.transformPoint(b.translation), }; } pub fn transformPoint(a: Affine, p: Vec3) Vec3 { return a.linear.mulVec(p).add(a.translation); } pub fn transformVector(a: Affine, v: Vec3) Vec3 { return a.linear.mulVec(v); } /// The matrix that carries surface normals through `a`, or null when the /// linear part is singular. Transformed normals keep their direction but /// not their length. pub fn normalMatrix(a: Affine) ?Mat3 { return a.linear.inverseTranspose(); } /// The inverse transform, or null when the linear part is singular. pub fn inverse(a: Affine) ?Affine { const linear = a.linear.inverse() orelse return null; return .{ .linear = linear, .translation = linear.mulVec(a.translation).negate(), }; } pub fn toMat4(a: Affine) Mat4 { return Mat4.fromLinearTranslation(a.linear, a.translation); }};Source: lib/linear/src/root.zig:14
zig
pub const Affine = affine.Affine;Audit
| Definitions | 10 |
|---|---|
| Public names | 10 |
| Members | 2 |
| Version | 26.7.0 |
| Revision | daab053ee433 |