3using System.Globalization;
56 private static readonly
Vector4 zeroVector =
new Vector4(0f, 0f, 0f, 0f);
58 private static readonly
Vector4 oneVector =
new Vector4(1f, 1f, 1f, 1f);
60 private static readonly
Vector4 positiveInfinityVector =
new Vector4(
float.PositiveInfinity,
float.PositiveInfinity,
float.PositiveInfinity,
float.PositiveInfinity);
62 private static readonly
Vector4 negativeInfinityVector =
new Vector4(
float.NegativeInfinity,
float.NegativeInfinity,
float.NegativeInfinity,
float.NegativeInfinity);
64 public float this[
int index]
79 throw new IndexOutOfRangeException(
"Invalid Vector4 index!");
99 throw new IndexOutOfRangeException(
"Invalid Vector4 index!");
146 public void Set(
float newX,
float newY,
float newZ,
float newW)
163 return new Vector4(a.
x + (b.
x - a.
x) * t, a.
y + (b.
y - a.
y) * t, a.
z + (b.
z - a.
z) * t, a.
w + (b.
w - a.
w) * t);
174 return new Vector4(a.
x + (b.
x - a.
x) * t, a.
y + (b.
y - a.
y) * t, a.
z + (b.
z - a.
z) * t, a.
w + (b.
w - a.
w) * t);
185 float num = target.
x - current.
x;
186 float num2 = target.
y - current.
y;
187 float num3 = target.
z - current.
z;
188 float num4 = target.
w - current.
w;
189 float num5 = num * num + num2 * num2 + num3 * num3 + num4 * num4;
190 if (num5 == 0f || (maxDistanceDelta >= 0f && num5 <= maxDistanceDelta * maxDistanceDelta))
194 float num6 = (float)Math.Sqrt((
double)num5);
195 return new Vector4(current.
x + num / num6 * maxDistanceDelta, current.
y + num2 / num6 * maxDistanceDelta, current.
z + num3 / num6 * maxDistanceDelta, current.
w + num4 / num6 * maxDistanceDelta);
222 return x.GetHashCode() ^ (
y.GetHashCode() << 2) ^ (
z.GetHashCode() >> 2) ^ (
w.GetHashCode() >> 1);
229 public override bool Equals(
object other)
240 return x == other.
x &&
y == other.
y &&
z == other.
z &&
w == other.
w;
280 return a.
x * b.
x + a.
y * b.
y + a.
z * b.
z + a.
w * b.
w;
290 return b * (
Dot(a, b) /
Dot(b, b));
305 return (
float)Math.Sqrt((
double)
Dot(a, a));
340 return new Vector4(0f - a.
x, 0f - a.
y, 0f - a.
z, 0f - a.
w);
345 return new Vector4(a.
x * d, a.
y * d, a.
z * d, a.
w * d);
350 return new Vector4(a.
x * d, a.
y * d, a.
z * d, a.
w * d);
355 return new Vector4(a.
x / d, a.
y / d, a.
z / d, a.
w / d);
360 float num = lhs.
x - rhs.
x;
361 float num2 = lhs.
y - rhs.
y;
362 float num3 = lhs.
z - rhs.
z;
363 float num4 = lhs.
w - rhs.
w;
364 float num5 = num * num + num2 * num2 + num3 * num3 + num4 * num4;
365 return num5 < 9.99999944E-11f;
370 return !(lhs == rhs);
399 return String.Format(
"({0:F4}, {1:F4}, {2:F4}, {3:F4})",
x,
y,
z,
w);
408 return String.Format(
"({0}, {1}, {2}, {3})",
x.ToString(format, CultureInfo.InvariantCulture.NumberFormat),
y.ToString(format, CultureInfo.InvariantCulture.NumberFormat),
z.ToString(format, CultureInfo.InvariantCulture.NumberFormat),
w.ToString(format, CultureInfo.InvariantCulture.NumberFormat));
418 return Dot(
this,
this);
static float Min(float a, float b)
static float Max(float a, float b)
static float Clamp01(float value)
override bool Equals(object other)
string ToString(string format)
static Vector4 MoveTowards(Vector4 current, Vector4 target, float maxDistanceDelta)
static float Dot(Vector4 a, Vector4 b)
override string ToString()
static Vector4 positiveInfinity
static Vector4 Project(Vector4 a, Vector4 b)
Vector4(float x, float y)
Vector4(float x, float y, float z, float w)
static Vector4 negativeInfinity
static Vector4 Scale(Vector4 a, Vector4 b)
void Scale(Vector4 scale)
bool Equals(Vector4 other)
override int GetHashCode()
static Vector4 Min(Vector4 lhs, Vector4 rhs)
static Vector4 Normalize(Vector4 a)
static Vector4 operator-(Vector4 a, Vector4 b)
static Vector4 Max(Vector4 lhs, Vector4 rhs)
void Set(float newX, float newY, float newZ, float newW)
static float Magnitude(Vector4 a)
static bool operator!=(Vector4 lhs, Vector4 rhs)
static Vector4 operator/(Vector4 a, float d)
static bool operator==(Vector4 lhs, Vector4 rhs)
static Vector4 operator+(Vector4 a, Vector4 b)
static Vector4 Lerp(Vector4 a, Vector4 b, float t)
static float SqrMagnitude(Vector4 a)
Vector4(float x, float y, float z)
static Vector4 LerpUnclamped(Vector4 a, Vector4 b, float t)
static float Distance(Vector4 a, Vector4 b)
static Vector4 operator*(Vector4 a, float d)