public void Normalize() { long num = this.x * 100; long num2 = this.y * 100; long a = (num * num) + (num2 * num2); if (a != 0) { long b = Fix32Math.Sqrt(a); this.x = (int)Fix32Math.Divide((long)(num * 0x3e8L), b); this.y = (int)Fix32Math.Divide((long)(num2 * 0x3e8L), b); } }
public static FixVector2 ClampMagnitude(FixVector2 v, int maxLength) { long sqrMagnitudeLong = v.sqrMagnitudeLong; long num2 = maxLength; if (sqrMagnitudeLong > (num2 * num2)) { long b = Fix32Math.Sqrt(sqrMagnitudeLong); int x = (int)Fix32Math.Divide((long)(v.x * maxLength), b); return(new FixVector2(x, (int)Fix32Math.Divide((long)(v.x * maxLength), b))); } return(v); }
public FixVector3 RotateY(int degree) { FixVector3 num; FixFactor factor; FixFactor factor2; Fix32Math.sincos(out factor, out factor2, (long)(0x7ab8 * degree), 0x1b7740L); long num2 = factor2.nom * factor.den; long num3 = factor2.den * factor.nom; long b = factor2.den * factor.den; num.x = (int)Fix32Math.Divide((long)((this.x * num2) + (this.z * num3)), b); num.z = (int)Fix32Math.Divide((long)((-this.x * num3) + (this.z * num2)), b); num.y = 0; return(num.NormalizeTo(Precision)); }
public FixVector3 RotateY(ref FixFactor radians) { FixVector3 num; FixFactor factor; FixFactor factor2; Fix32Math.sincos(out factor, out factor2, radians.nom, radians.den); long num2 = factor2.nom * factor.den; long num3 = factor2.den * factor.nom; long b = factor2.den * factor.den; num.x = (int)Fix32Math.Divide((long)((this.x * num2) + (this.z * num3)), b); num.z = (int)Fix32Math.Divide((long)((-this.x * num3) + (this.z * num2)), b); num.y = 0; return(num.NormalizeTo(0x3e8)); }
public FixVector3 NormalizeTo(int newMagn = 1) { long num = this.x; long num2 = this.y; long num3 = this.z; long a = ((num * num) + (num2 * num2)) + (num3 * num3); if (a != 0) { long b = Fix32Math.Sqrt(a); long num6 = newMagn; this.x = (int)Fix32Math.Divide((long)(num * num6), b); this.y = (int)Fix32Math.Divide((long)(num2 * num6), b); this.z = (int)Fix32Math.Divide((long)(num3 * num6), b); } return(this); }
public long Normalize() { long num = this.x << 7; long num2 = this.y << 7; long num3 = this.z << 7; long a = ((num * num) + (num2 * num2)) + (num3 * num3); if (a == 0) { return(0L); } long b = Fix32Math.Sqrt(a); long num6 = 0x3e8L; this.x = (int)Fix32Math.Divide((long)(num * num6), b); this.y = (int)Fix32Math.Divide((long)(num2 * num6), b); this.z = (int)Fix32Math.Divide((long)(num3 * num6), b); return(b >> 7); }
public static int operator *(int i, FixFactor f) { return((int)Fix32Math.Divide((long)(i * f.nom), f.den)); }
public static FixVector2 operator /(FixVector2 v, FixFactor f) { return(Fix32Math.Divide(v, f.den, f.nom)); }
public static FixVector3 operator *(FixVector3 v, FixFactor f) { return(Fix32Math.Divide(v, f.nom, f.den)); }
public static FixVector3 Lerp(FixVector3 a, FixVector3 b, int factorNom, int factorDen) { return(new FixVector3(Fix32Math.Divide((int)((b.x - a.x) * factorNom), factorDen) + a.x, Fix32Math.Divide((int)((b.y - a.y) * factorNom), factorDen) + a.y, Fix32Math.Divide((int)((b.z - a.z) * factorNom), factorDen) + a.z)); }
public static FixVector3 Lerp(FixVector3 a, FixVector3 b, FixFactor f) { return(new FixVector3(((int)Fix32Math.Divide((long)((b.x - a.x) * f.nom), f.den)) + a.x, ((int)Fix32Math.Divide((long)((b.y - a.y) * f.nom), f.den)) + a.y, ((int)Fix32Math.Divide((long)((b.z - a.z) * f.nom), f.den)) + a.z)); }
public static FixVector3 Cross(FixVector3 lhs, FixVector3 rhs) { return(new FixVector3(Fix32Math.Divide((int)((lhs.y * rhs.z) - (lhs.z * rhs.y)), Precision), Fix32Math.Divide((int)((lhs.z * rhs.x) - (lhs.x * rhs.z)), Precision), Fix32Math.Divide((int)((lhs.x * rhs.y) - (lhs.y * rhs.x)), Precision))); }