Skip to content

Commit

Permalink
Addded matrix.diag() method
Browse files Browse the repository at this point in the history
  • Loading branch information
ltmx committed Sep 27, 2023
1 parent ea055a3 commit 868d045
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Runtime/mathx.matrix.extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ public static partial class mathx
/// <inheritdoc cref="transpose(float4x4)" />
[MethodImpl(IL)] public static float2x2 transpose(this float2x2 m1) => math.transpose(m1);



/// Creates a 2x2 matrix with the scale vector as the diagonal elements. The remaining spots zeros
[MethodImpl(IL)] public static float2x2 diag(float2 scale) => new(scale.x, 0, 0, scale.y);
/// Creates a 2x2 matrix with the scale vector as the diagonal elements. The remaining spots zeros
[MethodImpl(IL)] public static float3x3 diag(float3 scale) => new(scale.x, 0, 0, 0, scale.y, 0, 0, 0, scale.z);
/// Creates a 2x2 matrix with the scale vector as the diagonal elements. The remaining spots zeros
[MethodImpl(IL)] public static float4x4 diag(float4 scale) => new(scale.x, 0, 0, 0, 0, scale.y, 0, 0, 0, 0, scale.z, 0, 0, 0, 0, scale.w);
}
}

0 comments on commit 868d045

Please sign in to comment.