Move FloatExtensions and VectorExtensions to .Core

このコミットが含まれているのは:
Sergio Pedri committed 2023-12-09 19:28:47 +01:00
1 親 317a537e10
コミット 3e25eeb8b7
2ファイル変更

検索条件に一致するファイルはありません

+71
ファイルの表示
@@ -0,0 +1,71 @@
using System;
using System.Numerics;
using System.Runtime.InteropServices;
namespace ComputeSharp;
/// <summary>
/// A <see langword="class"/> that contains extension methods for the <see cref="Float2"/>, <see cref="Float3"/> and <see cref="Float4"/> types.
/// </summary>
public static class FloatExtensions
{
/// <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>
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"/>.
/// </summary>
/// <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>
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"/>.
/// </summary>
/// <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>
public static Span<Vector3> AsVector3(this Span<Float3> span)
{
return MemoryMarshal.Cast<Float3, Vector3>(span);
}
/// <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>
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"/>.
/// </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="Vector4"/>, mapping the original <see cref="Span{T}"/>.</returns>
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>
public static ReadOnlySpan<Vector4> AsVector4(this ReadOnlySpan<Float4> span)
{
return MemoryMarshal.Cast<Float4, Vector4>(span);
}
}
+71
ファイルの表示
@@ -0,0 +1,71 @@
using System;
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"/> <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>
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"/>.
/// </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>
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"/>.
/// </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>
public static Span<Float3> AsFloat3(this Span<Vector3> span)
{
return MemoryMarshal.Cast<Vector3, Float3>(span);
}
/// <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>
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"/>.
/// </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>
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>
public static ReadOnlySpan<Float4> AsFloat4(this ReadOnlySpan<Vector4> span)
{
return MemoryMarshal.Cast<Vector4, Float4>(span);
}
}