Code refactoring to the public extensions
このコミットが含まれているのは:
1 親
ecaa794a9e
コミット
0a7070e690
5ファイル変更
+90
-67
検索条件に一致するファイルはありません
@@ -1,61 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ComputeSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains extension methods for the <see cref="Vector2"/>, <see cref="Vector3"/> and <see cref="Vector4"/> types
|
||||
/// </summary>
|
||||
public static class VectorExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector2"/> array into a <see cref="Span{T}"/> with items of type <see cref="Float2"/>
|
||||
/// </summary>
|
||||
/// <param name="array">The input <see cref="Vector2"/> array</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float2"/>, mapping the original array</returns>
|
||||
[Pure]
|
||||
public static Span<Float2> AsFloat2Span(this Vector2[] array) => MemoryMarshal.Cast<Vector2, Float2>(array);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector2"/> <see cref="Span{T}"/> into a <see cref="Span{T}"/> with items of type <see cref="Float2"/>
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Vector2"/> <see cref="Span{T}"/></param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float2"/>, mapping the original <see cref="Span{T}"/></returns>
|
||||
[Pure]
|
||||
public static Span<Float2> AsFloat2Span(this Span<Vector2> span) => MemoryMarshal.Cast<Vector2, Float2>(span);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector3"/> array into a <see cref="Span{T}"/> with items of type <see cref="Float3"/>
|
||||
/// </summary>
|
||||
/// <param name="array">The input <see cref="Vector3"/> array</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float3"/>, mapping the original array</returns>
|
||||
[Pure]
|
||||
public static Span<Float3> AsFloat3Span(this Vector3[] array) => MemoryMarshal.Cast<Vector3, Float3>(array);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector3"/> <see cref="Span{T}"/> into a <see cref="Span{T}"/> with items of type <see cref="Float3"/>
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Vector3"/> <see cref="Span{T}"/></param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float3"/>, mapping the original <see cref="Span{T}"/></returns>
|
||||
[Pure]
|
||||
public static Span<Float3> AsFloat3Span(this Span<Vector3> span) => MemoryMarshal.Cast<Vector3, Float3>(span);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector4"/> array into a <see cref="Span{T}"/> with items of type <see cref="Float4"/>
|
||||
/// </summary>
|
||||
/// <param name="array">The input <see cref="Vector4"/> array</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float4"/>, mapping the original array</returns>
|
||||
[Pure]
|
||||
public static Span<Float4> AsFloat4Span(this Vector4[] array) => MemoryMarshal.Cast<Vector4, Float4>(array);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector4"/> <see cref="Span{T}"/> into a <see cref="Span{T}"/> with items of type <see cref="Float4"/>
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Vector4"/> <see cref="Span{T}"/></param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float4"/>, mapping the original <see cref="Span{T}"/></returns>
|
||||
[Pure]
|
||||
public static Span<Float4> AsFloat4Span(this Span<Vector4> span) => MemoryMarshal.Cast<Vector4, Float4>(span);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using System.Diagnostics.Contracts;
|
||||
using ComputeSharp;
|
||||
using static System.Runtime.InteropServices.MemoryMarshal;
|
||||
|
||||
namespace System.Numerics
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains extension methods for the <see cref="Vector2"/>, <see cref="Vector3"/> and <see cref="Vector4"/> types.
|
||||
/// </summary>
|
||||
public static class VectorExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector2"/> array into a <see cref="Span{T}"/> with items of type <see cref="Float2"/>.
|
||||
/// </summary>
|
||||
/// <param name="array">The input <see cref="Vector2"/> array.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float2"/>, mapping the original array.</returns>
|
||||
[Pure]
|
||||
public static Span<Float2> AsFloat2Span(this Vector2[] array) => Cast<Vector2, Float2>(array);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector2"/> <see cref="ReadOnlySpan{T}"/> into a <see cref="ReadOnlySpan{T}"/> with items of type <see cref="Float2"/>
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Vector2"/> <see cref="ReadOnlySpan{T}"/>.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float2"/>, mapping the original <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static ReadOnlySpan<Float2> AsFloat2Span(this ReadOnlySpan<Vector2> span) => Cast<Vector2, Float2>(span);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector2"/> <see cref="Span{T}"/> into a <see cref="Span{T}"/> with items of type <see cref="Float2"/>.
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Vector2"/> <see cref="Span{T}"/>.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float2"/>, mapping the original <see cref="Span{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static Span<Float2> AsFloat2Span(this Span<Vector2> span) => Cast<Vector2, Float2>(span);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector3"/> array into a <see cref="Span{T}"/> with items of type <see cref="Float3"/>.
|
||||
/// </summary>
|
||||
/// <param name="array">The input <see cref="Vector3"/> array.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float3"/>, mapping the original array.</returns>
|
||||
[Pure]
|
||||
public static Span<Float3> AsFloat3Span(this Vector3[] array) => Cast<Vector3, Float3>(array);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector3"/> <see cref="ReadOnlySpan{T}"/> into a <see cref="ReadOnlySpan{T}"/> with items of type <see cref="Float3"/>.
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Vector3"/> <see cref="ReadOnlySpan{T}"/>.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float3"/>, mapping the original <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static ReadOnlySpan<Float3> AsFloat3Span(this ReadOnlySpan<Vector3> span) => Cast<Vector3, Float3>(span);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector3"/> <see cref="Span{T}"/> into a <see cref="Span{T}"/> with items of type <see cref="Float3"/>.
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Vector3"/> <see cref="Span{T}"/>.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float3"/>, mapping the original <see cref="Span{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static Span<Float3> AsFloat3Span(this Span<Vector3> span) => Cast<Vector3, Float3>(span);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector4"/> array into a <see cref="Span{T}"/> with items of type <see cref="Float4"/>.
|
||||
/// </summary>
|
||||
/// <param name="array">The input <see cref="Vector4"/> array.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float4"/>, mapping the original array.</returns>
|
||||
[Pure]
|
||||
public static Span<Float4> AsFloat4Span(this Vector4[] array) => Cast<Vector4, Float4>(array);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector4"/> <see cref="ReadOnlySpan{T}"/> into a <see cref="ReadOnlySpan{T}"/> with items of type <see cref="Float4"/>.
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Vector4"/> <see cref="ReadOnlySpan{T}"/>.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float4"/>, mapping the original <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static ReadOnlySpan<Float4> AsFloat4Span(this ReadOnlySpan<Vector4> span) => Cast<Vector4, Float4>(span);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector4"/> <see cref="Span{T}"/> into a <see cref="Span{T}"/> with items of type <see cref="Float4"/>.
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Vector4"/> <see cref="Span{T}"/>.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Float4"/>, mapping the original <see cref="Span{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static Span<Float4> AsFloat4Span(this Span<Vector4> span) => Cast<Vector4, Float4>(span);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ namespace Windows.Foundation
|
||||
/// <returns>A <see cref="Vector2"/> value representing the input <see cref="Point"/></returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector2 ToVector2(this in Point value) => new Vector2((float)value.X, (float)value.Y);
|
||||
public static Vector2 ToVector2(this Point value) => new((float)value.X, (float)value.Y);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector2"/> value to a <see cref="Point"/>
|
||||
@@ -25,6 +25,6 @@ namespace Windows.Foundation
|
||||
/// <returns>A <see cref="Point"/> value representing the input <see cref="Vector2"/></returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Point ToPoint(this in Vector2 value) => new Point(value.X, value.Y);
|
||||
public static Point ToPoint(this Vector2 value) => new(value.X, value.Y);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace Windows.Foundation
|
||||
/// <remarks>The input <see cref="Rect"/> is read in the following order: <see cref="Rect.Left"/>, <see cref="Rect.Top"/>, <see cref="Rect.Right"/>, <see cref="Rect.Bottom"/></remarks>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector4 ToVector2(this in Rect value) => new Vector4((float)value.Left, (float)value.Top, (float)value.Right, (float)value.Bottom);
|
||||
public static Vector4 ToVector2(this Rect value) => new((float)value.Left, (float)value.Top, (float)value.Right, (float)value.Bottom);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector2"/> value to a <see cref="Rect"/>
|
||||
@@ -27,6 +27,6 @@ namespace Windows.Foundation
|
||||
/// <remarks>The input <see cref="Vector4"/> is assigned in the following order: <see cref="Rect.Left"/>, <see cref="Rect.Top"/>, <see cref="Rect.Right"/>, <see cref="Rect.Bottom"/></remarks>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Rect ToPoint(this in Vector4 value) => new Rect(value.X, value.Y, value.Z, value.W);
|
||||
public static Rect ToPoint(this Vector4 value) => new(value.X, value.Y, value.Z, value.W);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace Windows.Foundation
|
||||
/// <remarks>The input <see cref="Size"/> is read in the following order: <see cref="Size.Width"/>, <see cref="Size.Height"/></remarks>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector2 ToVector2(this in Size value) => new Vector2((float)value.Width, (float)value.Height);
|
||||
public static Vector2 ToVector2(this Size value) => new((float)value.Width, (float)value.Height);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector2"/> value to a <see cref="Size"/>
|
||||
@@ -27,6 +27,6 @@ namespace Windows.Foundation
|
||||
/// <remarks>The input <see cref="Size"/> is assigned in the following order: <see cref="Size.Width"/>, <see cref="Size.Height"/></remarks>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Size ToPoint(this in Vector2 value) => new Size(value.X, value.Y);
|
||||
public static Size ToPoint(this Vector2 value) => new(value.X, value.Y);
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする