using System;
using System.Collections.Generic;
namespace NvAPIWrapper.Display
{
///
/// Represents a XYUVRQ scan-out warping vortex
///
public class XYUVRQVortex : IEquatable
{
///
/// Creates a new instance of .
///
/// The target view port mesh horizontal coordinate
/// The target view port mesh vertical coordinate
/// The desktop view port texture horizontal coordinate
/// The desktop view port texture vertical coordinate
/// The 3D warp perspective R factor
/// The 3D warp perspective Q factor
// ReSharper disable once TooManyDependencies
public XYUVRQVortex(int x, int y, int u, int v, float r, float q)
{
X = x;
Y = y;
U = u;
V = v;
R = r;
Q = q;
}
///
/// 3D warp perspective Q factor
///
public float Q { get; }
///
/// 3D warp perspective R factor
///
public float R { get; }
///
/// Desktop view port texture horizontal coordinate
///
public int U { get; }
///
/// Desktop view port texture vertical coordinate
///
public int V { get; }
///
/// Target view port mesh horizontal coordinate
///
public int X { get; }
///
/// Target view port mesh vertical coordinate
///
public int Y { get; }
///
public bool Equals(XYUVRQVortex other)
{
if (other == null)
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return Math.Abs(Q - other.Q) < 0.0001 &&
Math.Abs(R - other.R) < 0.0001 &&
U == other.U &&
V == other.V &&
X == other.X &&
Y == other.Y;
}
///
/// Parses an array of floats and returns the corresponding s.
///
/// The array of float representing one or more s.
/// Instances of .
public static IEnumerable FromFloatArray(float[] floats)
{
for (var i = 0; i + 6 <= floats.Length; i += 6)
{
yield return new XYUVRQVortex(
(int) floats[i],
(int) floats[i + 1],
(int) floats[i + 2],
(int) floats[i + 3],
floats[i + 4],
floats[i + 5]
);
}
}
///
/// Compares two instance of for equality.
///
/// The first instance.
/// The second instance.
/// if both instances are equal, otherwise
public static bool operator ==(XYUVRQVortex left, XYUVRQVortex right)
{
return Equals(left, right) || left?.Equals(right) == true;
}
///
/// Compares two instance of for in-equality.
///
/// The first instance.
/// The second instance.
/// if both instances are not equal, otherwise
public static bool operator !=(XYUVRQVortex left, XYUVRQVortex right)
{
return !(left == right);
}
///
public override bool Equals(object obj)
{
if (obj == null)
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return Equals(obj as XYUVRQVortex);
}
///
public override int GetHashCode()
{
unchecked
{
var hashCode = Q.GetHashCode();
hashCode = (hashCode * 397) ^ R.GetHashCode();
hashCode = (hashCode * 397) ^ U;
hashCode = (hashCode * 397) ^ V;
hashCode = (hashCode * 397) ^ X;
hashCode = (hashCode * 397) ^ Y;
return hashCode;
}
}
///
/// Returns this instance of as a float array.
///
/// An array of float values representing this instance of .
public float[] AsFloatArray()
{
return new[] {X, Y, U, V, R, Q};
}
}
}