/// <summary> /// <para>Clamps the Vector2Int to the bounds given by min and max.</para> /// </summary> /// <param name="min"></param> /// <param name="max"></param> public void Clamp(LVector2Int min, LVector2Int max) { this.x = LMath.Max(min.x, this.x); this.x = LMath.Min(max.x, this.x); this.y = LMath.Max(min.y, this.y); this.y = LMath.Min(max.y, this.y); }
public LVector2 Rotate(LFloat deg) { var rad = LMath.Deg2Rad * deg; LFloat cos, sin; LMath.SinCos(out sin, out cos, rad); return(new LVector2(x * cos - y * sin, x * sin + y * cos)); }
public LVector3 RotateY(LFloat degree) { LFloat s; LFloat c; LMath.SinCos(out s, out c, new LFloat(true, degree._val * 31416L / 1800000L)); LVector3 vInt; vInt._x = (int)(((long)this._x * s._val + (long)this._z * c._val) / LFloat.Precision); vInt._z = (int)(((long)this._x * -c._val + (long)this._z * s._val) / LFloat.Precision); vInt._y = 0; return(vInt.normalized); }
public void Normalize() { long num = (long)(this._x * 100); long num2 = (long)(this._y * 100); long num3 = num * num + num2 * num2; if (num3 == 0L) { return; } long b = (long)LMath.Sqrt(num3); this._x = (int)(num * 1000L / b); this._y = (int)(num2 * 1000L / b); }
public LVector3 Normalize(LFloat newMagn) { long num = (long)(this._x * 100); long num2 = (long)(this._y * 100); long num3 = (long)(this._z * 100); long num4 = num * num + num2 * num2 + num3 * num3; if (num4 == 0L) { return(this); } long b = (long)LMath.Sqrt(num4); long num5 = newMagn._val; this._x = (int)(num * num5 / b); this._y = (int)(num2 * num5 / b); this._z = (int)(num3 * num5 / b); return(this); }
public static LVector2 Min(LVector2 a, LVector2 b) { return(new LVector2(true, LMath.Min(a._x, b._x), LMath.Min(a._y, b._y))); }
public void Max(ref LVector2 r) { this._x = LMath.Max(this._x, r._x); this._y = LMath.Max(this._y, r._y); }