public static Vec4 Lerp(Vec4 v1, Vec4 v2, float amount) { Vec4 vec; vec.x = v1.x + ((v2.x - v1.x) * amount); vec.y = v1.y + ((v2.y - v1.y) * amount); vec.z = v1.z + ((v2.z - v1.z) * amount); vec.w = v1.w + ((v2.w - v1.w) * amount); return(vec); }
public static Vec4 Divide(float s, Vec4 v) { Vec4 vec; vec.x = s / v.x; vec.y = s / v.y; vec.z = s / v.z; vec.w = s / v.w; return(vec); }
public static Vec4 Negate(Vec4 v) { Vec4 vec; vec.x = -v.x; vec.y = -v.y; vec.z = -v.z; vec.w = -v.w; return(vec); }
public static Vec4 Multiply(float s, Vec4 v) { Vec4 vec; vec.x = v.x * s; vec.y = v.y * s; vec.z = v.z * s; vec.w = v.w * s; return(vec); }
public static Vec4 Divide(Vec4 v1, Vec4 v2) { Vec4 vec; vec.x = v1.x / v2.x; vec.y = v1.y / v2.y; vec.z = v1.z / v2.z; vec.w = v1.w / v2.w; return(vec); }
public static Vec4 Multiply(Vec4 v1, Vec4 v2) { Vec4 vec; vec.x = v1.x * v2.x; vec.y = v1.y * v2.y; vec.z = v1.z * v2.z; vec.w = v1.w * v2.w; return(vec); }
public static Vec4 Subtract(Vec4 v1, Vec4 v2) { Vec4 vec; vec.x = v1.x - v2.x; vec.y = v1.y - v2.y; vec.z = v1.z - v2.z; vec.w = v1.w - v2.w; return(vec); }
public static Vec4 Add(Vec4 v1, Vec4 v2) { Vec4 vec; vec.x = v1.x + v2.x; vec.y = v1.y + v2.y; vec.z = v1.z + v2.z; vec.w = v1.w + v2.w; return(vec); }
public static Vec4 Divide(Vec4 v, float s) { Vec4 vec; float num = 1f / s; vec.x = v.x * num; vec.y = v.y * num; vec.z = v.z * num; vec.w = v.w * num; return(vec); }
public bool Equals(ref Vec4 v, float epsilon) { if (System.Math.Abs(x - v.x) > epsilon) { return(false); } if (System.Math.Abs(y - v.y) > epsilon) { return(false); } if (System.Math.Abs(z - v.z) > epsilon) { return(false); } if (System.Math.Abs(w - v.w) > epsilon) { return(false); } return(true); }
public static Vec4 Parse(string text) { Vec4 vec; if (string.IsNullOrEmpty(text)) { throw new ArgumentNullException("The text parameter cannot be null or zero length."); } string[] strArray = text.Split(SpaceCharacter.arrayWithOneSpaceCharacter, StringSplitOptions.RemoveEmptyEntries); if (strArray.Length != 4) { throw new FormatException(string.Format("Cannot parse the text '{0}' because it does not have 4 parts separated by spaces in the form (x y z w).", text)); } try { vec = new Vec4(float.Parse(strArray[0]), float.Parse(strArray[1]), float.Parse(strArray[2]), float.Parse(strArray[3])); } catch (Exception) { throw new FormatException("The parts of the vectors must be decimal numbers."); } return(vec); }
public static Vec4 NormalizeFast(Vec4 v) { float num = MathFunctions.InvSqrt16((((v.x * v.x) + (v.y * v.y)) + (v.z * v.z)) + (v.w * v.w)); return(new Vec4(v.x * num, v.y * num, v.z * num, v.w * num)); }
static Vec4() { Zero = new Vec4(0f, 0f, 0f, 0f); }
public static Vec4 Multiply(Vec4 v, Mat4 m) { Multiply(ref m, ref v, out Vec4 vec); return(vec); }