using System.Diagnostics; using System.Runtime.InteropServices; using ComputeSharp.Exceptions; namespace ComputeSharp { /// /// A that maps the HLSL type. /// [DebuggerDisplay("({X}, {Y})")] [StructLayout(LayoutKind.Sequential, Size = sizeof(double) * 2)] public partial struct Double2 { /// /// Gets an value with all components set to 0. /// public static Double2 Zero => 0; /// /// Gets an value with all components set to 1. /// public static Double2 One => 1; /// /// Gets an value with the component set to 1, and the others to 0. /// public static Double2 UnitX => new(1, 0); /// /// Gets an value with the component set to 1, and the others to 0. /// public static Double2 UnitY => new(0, 1); /// /// Creates a new instance with the specified parameters. /// /// The value to assign to the first vector component. /// The value to assign to the second vector component. public Double2(double x, double y) { X = x; Y = y; } /// /// Gets or sets the value of the first vector component. /// public double X { get; set; } /// /// Gets or sets the value of the second vector component. /// public double Y { get; set; } /// /// Gets or sets the value of the first color component. /// public double R { get => throw new InvalidExecutionContextException($"{nameof(Double2)}.{nameof(R)}"); set => throw new InvalidExecutionContextException($"{nameof(Double2)}.{nameof(R)}"); } /// /// Gets or sets the value of the second color component. /// public double G { get => throw new InvalidExecutionContextException($"{nameof(Double2)}.{nameof(G)}"); set => throw new InvalidExecutionContextException($"{nameof(Double2)}.{nameof(G)}"); } /// /// Gets or sets a specific component in the current instance. /// /// The index of the component to access. public double this[int i] { get => throw new InvalidExecutionContextException($"{nameof(Double2)}[int]"); set => throw new InvalidExecutionContextException($"{nameof(Double2)}[int]"); } /// /// Creates a new value with the same value for all its components. /// /// The value to use for the components of the new instance. public static implicit operator Double2(double x) => new(x, x); /// /// Casts a value to a one. /// /// The input value to cast. public static explicit operator Int2(Double2 xy) => throw new InvalidExecutionContextException($"{nameof(Double2)}.({nameof(Int2)})"); /// /// Casts a value to a one. /// /// The input value to cast. public static explicit operator UInt2(Double2 xy) => throw new InvalidExecutionContextException($"{nameof(Double2)}.({nameof(UInt2)})"); /// /// Casts a value to a one. /// /// The input value to cast. public static explicit operator Float2(Double2 xy) => throw new InvalidExecutionContextException($"{nameof(Double2)}.({nameof(Float2)})"); /// /// Negates a value. /// /// The value to negate. public static Double2 operator -(Double2 xy) => throw new InvalidExecutionContextException($"{nameof(Double2)}.-"); /// /// Sums two values. /// /// The first value to sum. /// The second value to sum. public static Double2 operator +(Double2 left, Double2 right) => throw new InvalidExecutionContextException($"{nameof(Double2)}.+"); /// /// Divides two values. /// /// The first value to divide. /// The second value to divide. public static Double2 operator /(Double2 left, Double2 right) => throw new InvalidExecutionContextException($"{nameof(Double2)}./"); /// /// Multiplies two values. /// /// The first value to multiply. /// The second value to multiply. public static Double2 operator *(Double2 left, Double2 right) => throw new InvalidExecutionContextException($"{nameof(Double2)}.*"); /// /// Subtracts two values. /// /// The first value to subtract. /// The second value to subtract. public static Double2 operator -(Double2 left, Double2 right) => throw new InvalidExecutionContextException($"{nameof(Double2)}.-"); } }