public static bool EqualsWithTolerance(Vector3 left, Vector3 right, float tolerance = EngineMath.TOLERANCE_FLOAT_POSITIVE) { return (EngineMath.EqualsWithTolerance(left.X, right.X, tolerance) && EngineMath.EqualsWithTolerance(left.Y, right.Y, tolerance) && EngineMath.EqualsWithTolerance(left.Z, right.Z, tolerance)); }
public bool EqualsWithTolerance(Color4 other) { return (EngineMath.EqualsWithTolerance(Red, other.Red) && EngineMath.EqualsWithTolerance(Green, other.Green) && EngineMath.EqualsWithTolerance(Blue, other.Blue) && EngineMath.EqualsWithTolerance(Alpha, other.Alpha)); }
/// <summary> /// Calculates the intersection point to the intersection seen from local origin position. /// </summary> /// <param name="other">The ray to calculate intersection with</param> public Tuple <bool, Vector2> Intersect(Ray2D other) { //Intersection method taken from http://stackoverflow.com/questions/4543506/algorithm-for-intersection-of-2-lines var a1 = this.A; var b1 = this.B; var c1 = this.C; var a2 = other.A; var b2 = other.B; var c2 = other.C; var delta = a1 * b2 - a2 * b1; if (EngineMath.EqualsWithTolerance(delta, 0)) { return(Tuple.Create(false, Vector2.Zero)); } var intersectionX = (b2 * c1 - b1 * c2) / delta; var intersectionY = (a1 * c2 - a2 * c1) / delta; return(Tuple.Create(true, new Vector2(intersectionX, intersectionY))); }
/// <summary> /// Initializes a new instance of the <see cref="MovementSpeed"/> struct. /// </summary> /// <param name="maxSpeed">The maximum speed in m/s.</param> /// <param name="acceleration">The acceleration in m/s².</param> /// <param name="deceleration">The deceleration in m/s².</param> public MovementSpeed(float maxSpeed, float acceleration, float deceleration) { MaximumSpeed = EngineMath.ForcePositive(maxSpeed); Acceleration = EngineMath.ForcePositive(acceleration); Deceleration = EngineMath.ForceNegative(deceleration); }
/// <summary> /// Initializes a new instance of the <see cref="MovementSpeed"/> struct. /// </summary> /// <param name="maxSpeed">The maximum speed in m/s.</param> /// <param name="acceleration">The acceleration in m/s².</param> public MovementSpeed(float maxSpeed, float acceleration) { MaximumSpeed = maxSpeed; Acceleration = EngineMath.ForcePositive(acceleration); Deceleration = 0f; }