mirror of
https://github.com/ZuneDev/Xune.git
synced 2026-07-27 13:13:10 -07:00
136 lines
5.0 KiB
C#
136 lines
5.0 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: Microsoft.Iris.Render.Vector4
|
|
// Assembly: UIX.RenderApi, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
|
// MVID: D47658B8-A8EA-43D6-8837-ECE823BFFFC1
|
|
// Assembly location: C:\Program Files\Zune\UIX.RenderApi.dll
|
|
|
|
using Microsoft.Iris.Render.Internal;
|
|
using System;
|
|
using System.Text;
|
|
|
|
namespace Microsoft.Iris.Render
|
|
{
|
|
[Serializable]
|
|
public struct Vector4
|
|
{
|
|
private float m_x;
|
|
private float m_y;
|
|
private float m_z;
|
|
private float m_w;
|
|
public static readonly Vector4 Zero = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
|
|
public static readonly Vector4 UnitVector = new Vector4(1f, 1f, 1f, 1f);
|
|
|
|
public Vector4(float x, float y, float z, float w)
|
|
{
|
|
this.m_x = x;
|
|
this.m_y = y;
|
|
this.m_z = z;
|
|
this.m_w = w;
|
|
}
|
|
|
|
internal Vector4(double x, double y, double z, double w)
|
|
: this((float)x, (float)y, (float)z, (float)w)
|
|
{
|
|
}
|
|
|
|
public float X
|
|
{
|
|
get => this.m_x;
|
|
set => this.m_x = value;
|
|
}
|
|
|
|
public float Y
|
|
{
|
|
get => this.m_y;
|
|
set => this.m_y = value;
|
|
}
|
|
|
|
public float Z
|
|
{
|
|
get => this.m_z;
|
|
set => this.m_z = value;
|
|
}
|
|
|
|
public float W
|
|
{
|
|
get => this.m_w;
|
|
set => this.m_w = value;
|
|
}
|
|
|
|
public static Vector4 operator +(Vector4 left, Vector4 right) => new Vector4(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
|
|
|
|
public static Vector4 Add(Vector4 left, Vector4 right) => left + right;
|
|
|
|
public static Vector4 operator -(Vector4 left, Vector4 right) => new Vector4(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
|
|
|
|
public static Vector4 operator -(Vector4 left) => new Vector4(-left.X, -left.Y, -left.Z, -left.W);
|
|
|
|
public static Vector4 Subtract(Vector4 left, Vector4 right) => left - right;
|
|
|
|
public static Vector4 operator *(Vector4 left, Vector4 right) => new Vector4(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W);
|
|
|
|
public static Vector4 Multiply(Vector4 left, Vector4 right) => left * right;
|
|
|
|
public static Vector4 operator *(Vector4 vector, float scalar) => new Vector4(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar);
|
|
|
|
public static Vector4 Multiply(Vector4 vector, float scalar) => vector * scalar;
|
|
|
|
public static Vector4 operator /(Vector4 left, Vector4 right) => new Vector4(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W);
|
|
|
|
public static Vector4 Divide(Vector4 left, Vector4 right) => left / right;
|
|
|
|
public static Vector4 operator /(Vector4 vector, float scalar) => new Vector4(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar);
|
|
|
|
public static Vector4 Divide(Vector4 vector, float scalar) => vector / scalar;
|
|
|
|
internal void Normalize()
|
|
{
|
|
float flValue1 = (float)(m_x * (double)this.m_x + m_y * (double)this.m_y + m_z * (double)this.m_z + m_w * (double)this.m_w);
|
|
if (Math2.WithinEpsilon(flValue1, 1f))
|
|
return;
|
|
if (flValue1 > 1.40129846432482E-45)
|
|
{
|
|
float num = (float)Math.Sqrt(flValue1);
|
|
this.m_x /= num;
|
|
this.m_y /= num;
|
|
this.m_z /= num;
|
|
this.m_w /= num;
|
|
}
|
|
else
|
|
{
|
|
this.m_x = 0.0f;
|
|
this.m_y = 0.0f;
|
|
this.m_z = 0.0f;
|
|
this.m_w = 0.0f;
|
|
}
|
|
}
|
|
|
|
public override bool Equals(object obj) => obj is Vector4 vector4 && this == vector4;
|
|
|
|
public static bool operator ==(Vector4 left, Vector4 right) => left.X == (double)right.X && left.Y == (double)right.Y && left.Z == (double)right.Z && left.W == (double)right.W;
|
|
|
|
public static bool operator !=(Vector4 left, Vector4 right) => !(left == right);
|
|
|
|
public override int GetHashCode() => this.X.GetHashCode() ^ this.Y.GetHashCode() ^ this.Z.GetHashCode() ^ this.W.GetHashCode();
|
|
|
|
public override string ToString() => base.ToString();
|
|
|
|
internal string ToDxShaderString()
|
|
{
|
|
StringBuilder stringBuilder = new StringBuilder(128);
|
|
stringBuilder.Append("{");
|
|
stringBuilder.Append(this.X);
|
|
stringBuilder.Append(", ");
|
|
stringBuilder.Append(this.Y);
|
|
stringBuilder.Append(", ");
|
|
stringBuilder.Append(this.Z);
|
|
stringBuilder.Append(", ");
|
|
stringBuilder.Append(this.W);
|
|
stringBuilder.Append("}");
|
|
return stringBuilder.ToString();
|
|
}
|
|
|
|
public bool IsApproximate(Vector4 vector) => Math2.WithinEpsilon(this.m_x, vector.m_x) && Math2.WithinEpsilon(this.m_y, vector.m_y) && Math2.WithinEpsilon(this.m_z, vector.m_z) && Math2.WithinEpsilon(this.m_w, vector.m_w);
|
|
}
|
|
}
|