/// <summary> /// Determines whether a <see cref="OrientedBoundingBox"/> contains a point. /// </summary> /// <param name="point">The point to test.</param> /// <returns>The type of containment the two objects have.</returns> public ContainmentType Contains(ref Vector3 point) { // Transform the point into the obb coordinates Matrix invTrans; Matrix.Invert(ref Transformation, out invTrans); Vector3 locPoint; Vector3.TransformCoordinate(ref point, ref invTrans, out locPoint); locPoint.X = Math.Abs(locPoint.X); locPoint.Y = Math.Abs(locPoint.Y); locPoint.Z = Math.Abs(locPoint.Z); //Simple axes-aligned BB check if (MathUtil.NearEqual(locPoint.X, Extents.X) && MathUtil.NearEqual(locPoint.Y, Extents.Y) && MathUtil.NearEqual(locPoint.Z, Extents.Z)) { return(ContainmentType.Intersects); } if (locPoint.X < Extents.X && locPoint.Y < Extents.Y && locPoint.Z < Extents.Z) { return(ContainmentType.Contains); } else { return(ContainmentType.Disjoint); } }
/// <inheritdoc/> public bool Equals(RectangleF other) { return(MathUtil.NearEqual(other.Left, Left) && MathUtil.NearEqual(other.Right, Right) && MathUtil.NearEqual(other.Top, Top) && MathUtil.NearEqual(other.Bottom, Bottom)); }
/// <summary> /// Determines whether the specified <see cref="SharpDX.Matrix3x2"/> is equal to this instance. /// </summary> /// <param name="other">The <see cref="SharpDX.Matrix3x2"/> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="SharpDX.Matrix3x2"/> is equal to this instance; otherwise, <c>false</c>. /// </returns> public bool Equals(Matrix3x2 other) { return(MathUtil.NearEqual(other.M11, M11) && MathUtil.NearEqual(other.M12, M12) && MathUtil.NearEqual(other.M21, M21) && MathUtil.NearEqual(other.M22, M22) && MathUtil.NearEqual(other.M31, M31) && MathUtil.NearEqual(other.M32, M32)); }
/// <summary> /// Determines whether the specified <see cref="ViewportF"/> is equal to this instance. /// </summary> /// <param name="other">The <see cref="ViewportF"/> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="ViewportF"/> is equal to this instance; otherwise, <c>false</c>. /// </returns> public bool Equals(ref ViewportF other) { return(MathUtil.NearEqual(X, other.X) && MathUtil.NearEqual(Y, other.Y) && MathUtil.NearEqual(Width, other.Width) && MathUtil.NearEqual(Height, other.Height) && MathUtil.NearEqual(MinDepth, other.MinDepth) && MathUtil.NearEqual(MaxDepth, other.MaxDepth)); }
/// <summary> /// Determines whether a <see cref="OrientedBoundingBox"/> contains an array of points>. /// </summary> /// <param name="points">The points array to test.</param> /// <returns>The type of containment.</returns> public ContainmentType Contains(Vector3[] points) { Matrix invTrans; Matrix.Invert(ref Transformation, out invTrans); var containsAll = true; var containsAny = false; for (int i = 0; i < points.Length; i++) { Vector3 locPoint; Vector3.TransformCoordinate(ref points[i], ref invTrans, out locPoint); locPoint.X = Math.Abs(locPoint.X); locPoint.Y = Math.Abs(locPoint.Y); locPoint.Z = Math.Abs(locPoint.Z); //Simple axes-aligned BB check if (MathUtil.NearEqual(locPoint.X, Extents.X) && MathUtil.NearEqual(locPoint.Y, Extents.Y) && MathUtil.NearEqual(locPoint.Z, Extents.Z)) { containsAny = true; } if (locPoint.X < Extents.X && locPoint.Y < Extents.Y && locPoint.Z < Extents.Z) { containsAny = true; } else { containsAll = false; } } if (containsAll) { return(ContainmentType.Contains); } else if (containsAny) { return(ContainmentType.Intersects); } else { return(ContainmentType.Disjoint); } }
/// <summary> /// Determines whether the specified <see cref="SharpDX.Matrix5x4"/> is equal to this instance. /// </summary> /// <param name="other">The <see cref="SharpDX.Matrix5x4"/> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="SharpDX.Matrix5x4"/> is equal to this instance; otherwise, <c>false</c>. /// </returns> public bool Equals(Matrix5x4 other) { return(MathUtil.NearEqual(other.M11, M11) && MathUtil.NearEqual(other.M12, M12) && MathUtil.NearEqual(other.M13, M13) && MathUtil.NearEqual(other.M14, M14) && MathUtil.NearEqual(other.M21, M21) && MathUtil.NearEqual(other.M22, M22) && MathUtil.NearEqual(other.M23, M23) && MathUtil.NearEqual(other.M24, M24) && MathUtil.NearEqual(other.M31, M31) && MathUtil.NearEqual(other.M32, M32) && MathUtil.NearEqual(other.M33, M33) && MathUtil.NearEqual(other.M34, M34) && MathUtil.NearEqual(other.M41, M41) && MathUtil.NearEqual(other.M42, M42) && MathUtil.NearEqual(other.M43, M43) && MathUtil.NearEqual(other.M44, M44) && MathUtil.NearEqual(other.M51, M51) && MathUtil.NearEqual(other.M52, M52) && MathUtil.NearEqual(other.M53, M53) && MathUtil.NearEqual(other.M54, M54)); }
public bool Equals(ref Viewport other) { return(X == other.X && Y == other.Y && Width == other.Width && Height == other.Height && MathUtil.NearEqual(MinDepth, other.MinDepth) && MathUtil.NearEqual(MaxDepth, other.MaxDepth)); }