using System.Diagnostics; using System.Numerics; using System.Runtime.InteropServices; using ComputeSharp.Exceptions; namespace ComputeSharp { /// /// A that maps the HLSL type. /// [DebuggerDisplay("({X}, {Y}, {Z})")] [StructLayout(LayoutKind.Sequential, Size = sizeof(float) * 3)] public struct Float3 { /// /// Gets an value with all components set to 0. /// public static Float3 Zero => 0; /// /// Gets an value with all components set to 1. /// public static Float3 One => 1; /// /// Gets an value with the component set to 1, and the others to 0. /// public static Float3 UnitX => new(1, 0, 0); /// /// Gets an value with the component set to 1, and the others to 0. /// public static Float3 UnitY => new(0, 1, 0); /// /// Gets an value with the component set to 1, and the others to 0. /// public static Float3 UnitZ => new(0, 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. /// The value to assign to the third vector component. public Float3(float x, float y, float z) { X = x; Y = y; Z = z; } /// /// Gets or sets the value of the first vector component. /// public float X { get; set; } /// /// Gets or sets the value of the second vector component. /// public float Y { get; set; } /// /// Gets or sets the value of the third vector component. /// public float Z { get; set; } /// /// Gets or sets the value of the first color component. /// public float R { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(R)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(R)}"); } /// /// Gets or sets the value of the second color component. /// public float G { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(G)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(G)}"); } /// /// Gets or sets the value of the third color component. /// public float B { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(B)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(B)}"); } /// /// Gets or sets a specific component in the current instance. /// /// The index of the component to access. public float this[int i] { get => throw new InvalidExecutionContextException($"{nameof(Float3)}[int]"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}[int]"); } /// /// Gets an value with the value for all components. /// public Float2 XX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XX)}"); /// /// Gets or sets an value with the and values. /// public Float2 XY { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XY)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XY)}"); } /// /// Gets or sets an value with the and values. /// public Float2 XZ { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XZ)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XZ)}"); } /// /// Gets or sets an value with the and values. /// public Float2 YX { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YX)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YX)}"); } /// /// Gets an value with the value for all components. /// public Float2 YY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YY)}"); /// /// Gets or sets an value with the and values. /// public Float2 YZ { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YZ)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YZ)}"); } /// /// Gets or sets an value with the and values. /// public Float2 ZX { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZX)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZX)}"); } /// /// Gets or sets an value with the and values. /// public Float2 ZY { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZY)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZY)}"); } /// /// Gets an value with the value for all components. /// public Float2 ZZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZZ)}"); /// /// Gets an value with the value for all components. /// public Float2 RR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RR)}"); /// /// Gets or sets an value with the and values. /// public Float2 RG { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RG)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RG)}"); } /// /// Gets or sets an value with the and values. /// public Float2 RB { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RB)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RB)}"); } /// /// Gets or sets an value with the and values. /// public Float2 GR { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GR)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GR)}"); } /// /// Gets an value with the value for all components. /// public Float2 GG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GG)}"); /// /// Gets or sets an value with the and values. /// public Float2 GB { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GB)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GB)}"); } /// /// Gets or sets an value with the and values. /// public Float2 BR { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BR)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BR)}"); } /// /// Gets or sets an value with the and values. /// public Float2 BG { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BG)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BG)}"); } /// /// Gets an value with the value for all components. /// public Float2 BB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BB)}"); /// /// Gets an value with the value for all components. /// public Float3 XXX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XXX)}"); /// /// Gets an value with the , and values. /// public Float3 XXY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XXY)}"); /// /// Gets an value with the , and values. /// public Float3 XXZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XXZ)}"); /// /// Gets an value with the , and values. /// public Float3 XYX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XYX)}"); /// /// Gets an value with the , and values. /// public Float3 XYY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XYY)}"); /// /// Gets or sets an value with the , and values. /// public Float3 XYZ { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XYZ)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XYZ)}"); } /// /// Gets an value with the , and values. /// public Float3 XZX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XZX)}"); /// /// Gets or sets an value with the , and values. /// public Float3 XZY { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XZY)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XZY)}"); } /// /// Gets an value with the , and values. /// public Float3 XZZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XZZ)}"); /// /// Gets an value with the , and values. /// public Float3 YXX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YXX)}"); /// /// Gets an value with the , and values. /// public Float3 YXY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YXY)}"); /// /// Gets or sets an value with the , and values. /// public Float3 YXZ { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YXZ)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YXZ)}"); } /// /// Gets an value with the , and values. /// public Float3 YYX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YYX)}"); /// /// Gets an value with the value for all components. /// public Float3 YYY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YYY)}"); /// /// Gets an value with the , and values. /// public Float3 YYZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YYZ)}"); /// /// Gets or sets an value with the , and values. /// public Float3 YZX { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YZX)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YZX)}"); } /// /// Gets an value with the , and values. /// public Float3 YZY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YZY)}"); /// /// Gets an value with the , and values. /// public Float3 YZZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YZZ)}"); /// /// Gets an value with the , and values. /// public Float3 ZXX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZXX)}"); /// /// Gets or sets an value with the , and values. /// public Float3 ZXY { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZXY)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZXY)}"); } /// /// Gets an value with the , and values. /// public Float3 ZXZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZXZ)}"); /// /// Gets or sets an value with the , and values. /// public Float3 ZYX { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZYX)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZYX)}"); } /// /// Gets an value with the , and values. /// public Float3 ZYY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZYY)}"); /// /// Gets an value with the , and values. /// public Float3 ZYZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZYZ)}"); /// /// Gets an value with the , and values. /// public Float3 ZZX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZZX)}"); /// /// Gets an value with the , and values. /// public Float3 ZZY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZZY)}"); /// /// Gets an value with the value for all components. /// public Float3 ZZZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZZZ)}"); /// /// Gets an value with the value for all components. /// public Float3 RRR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RRR)}"); /// /// Gets an value with the , and values. /// public Float3 RRG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RRG)}"); /// /// Gets an value with the , and values. /// public Float3 RRB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RRB)}"); /// /// Gets an value with the , and values. /// public Float3 RGR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RGR)}"); /// /// Gets an value with the , and values. /// public Float3 RGG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RGG)}"); /// /// Gets or sets an value with the , and values. /// public Float3 RGB { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RGB)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RGB)}"); } /// /// Gets an value with the , and values. /// public Float3 RBR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RBR)}"); /// /// Gets or sets an value with the , and values. /// public Float3 RBG { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RBG)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RBG)}"); } /// /// Gets an value with the , and values. /// public Float3 RBB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RBB)}"); /// /// Gets an value with the , and values. /// public Float3 GRR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GRR)}"); /// /// Gets an value with the , and values. /// public Float3 GRG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GRG)}"); /// /// Gets or sets an value with the , and values. /// public Float3 GRB { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GRB)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GRB)}"); } /// /// Gets an value with the , and values. /// public Float3 GGR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GGR)}"); /// /// Gets an value with the value for all components. /// public Float3 GGG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GGG)}"); /// /// Gets an value with the , and values. /// public Float3 GGB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GGB)}"); /// /// Gets or sets an value with the , and values. /// public Float3 GBR { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GBR)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GBR)}"); } /// /// Gets an value with the , and values. /// public Float3 GBG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GBG)}"); /// /// Gets an value with the , and values. /// public Float3 GBB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GBB)}"); /// /// Gets an value with the , and values. /// public Float3 BRR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BRR)}"); /// /// Gets or sets an value with the , and values. /// public Float3 BRG { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BRG)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BRG)}"); } /// /// Gets an value with the , and values. /// public Float3 BRB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BRB)}"); /// /// Gets or sets an value with the , and values. /// public Float3 BGR { get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BGR)}"); set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BGR)}"); } /// /// Gets an value with the , and values. /// public Float3 BGG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BGG)}"); /// /// Gets an value with the , and values. /// public Float3 BGB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BGB)}"); /// /// Gets an value with the , and values. /// public Float3 BBR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BBR)}"); /// /// Gets an value with the , and values. /// public Float3 BBG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BBG)}"); /// /// Gets an value with the value for all components. /// public Float3 BBB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BBB)}"); /// /// 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 Float3(float x) => new(x, x, x); /// /// Casts a value to a one. /// /// The input value to cast. public static unsafe implicit operator Vector3(Float3 xyz) => *(Vector3*)&xyz; /// /// Casts a value to a one. /// /// The input value to cast. public static unsafe implicit operator Float3(Vector3 xyz) => *(Float3*)&xyz; /// /// Casts a value to a one. /// /// The input value to cast. public static implicit operator Double3(Float3 xyz) => throw new InvalidExecutionContextException($"{nameof(Float3)}.({nameof(Double3)})"); /// /// Casts a value to a one. /// /// The input value to cast. public static explicit operator Int3(Float3 xyz) => throw new InvalidExecutionContextException($"{nameof(Float3)}.({nameof(Int3)})"); /// /// Casts a value to a one. /// /// The input value to cast. public static explicit operator UInt3(Float3 xyz) => throw new InvalidExecutionContextException($"{nameof(Float3)}.({nameof(UInt3)})"); /// /// Sums two values. /// /// The first value to sum. /// The second value to sum. public static Float3 operator +(Float3 left, Float3 right) => throw new InvalidExecutionContextException($"{nameof(Float3)}.+"); /// /// Divides two values. /// /// The first value to divide. /// The second value to divide. public static Float3 operator /(Float3 left, Float3 right) => throw new InvalidExecutionContextException($"{nameof(Float3)}./"); /// /// Multiplies two values. /// /// The first value to multiply. /// The second value to multiply. public static Float3 operator *(Float3 left, Float3 right) => throw new InvalidExecutionContextException($"{nameof(Float3)}.*"); /// /// Subtracts two values. /// /// The first value to subtract. /// The second value to subtract. public static Float3 operator -(Float3 left, Float3 right) => throw new InvalidExecutionContextException($"{nameof(Float3)}.-"); } }