/// <summary> /// Calculates whether this rectangle contains a point. /// </summary> /// <param name="point">The point.</param> /// <returns>True if this rectangle contains the point; False otherwise.</returns> /// <remarks>This does consider a point on the edge contained.</remarks> public bool Contains(Vector2D <T> point) { var max = Max; return(Scalar.GreaterThanOrEqual(point.X, Origin.X) && Scalar.GreaterThanOrEqual (point.Y, Origin.Y) && Scalar.LessThanOrEqual(point.X, max.X) && Scalar.LessThanOrEqual(point.Y, max.Y)); }
/// <summary> /// Calculates whether this circle contains another circle /// </summary> /// <param name="other">The circle.</param> /// <returns>True if this circle contains the given circle; False otherwise.</returns> /// <remarks>This does consider a circle that touches the edge contained.</remarks> public bool Contains(Circle <T> other) { var distanceSquared = Vector2D.DistanceSquared(Center, other.Center); var radiusDiff = Scalar.Subtract(Radius, other.Radius); return(Scalar.LessThanOrEqual(distanceSquared, Scalar.Multiply(radiusDiff, radiusDiff))); }
/// <summary> /// Calculates whether this rectangle contains another rectangle /// </summary> /// <param name="other">The rectangle.</param> /// <returns>True if this rectangle contains the given rectangle; False otherwise.</returns> /// <remarks>This does consider a rectangle that touches the edge contained.</remarks> public bool Contains(Rectangle <T> other) { var tMax = this.Max; var oMax = other.Max; return(Scalar.GreaterThanOrEqual(other.Origin.X, this.Origin.X) && Scalar.GreaterThanOrEqual (other.Origin.Y, this.Origin.Y) && Scalar.LessThanOrEqual(oMax.X, tMax.X) && Scalar.LessThanOrEqual (oMax.Y, tMax.Y)); }
/// <summary> /// Calculates whether this circle contains a point. /// </summary> /// <param name="point">The point.</param> /// <returns>True if this circle contains the point; False otherwise.</returns> /// <remarks>This does consider a point on the edge contained.</remarks> public bool Contains(Vector2D <T> point) { return(Scalar.LessThanOrEqual(Vector2D.DistanceSquared(point, Center), Radius)); }
/// <summary> /// Calculates whether this box contains another box /// </summary> /// <param name="other">The box.</param> /// <returns>True if this box contains the given box; False otherwise.</returns> /// <remarks>This does consider a box that touches the edge contained.</remarks> public bool Contains(Box2D <T> other) => Scalar.GreaterThanOrEqual(other.Min.X, Min.X) && Scalar.GreaterThanOrEqual(other.Min.Y, Min.Y) && Scalar.LessThanOrEqual(other.Max.X, Max.X) && Scalar.LessThanOrEqual(other.Max.Y, Max.Y);
/// <summary> /// Calculates whether this box contains a point. /// </summary> /// <param name="point">The point.</param> /// <returns>True if this box contains the point; False otherwise.</returns> /// <remarks>This does consider a point on the edge contained.</remarks> public bool Contains(Vector2D <T> point) => Scalar.GreaterThanOrEqual(point.X, Min.X) && Scalar.GreaterThanOrEqual(point.Y, Min.Y) && Scalar.LessThanOrEqual(point.X, Max.X) && Scalar.LessThanOrEqual(point.Y, Max.Y);
/// <summary> /// Calculates whether this box contains another box /// </summary> /// <param name="other">The box.</param> /// <returns>True if this box contains the given box; False otherwise.</returns> /// <remarks>This does consider a box that touches the edge contained.</remarks> public bool Contains(Box3D <T> other) => Scalar.GreaterThanOrEqual(other.Min.X, this.Min.X) && Scalar.GreaterThanOrEqual(other.Min.Y, this.Min.Y) && Scalar.GreaterThanOrEqual(other.Min.Z, this.Min.Z) && Scalar.LessThanOrEqual(other.Max.X, this.Max.X) && Scalar.LessThanOrEqual(other.Max.Y, this.Max.Y) && Scalar.LessThanOrEqual(other.Max.Z, this.Max.Z);