本文整理汇总了C#中Vertex.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Vertex.Equals方法的具体用法?C# Vertex.Equals怎么用?C# Vertex.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertex
的用法示例。
在下文中一共展示了Vertex.Equals方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EqualTest1
public void EqualTest1()
{
Vertex v0 = new Vertex(new Vector3(2f, 234.4f, 30f), new Vector2(-341f, 234000f), new Vector3(9f, 24.4f, 330f), new Vector3(255f, 2.4f, 10.315f));
Vertex v1 = new Vertex(new Vector3(2f, 234.4f, 30f), new Vector2(-341f, 234000f), new Vector3(9f, 24.4f, 330f), new Vector3(255f, 2.4f, 10.315f));
Assert.IsTrue(v0.Equals(v1));
Assert.IsTrue(v1.Equals(v0));
Assert.IsTrue(v0.Equals((object)v1));
Assert.IsTrue(v1.Equals((object)v0));
Assert.IsTrue(v0 == v1);
Assert.IsFalse(v0 != v1);
}
示例2: EqualTest0
public void EqualTest0()
{
Vertex v0 = new Vertex();
Vertex v1 = new Vertex();
Assert.IsTrue(v0.Equals(v1));
Assert.IsTrue(v1.Equals(v0));
Assert.IsTrue(v0.Equals((object)v1));
Assert.IsTrue(v1.Equals((object)v0));
Assert.IsTrue(v0 == v1);
Assert.IsFalse(v0 != v1);
}
示例3: TestEquals
public void TestEquals()
{
var vertex = new Vertex(12.34f, -98.7f, 54);
Assert.False(vertex.Equals((object)null));
Assert.False(vertex.Equals(12345));
var vertex2 = new Vertex();
Assert.False(vertex.Equals((object)vertex2));
vertex2 = new Vertex(12.34f, -98.7f, 54);
Assert.True(vertex.Equals((object)vertex2));
Assert.True(vertex.Equals((object)vertex));
}
示例4: Equals
public void Equals()
{
Vertex vertex1 = new Vertex(2.0,3.0,4.0);
Vertex vertex2 = new Vertex(2.0,3.0,4.0);
Assert.IsTrue(vertex1.Equals(vertex2));
vertex1.x = 1.0;
Assert.IsFalse(vertex1.Equals(vertex2));
vertex1.x = 2.0;
vertex1.y = 2.0;
Assert.IsFalse(vertex1.Equals(vertex2));
vertex1.y = 3.0;
vertex1.z = 5.0;
Assert.IsFalse(vertex1.Equals(vertex2));
Assert.IsFalse(vertex1.Equals(null));
Assert.IsFalse(vertex1.Equals("string"));
}
示例5: ContainsPoint
public bool ContainsPoint(Vertex point)
{
//return true if the point to test is one of the vertices
if (point.Equals(A) || point.Equals(B) || point.Equals(C))
return true;
bool oddNodes = false;
if (checkPointToSegment(C, A, point))
oddNodes = !oddNodes;
if (checkPointToSegment(A, B, point))
oddNodes = !oddNodes;
if (checkPointToSegment(B, C, point))
oddNodes = !oddNodes;
return oddNodes;
}
示例6: Vertex_Equals_IsTrue_Test
public void Vertex_Equals_IsTrue_Test()
{
// Assign
var vertexA = new Vertex("a");
var vertexB = new Vertex("a");
// Act
bool actual = vertexA.Equals(vertexB);
// Assert
bool expected = true;
Assert.AreEqual(expected, actual);
}
示例7: findEdge
public Edge findEdge(Vertex vet1, Vertex vet2) {
if (!vet1.Equals(vet2)) {
if (directed) {
foreach (Edge e in edges)
if (((e.getStart().getName().Equals(vet1.getName())) &&
(e.getEnd().getName().Equals(vet2.getName()))))
return e;
} else {
foreach (Edge e in edges)
if (((e.getStart().getName().Equals(vet1.getName())) &&
(e.getEnd().getName().Equals(vet2.getName()))) ||
((e.getStart().getName().Equals(vet2.getName())) &&
(e.getEnd().getName().Equals(vet1.getName()))))
return e;
}
}
return null;
}
示例8: Add
/// <summary>
/// Adds a triangle to the mesh using absolute vertices
/// </summary>
/// <param name="v1"></param>
/// <param name="v2"></param>
/// <param name="v3"></param>
public void Add(Vertex v1, Vertex v2, Vertex v3)
{
//do not include any triangles that have been smashed into lines
if (v1.Equals(v2) || v2.Equals(v3) || v1.Equals(v3))
return;
// If a vertex of the triangle is not yet in the vertices list,
// add it and set its index to the current index count
if (!m_vertices.ContainsKey(v1))
m_vertices[v1] = m_vertices.Count;
if (!m_vertices.ContainsKey(v2))
m_vertices[v2] = m_vertices.Count;
if (!m_vertices.ContainsKey(v3))
m_vertices[v3] = m_vertices.Count;
//do not include any triangles we already have
if (!_triIndex.Add(new IndexedTriangle(m_vertices[v1], m_vertices[v2], m_vertices[v3])))
return;
_meshData.AddTriangle(v1, v2, v3);
}
示例9: LocateFromEdge
/// <summary>
/// Locates an edge of a triangle which contains a location
/// specified by a Vertex v.
/// The edge returned has the
/// property that either v is on e, or e is an edge of a triangle containing v.
/// The search starts from startEdge amd proceeds on the general direction of v.
/// </summary>
/// <remarks>
/// This locate algorithm relies on the subdivision being Delaunay. For
/// non-Delaunay subdivisions, this may loop for ever.
/// </remarks>
/// <param name="v">the location to search for</param>
/// <param name="startEdge">an edge of the subdivision to start searching at</param>
/// <returns>a QuadEdge which contains v, or is on the edge of a triangle containing v</returns>
/// <exception cref="LocateFailureException">
/// if the location algorithm fails to converge in a reasonable
/// number of iterations
/// </exception>
public QuadEdge LocateFromEdge(Vertex v, QuadEdge startEdge)
{
int iter = 0;
int maxIter = _quadEdges.Count;
QuadEdge e = startEdge;
while (true)
{
iter++;
/*
* So far it has always been the case that failure to locate indicates an
* invalid subdivision. So just fail completely. (An alternative would be
* to perform an exhaustive search for the containing triangle, but this
* would mask errors in the subdivision topology)
*
* This can also happen if two vertices are located very close together,
* since the orientation predicates may experience precision failures.
*/
if (iter > maxIter)
{
throw new LocateFailureException(e.ToLineSegment());
// String msg = "Locate failed to converge (at edge: " + e + ").
// Possible causes include invalid Subdivision topology or very close
// sites";
// System.err.println(msg);
// dumpTriangles();
}
if ((v.Equals(e.Orig)) || (v.Equals(e.Dest)))
{
break;
}
if (v.RightOf(e))
{
e = e.Sym;
}
else if (!v.RightOf(e.ONext))
{
e = e.ONext;
}
else if (!v.RightOf(e.DPrev))
{
e = e.DPrev;
}
else
{
// on edge or in triangle containing edge
break;
}
}
// System.out.println("Locate count: " + iter);
return e;
}
示例10: IsVertexOfEdge
/// <summary>
/// Tests whether a <see cref="Vertex"/> is the start or end vertex of a
/// <see cref="QuadEdge"/>, up to the subdivision tolerance distance.
/// </summary>
/// <param name="e" />
/// <param name="v" />
/// <returns>true if the vertex is a endpoint of the edge</returns>
public bool IsVertexOfEdge(QuadEdge e, Vertex v)
{
if ((v.Equals(e.Orig, _tolerance)) || (v.Equals(e.Dest, _tolerance)))
{
return true;
}
return false;
}
示例11: IsFrameVertex
/// <summary>
/// Tests whether a vertex is a vertex of the outer triangle.
/// </summary>
/// <param name="v">the vertex to test</param>
/// <returns>true if the vertex is an outer triangle vertex</returns>
public bool IsFrameVertex(Vertex v)
{
if (v.Equals(_frameVertex[0]))
return true;
if (v.Equals(_frameVertex[1]))
return true;
if (v.Equals(_frameVertex[2]))
return true;
return false;
}
示例12: InsertSite
/// <summary>
/// Inserts a new site into the Subdivision, connecting it to the vertices of
/// the containing triangle (or quadrilateral, if the split point falls on an
/// existing edge).
/// </summary>
/// <remarks>
/// <para>
/// This method does NOT maintain the Delaunay condition. If desired, this must
/// be checked and enforced by the caller.
/// </para>
/// <para>
/// This method does NOT check if the inserted vertex falls on an edge. This
/// must be checked by the caller, since this situation may cause erroneous
/// triangulation
/// </para>
/// </remarks>
/// <param name="v">the vertex to insert</param>
/// <returns>a new quad edge terminating in v</returns>
public QuadEdge InsertSite(Vertex v)
{
QuadEdge e = Locate(v);
if ((v.Equals(e.Orig, _tolerance)) || (v.Equals(e.Dest, _tolerance)))
{
return e; // point already in subdivision.
}
// Connect the new point to the vertices of the containing
// triangle (or quadrilateral, if the new point fell on an
// existing edge.)
QuadEdge baseQE = MakeEdge(e.Orig, v);
QuadEdge.Splice(baseQE, e);
QuadEdge startEdge = baseQE;
do
{
baseQE = Connect(e, baseQE.Sym);
e = baseQE.OPrev;
} while (e.LNext != startEdge);
return startEdge;
}
示例13: EqualTest3
public void EqualTest3()
{
//Texture coord is different
Vertex v0 = new Vertex(new Vector3(2f, 234.4f, 30f), new Vector2(-341f, 99000f), new Vector3(9f, 24.4f, 330f), new Vector3(255f, 2.4f, 10.315f));
Vertex v1 = new Vertex(new Vector3(2f, 234.4f, 30f), new Vector2(-341f, 234000f), new Vector3(9f, 24.4f, 330f), new Vector3(255f, 2.4f, 10.315f));
Assert.IsFalse(v0.Equals(v1));
Assert.IsFalse(v1.Equals(v0));
Assert.IsFalse(v0.Equals((object)v1));
Assert.IsFalse(v1.Equals((object)v0));
Assert.IsFalse(v0 == v1);
Assert.IsTrue(v0 != v1);
}
示例14: DigRiver
public void DigRiver(List<Vertex> path, int width, float depthFactor)
{
float[,] depthField = new float[terrainSize, terrainSize]; //depth to dig
float[,] distField = new float[terrainSize, terrainSize]; //distance from line
float[,] pathMark = new float[terrainSize, terrainSize]; //path number which will effect the vertex
for (int x = 0; x < terrainSize; x++)
{
for (int z = 0; z < terrainSize; z++)
{
depthField[x, z] = 666;//mark
distField[x, z] = 666;//mark
}
}
//should be min 2
int areaFactor = 2;
List<float> widthInPoints = AssignWidthToPoints(path, width);
for (int i = 0; i < path.Count - 1; i++)
{
Vertex v1 = path[i];
Vertex v2 = path[i + 1];
float width1 = widthInPoints[i];
float width2 = widthInPoints[i+1];
Vertex topLeftCorner = new Vertex(0, 0);
Vertex botRightCorner = new Vertex(0, 0);
//evaluate position of affected area
if (v1.x < v2.x)
{
topLeftCorner.x = (int)(v1.x - width1 * areaFactor);
botRightCorner.x = (int)(v2.x + width2 * areaFactor);
}
else
{
topLeftCorner.x = (int)(v2.x - width2 * areaFactor);
botRightCorner.x = (int)(v1.x + width1 * areaFactor);
}
if (v1.z < v2.z)
{
topLeftCorner.z = (int)(v2.z + width2 * areaFactor);
botRightCorner.z = (int)(v1.z - width1 * areaFactor);
}
else
{
topLeftCorner.z = (int)(v1.z + width1 * areaFactor);
botRightCorner.z = (int)(v2.z - width2 * areaFactor);
}
if (topLeftCorner.Equals(botRightCorner))
{
Debug.Log("same vertices");
break;
}
for (int x = topLeftCorner.x; x < botRightCorner.x; x++)
{
for (int z = topLeftCorner.z; z > botRightCorner.z; z--)
{
if (ftm.CheckBounds(x, z) && fmc.BelongsToPath(x, z, v1, v2, 2*width * areaFactor))
{
bool valid = true;
Vertex vert = new Vertex(x, z);
float distance = fmc.GetDistanceFromLine(vert, v1, v2);
float depth = 0;
if (distance == 0) //sinc is not defined at 0
distance += 0.01f;
//determine width (interpolation between points)
float localWidth = GetLocalWidth(vert, v1, v2, width1, width2);
//float localWidth = 1;
if(localWidth < width)
{
Debug.Log("!");
}
if(distance > areaFactor * localWidth)
{
valid = false;
}
depth = MySinc(distance, localWidth, depthFactor);
if (valid && depthField[vert.x, vert.z] == 666) //hasnt been modified yet
{
depthField[vert.x, vert.z] = depth;
distField[vert.x, vert.z] = distance;
pathMark[vert.x, vert.z] = 1;//path
//widthFactor += 0.0003f;
}
else if (valid && depthField[vert.x, vert.z] != 666) //has been modified but I can dig it better (valid shouldnt be neccessary)
{
if (distance < distField[vert.x, vert.z])
{
//depthField[vert.x, vert.z] = Math.Min(depthField[vert.x, vert.z], depth);
//.........这里部分代码省略.........