本文整理汇总了C#中System.Vector4.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Vector4.Equals方法的具体用法?C# Vector4.Equals怎么用?C# Vector4.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector4
的用法示例。
在下文中一共展示了Vector4.Equals方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Vector4_EqualsTestsCorrectly
public void Vector4_EqualsTestsCorrectly()
{
var vector1 = new Vector4(123.4f, 567.8f, 901.2f, 345.6f);
var vector2 = new Vector4(123.4f, 567.8f, 901.2f, 345.6f);
var vector3 = new Vector4(345.6f, 901.2f, 567.8f, 123.4f);
TheResultingValue(vector1.Equals(vector2)).ShouldBe(true);
TheResultingValue(vector1.Equals(vector3)).ShouldBe(false);
}
示例2: NaNEquality
public void NaNEquality()
{
Vector4 nanVec = new Vector4(float.NaN, float.NaN, float.NaN, float.NaN);
Assert.IsFalse(nanVec == nanVec);
Assert.IsTrue(nanVec != nanVec);
Assert.IsTrue(nanVec.Equals(nanVec));
}
示例3: TestEquality
// Test Operator: Equality //-----------------------------------------//
/// <summary>
/// Helper method for testing equality.
/// </summary>
void TestEquality (Vector4 a, Vector4 b, Boolean expected )
{
// This test asserts the following:
// (a == b) == expected
// (b == a) == expected
// (a != b) == !expected
// (b != a) == !expected
Boolean result_1a = (a == b);
Boolean result_1b = (a.Equals(b));
Boolean result_1c = (a.Equals((Object)b));
Boolean result_2a = (b == a);
Boolean result_2b = (b.Equals(a));
Boolean result_2c = (b.Equals((Object)a));
Boolean result_3a = (a != b);
Boolean result_4a = (b != a);
Assert.That(result_1a, Is.EqualTo(expected));
Assert.That(result_1b, Is.EqualTo(expected));
Assert.That(result_1c, Is.EqualTo(expected));
Assert.That(result_2a, Is.EqualTo(expected));
Assert.That(result_2b, Is.EqualTo(expected));
Assert.That(result_2c, Is.EqualTo(expected));
Assert.That(result_3a, Is.EqualTo(!expected));
Assert.That(result_4a, Is.EqualTo(!expected));
}
示例4: Clear
public void Clear(ClearOptions options, Vector4 color, float depth, int stencil)
{
// glClear depends on the scissor rectangle!
if (scissorTestEnable)
{
glDisable(GLenum.GL_SCISSOR_TEST);
}
bool clearTarget = (options & ClearOptions.Target) == ClearOptions.Target;
bool clearDepth = (options & ClearOptions.DepthBuffer) == ClearOptions.DepthBuffer;
bool clearStencil = (options & ClearOptions.Stencil) == ClearOptions.Stencil;
// Get the clear mask, set the clear properties if needed
GLenum clearMask = GLenum.GL_ZERO;
if (clearTarget)
{
clearMask |= GLenum.GL_COLOR_BUFFER_BIT;
if (!color.Equals(currentClearColor))
{
glClearColor(
color.X,
color.Y,
color.Z,
color.W
);
currentClearColor = color;
}
// glClear depends on the color write mask!
if (colorWriteEnable != ColorWriteChannels.All)
{
// FIXME: ColorWriteChannels1/2/3? -flibit
glColorMask(true, true, true, true);
}
}
if (clearDepth)
{
clearMask |= GLenum.GL_DEPTH_BUFFER_BIT;
if (depth != currentClearDepth)
{
glClearDepth((double) depth);
currentClearDepth = depth;
}
// glClear depends on the depth write mask!
if (!zWriteEnable)
{
glDepthMask(true);
}
}
if (clearStencil)
{
clearMask |= GLenum.GL_STENCIL_BUFFER_BIT;
if (stencil != currentClearStencil)
{
glClearStencil(stencil);
currentClearStencil = stencil;
}
// glClear depends on the stencil write mask!
if (stencilWriteMask != -1)
{
// AKA 0xFFFFFFFF, ugh -flibit
glStencilMask(-1);
}
}
// CLEAR!
glClear(clearMask);
// Clean up after ourselves.
if (scissorTestEnable)
{
glEnable(GLenum.GL_SCISSOR_TEST);
}
if (clearTarget && colorWriteEnable != ColorWriteChannels.All)
{
// FIXME: ColorWriteChannels1/2/3? -flibit
glColorMask(
(colorWriteEnable & ColorWriteChannels.Red) != 0,
(colorWriteEnable & ColorWriteChannels.Blue) != 0,
(colorWriteEnable & ColorWriteChannels.Green) != 0,
(colorWriteEnable & ColorWriteChannels.Alpha) != 0
);
}
if (clearDepth && !zWriteEnable)
{
glDepthMask(false);
}
if (clearStencil && stencilWriteMask != -1) // AKA 0xFFFFFFFF, ugh -flibit
{
glStencilMask(stencilWriteMask);
}
}
示例5: Vector4NormaliseTest
public void Vector4NormaliseTest()
{
var a = new Vector4(3.0f, 4.0f, 1.0f, 2.0f);
var expectedResult = new Vector4(0.5477226f, 0.730296731f, 0.182574183f, 0.365148365f);
a.Normalise();
Assert.True(a.Equals(expectedResult, 1e-3f));
}