Refactor Float/Vector extensions
このコミットが含まれているのは:
1 親
00fc0f3b12
コミット
0745fb50cf
3ファイル変更
+85
-95
検索条件に一致するファイルはありません
+42
-47
@@ -1,8 +1,9 @@
|
||||
using System.Diagnostics.Contracts;
|
||||
using ComputeSharp;
|
||||
using static System.Runtime.InteropServices.MemoryMarshal;
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System.Numerics;
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains extension methods for the <see cref="Float2"/>, <see cref="Float3"/> and <see cref="Float4"/> types.
|
||||
@@ -10,12 +11,15 @@ namespace System.Numerics;
|
||||
public static class FloatExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Float2"/> array into a <see cref="Span{T}"/> with items of type <see cref="Vector2"/>.
|
||||
/// Converts a <see cref="Float2"/> <see cref="Span{T}"/> into a <see cref="Span{T}"/> with items of type <see cref="Vector2"/>.
|
||||
/// </summary>
|
||||
/// <param name="array">The input <see cref="Float2"/> array.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Vector2"/>, mapping the original array.</returns>
|
||||
/// <param name="span">The input <see cref="Float2"/> <see cref="Span{T}"/>.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Vector2"/>, mapping the original <see cref="Span{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static Span<Vector2> AsVector2Span(this Float2[] array) => Cast<Float2, Vector2>(array);
|
||||
public static Span<Vector2> AsVector2(this Span<Float2> span)
|
||||
{
|
||||
return MemoryMarshal.Cast<Float2, Vector2>(span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Float2"/> <see cref="ReadOnlySpan{T}"/> into a <see cref="ReadOnlySpan{T}"/> with items of type <see cref="Vector2"/>.
|
||||
@@ -23,31 +27,10 @@ public static class FloatExtensions
|
||||
/// <param name="span">The input <see cref="Float2"/> <see cref="ReadOnlySpan{T}"/>.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Vector2"/>, mapping the original <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static ReadOnlySpan<Vector2> AsVector2Span(this ReadOnlySpan<Float2> span) => Cast<Float2, Vector2>(span);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Float2"/> <see cref="Span{T}"/> into a <see cref="Span{T}"/> with items of type <see cref="Vector2"/>.
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Float2"/> <see cref="Span{T}"/>.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Vector2"/>, mapping the original <see cref="Span{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static Span<Vector2> AsVector2Span(this Span<Float2> span) => Cast<Float2, Vector2>(span);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Float3"/> array into a <see cref="Span{T}"/> with items of type <see cref="Vector3"/>.
|
||||
/// </summary>
|
||||
/// <param name="array">The input <see cref="Float3"/> array.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Vector3"/>, mapping the original array.</returns>
|
||||
[Pure]
|
||||
public static Span<Vector3> AsVector3Span(this Float3[] array) => Cast<Float3, Vector3>(array);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Float3"/> <see cref="ReadOnlySpan{T}"/> into a <see cref="ReadOnlySpan{T}"/> with items of type <see cref="Vector3"/>.
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Float3"/> <see cref="ReadOnlySpan{T}"/>.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Vector3"/>, mapping the original <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static ReadOnlySpan<Vector3> AsVector3Span(this ReadOnlySpan<Float3> span) => Cast<Float3, Vector3>(span);
|
||||
public static ReadOnlySpan<Vector2> AsVector2(this ReadOnlySpan<Float2> span)
|
||||
{
|
||||
return MemoryMarshal.Cast<Float2, Vector2>(span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Float3"/> <see cref="Span{T}"/> into a <see cref="Span{T}"/> with items of type <see cref="Vector3"/>.
|
||||
@@ -55,23 +38,21 @@ public static class FloatExtensions
|
||||
/// <param name="span">The input <see cref="Float3"/> <see cref="Span{T}"/>.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Vector3"/>, mapping the original <see cref="Span{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static Span<Vector3> AsVector3Span(this Span<Float3> span) => Cast<Float3, Vector3>(span);
|
||||
public static Span<Vector3> AsVector3(this Span<Float3> span)
|
||||
{
|
||||
return MemoryMarshal.Cast<Float3, Vector3>(span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Float4"/> array into a <see cref="Span{T}"/> with items of type <see cref="Vector4"/>.
|
||||
/// Converts a <see cref="Float3"/> <see cref="ReadOnlySpan{T}"/> into a <see cref="ReadOnlySpan{T}"/> with items of type <see cref="Vector3"/>.
|
||||
/// </summary>
|
||||
/// <param name="array">The input <see cref="Float4"/> array.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Vector4"/>, mapping the original array.</returns>
|
||||
/// <param name="span">The input <see cref="Float3"/> <see cref="ReadOnlySpan{T}"/>.</param>
|
||||
/// <returns>A <see cref="Span{T}"/> with items of type <see cref="Vector3"/>, mapping the original <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static Span<Vector4> AsVector4Span(this Float4[] array) => Cast<Float4, Vector4>(array);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector4"/> <see cref="ReadOnlySpan{T}"/> into a <see cref="ReadOnlySpan{T}"/> with items of type <see cref="Vector4"/>.
|
||||
/// </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="Vector4"/>, mapping the original <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static ReadOnlySpan<Vector4> AsVector4Span(this ReadOnlySpan<Float4> span) => Cast<Float4, Vector4>(span);
|
||||
public static ReadOnlySpan<Vector3> AsVector3(this ReadOnlySpan<Float3> span)
|
||||
{
|
||||
return MemoryMarshal.Cast<Float3, Vector3>(span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector4"/> <see cref="Span{T}"/> into a <see cref="Span{T}"/> with items of type <see cref="Vector4"/>.
|
||||
@@ -79,5 +60,19 @@ public static class FloatExtensions
|
||||
/// <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="Vector4"/>, mapping the original <see cref="Span{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static Span<Vector4> AsVector4Span(this Span<Float4> span) => Cast<Float4, Vector4>(span);
|
||||
public static Span<Vector4> AsVector4(this Span<Float4> span)
|
||||
{
|
||||
return MemoryMarshal.Cast<Float4, Vector4>(span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector4"/> <see cref="ReadOnlySpan{T}"/> into a <see cref="ReadOnlySpan{T}"/> with items of type <see cref="Vector4"/>.
|
||||
/// </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="Vector4"/>, mapping the original <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static ReadOnlySpan<Vector4> AsVector4(this ReadOnlySpan<Float4> span)
|
||||
{
|
||||
return MemoryMarshal.Cast<Float4, Vector4>(span);
|
||||
}
|
||||
}
|
||||
+42
-47
@@ -1,8 +1,9 @@
|
||||
using System.Diagnostics.Contracts;
|
||||
using ComputeSharp;
|
||||
using static System.Runtime.InteropServices.MemoryMarshal;
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System.Numerics;
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains extension methods for the <see cref="Vector2"/>, <see cref="Vector3"/> and <see cref="Vector4"/> types.
|
||||
@@ -10,12 +11,15 @@ namespace System.Numerics;
|
||||
public static class VectorExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector2"/> array into a <see cref="Span{T}"/> with items of type <see cref="Float2"/>.
|
||||
/// 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="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>
|
||||
/// <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 Vector2[] array) => Cast<Vector2, Float2>(array);
|
||||
public static Span<Float2> AsFloat2(this Span<Vector2> span)
|
||||
{
|
||||
return MemoryMarshal.Cast<Vector2, Float2>(span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector2"/> <see cref="ReadOnlySpan{T}"/> into a <see cref="ReadOnlySpan{T}"/> with items of type <see cref="Float2"/>.
|
||||
@@ -23,31 +27,10 @@ public static class VectorExtensions
|
||||
/// <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);
|
||||
public static ReadOnlySpan<Float2> AsFloat2(this ReadOnlySpan<Vector2> span)
|
||||
{
|
||||
return MemoryMarshal.Cast<Vector2, Float2>(span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector3"/> <see cref="Span{T}"/> into a <see cref="Span{T}"/> with items of type <see cref="Float3"/>.
|
||||
@@ -55,23 +38,21 @@ public static class VectorExtensions
|
||||
/// <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);
|
||||
public static Span<Float3> AsFloat3(this Span<Vector3> span)
|
||||
{
|
||||
return 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"/>.
|
||||
/// 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="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>
|
||||
/// <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 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);
|
||||
public static ReadOnlySpan<Float3> AsFloat3(this ReadOnlySpan<Vector3> span)
|
||||
{
|
||||
return MemoryMarshal.Cast<Vector3, Float3>(span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector4"/> <see cref="Span{T}"/> into a <see cref="Span{T}"/> with items of type <see cref="Float4"/>.
|
||||
@@ -79,5 +60,19 @@ public static class VectorExtensions
|
||||
/// <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);
|
||||
public static Span<Float4> AsFloat4(this Span<Vector4> span)
|
||||
{
|
||||
return MemoryMarshal.Cast<Vector4, Float4>(span);
|
||||
}
|
||||
|
||||
/// <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> AsFloat4(this ReadOnlySpan<Vector4> span)
|
||||
{
|
||||
return MemoryMarshal.Cast<Vector4, Float4>(span);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public sealed class UnsupportedDoubleOperationsException : InvalidOperationExcep
|
||||
/// Creates a new <see cref="UnsupportedDoubleOperationsException"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public UnsupportedDoubleOperationsException(string message)
|
||||
private UnsupportedDoubleOperationsException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする