本文整理汇总了C#中BoundingRectangle.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingRectangle.Contains方法的具体用法?C# BoundingRectangle.Contains怎么用?C# BoundingRectangle.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingRectangle
的用法示例。
在下文中一共展示了BoundingRectangle.Contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContainsPoint
public void ContainsPoint()
{
BoundingRectangle rect = new BoundingRectangle(0, 0, 2, 2);
Assert.AreEqual(ContainmentType.Contains, rect.Contains(new Vector2D(1, 1)), "1");
Assert.AreEqual(ContainmentType.Contains, rect.Contains(new Vector2D(2, 2)), "2");
Assert.AreEqual(ContainmentType.Contains, rect.Contains(new Vector2D(0, 2)), "3");
Assert.AreEqual(ContainmentType.Contains, rect.Contains(new Vector2D(0, 0)), "4");
Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(2, 3)), "5");
Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(-1, 0)), "6");
Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(-.0001f, 0)), "7");
Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(3, 1)), "8");
Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(1, -1)), "9");
}
示例2: Collide
void Collide(ref LinkedListNode<ContactPoint> node, Body b1, Body b2, bool inverse, ref BoundingRectangle targetArea)
{
Vector2D[] vertexes = b2.Shape.Vertexes;
Vector2D[] normals = b2.Shape.VertexNormals;
Matrix2x3 b2ToWorld = b2.Matrices.ToWorld;
Matrix2x3 b1ToBody = b1.Matrices.ToBody;
Matrix2x2 b1ToWorldNormal = b1.Matrices.ToWorldNormal;
Matrix2x2 normalM;
Matrix2x2.Multiply(ref b1.Matrices.ToBodyNormal, ref b2.Matrices.ToWorldNormal, out normalM);
IntersectionInfo info = IntersectionInfo.Zero;
ContainmentType contains;
ContactPoint contact;
for (int index = 0; index < vertexes.Length; ++index)
{
Vector2D worldVertex;
Vector2D.Transform(ref b2ToWorld, ref vertexes[index], out worldVertex);
targetArea.Contains(ref worldVertex, out contains);
bool isBad = (contains != ContainmentType.Contains);
if (!isBad)
{
Vector2D bodyVertex;
Vector2D.Transform(ref b1ToBody, ref worldVertex, out bodyVertex);
isBad = !b1.Shape.TryGetIntersection(bodyVertex, out info);
if (!isBad && normals != null &&
!body1.IgnoresCollisionResponse &&
!body2.IgnoresCollisionResponse)
{
Vector2D normal;
Vector2D.Transform(ref normalM, ref normals[index], out normal);
Scalar temp;
Vector2D.Dot(ref info.Normal, ref normal, out temp);
isBad = temp >= 0;
}
}
int Id = (inverse) ? (index) : ((-vertexes.Length + index));
while (node != null && node.Value.id < Id) { node = node.Next; }
if (isBad)
{
if (node != null && node.Value.id == Id)
{
LinkedListNode<ContactPoint> nextNode = node.Next;
contacts.Remove(node);
node = nextNode;
}
}
else
{
if (node == null)
{
contact = new ContactPoint();
contact.id = Id;
contacts.AddLast(contact);
}
else if (node.Value.id == Id)
{
contact = node.Value;
node = node.Next;
if (!parent.warmStarting)
{
contact.Pn = 0;
contact.Pt = 0;
contact.Pnb = 0;
}
}
else
{
contact = new ContactPoint();
contact.id = Id;
contacts.AddBefore(node, contact);
}
Vector2D.Transform(ref b1ToWorldNormal, ref info.Normal, out contact.normal);
contact.distance = info.Distance;
contact.position = worldVertex;
if (inverse)
{
Vector2D.Negate(ref contact.normal, out contact.normal);
}
Vector2D.Normalize(ref contact.normal, out contact.normal);
}
}
}
示例3: FillRect
static void FillRect(int[,] has, BoundingRectangle clip, BoundingRectangle other)
{
ContainmentType inter = clip.Contains(other);
if (inter == ContainmentType.Contains)
{
has[Non, Non]++;
}
else
{
has[Non, Non]++;
bool hasMin = false;
bool hasMax = false;
if (other.Min.X < clip.Min.X)
{
hasMin = true;
has[Min, Non]++;
}
else if (other.Max.X > clip.Max.X)
{
hasMax = true;
has[Max, Non]++;
}
if (other.Min.Y < clip.Min.Y)
{
has[Non, Min]++;
if (hasMax)
{
has[Max, Min]++;
}
else if (hasMin)
{
has[Min, Min]++;
}
}
else if (other.Max.Y > clip.Max.Y)
{
has[Non, Max]++;
if (hasMax)
{
has[Max, Max]++;
}
else if (hasMin)
{
has[Min, Max]++;
}
}
}
}