Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
return new vectors from extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
chirpxiv committed Apr 16, 2023
1 parent c3e1ee5 commit 99b34d0
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions PalettePlus/Extensions/Vector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,26 @@

namespace PalettePlus.Extensions {
internal static class VectorExtensions {
internal static void RgbSqrt(this Vector3 vec) {
vec.X = (float)Math.Sqrt(vec.X);
vec.Y = (float)Math.Sqrt(vec.Y);
vec.Z = (float)Math.Sqrt(vec.Z);
}

internal static void RgbSqrt(this Vector4 vec) {
vec.X = (float)Math.Sqrt(vec.X);
vec.Y = (float)Math.Sqrt(vec.Y);
vec.Z = (float)Math.Sqrt(vec.Z);
}
internal static Vector3 RgbSqrt(this Vector3 vec) => new(
(float)Math.Sqrt(vec.X),
(float)Math.Sqrt(vec.Y),
(float)Math.Sqrt(vec.Z)
);

internal static void RgbPow2(this Vector3 vec) {
vec.X *= vec.X;
vec.Y *= vec.Y;
vec.Z *= vec.Z;
}

internal static void RgbPow2(this Vector4 vec) {
vec.X *= vec.X;
vec.Y *= vec.Y;
vec.Z *= vec.Z;
}
internal static Vector4 RgbSqrt(this Vector4 vec) => new(
(float)Math.Sqrt(vec.X),
(float)Math.Sqrt(vec.Y),
(float)Math.Sqrt(vec.Z),
vec.W
);

internal static Vector3 RgbPow2(this Vector3 vec) => vec * vec;

internal static Vector4 RgbPow2(this Vector4 vec) => new(
vec.X * vec.X,
vec.Y * vec.Y,
vec.Z * vec.Z,
vec.W
);
}
}

0 comments on commit 99b34d0

Please sign in to comment.