static void Main() { Point3 p1 = new Point3(1, 1); Point3 p2 = new Point3(2, 2); object o2 = new Point3(2, 2); Console.WriteLine(p1.Equals(p2)); Console.WriteLine(p1.Equals(o2)); }
public void Point3Test() { var point3 = new Point3(3d, 3d, 3d); int hashCode = point3.GetHashCode(); Assert.IsTrue(point3.Equals(new Point3(3, 3, 3))); Assert.IsFalse(point3.Equals(3d)); Assert.AreEqual(3, point3.X); Assert.AreEqual(3, point3.Y); Assert.AreEqual(3, point3.Z); }
public void TestEquality() { var p = new Point3(1, 2, 3); var p2 = new Point3(1, 2, 3); Assert.AreEqual(p, p2); Assert.AreEqual(p.GetHashCode(), p2.GetHashCode()); Assert.IsFalse(p.Equals(null)); Assert.IsTrue(p.Equals(p)); Assert.IsFalse(p.Equals(1)); }
public void equal_object() { var a = new Point3(1, 2, 0); var b = new Point3(3, 4, 9); var c = new Point3(3, 4, 9); Assert.False(a.Equals((object)(new Vector3(b)))); Assert.False(a.Equals((object)(new Vector3(c)))); Assert.False(((object)b).Equals(a)); Assert.True(((object)b).Equals(new Vector3(c))); Assert.False(c.Equals((object)a)); Assert.True(c.Equals((object)b)); }
public void equal_typed() { var a = new Point3(1, 2, 9); var b = new Point3(3, 4, 6); var c = new Point3(3, 4, 6); Assert.False(a.Equals(b)); Assert.False(a.Equals(c)); Assert.False(b.Equals(a)); Assert.True(b.Equals(c)); Assert.False(c.Equals(a)); Assert.True(c.Equals(b)); }
public void TestEquality() { Point3 p1 = new Point3(0.0f, 0.0f, 0.0f); Point3 p2 = new Point3(0.0f, 0.0f, 0.0f); Point3 p3 = new Point3(1.0f, 0.0f, 2.0f); Assert.IsTrue(p1 == p2); Assert.IsFalse(p1 != p2); Assert.IsFalse(p1 == p3); Assert.IsTrue(p1 != p3); Assert.IsTrue(p1.Equals(p2)); Assert.IsFalse(p1.Equals(p3)); }
public void equal_coordtriple() { var a = new Point3(1, 2, 0); var b = new Point3(3, 4, 1); var c = new Point3(3, 4, 1); ICoordinateTriple <double> nil = null; Assert.False(a.Equals((ICoordinateTriple <double>)b)); Assert.False(a.Equals((ICoordinateTriple <double>)c)); Assert.False(b.Equals((ICoordinateTriple <double>)a)); Assert.True(b.Equals((ICoordinateTriple <double>)c)); Assert.False(c.Equals((ICoordinateTriple <double>)a)); Assert.True(c.Equals((ICoordinateTriple <double>)b)); Assert.False(a.Equals(nil)); }
/// <summary> /// Constructs a new rotation transformation with Sin and Cos radians angle, rotation center and rotation axis. /// </summary> /// <param name="sinAngle">Sin radians angle.</param> /// <param name="cosAngle">Cos radians angle.</param> /// <param name="axis">Axis direction.</param> /// <param name="origin">Rotation center.</param> /// <returns>A transformation matrix which rotates geometry around an anchor.</returns> private static Transform Rotation(double sinAngle, double cosAngle, Vector3 axis, Point3 origin) { double sAngle = sinAngle; double cAngle = cosAngle; GSharkMath.KillNoise(ref sAngle, ref cAngle); Transform transform = Identity(); double oneMinusCosAngle = 1 - cosAngle; transform[0][0] = axis[0] * axis[0] * oneMinusCosAngle + cAngle; transform[0][1] = axis[0] * axis[1] * oneMinusCosAngle - axis[2] * sAngle; transform[0][2] = axis[0] * axis[2] * oneMinusCosAngle + axis[1] * sAngle; transform[1][0] = axis[1] * axis[0] * oneMinusCosAngle + axis[2] * sAngle; transform[1][1] = axis[1] * axis[1] * oneMinusCosAngle + cAngle; transform[1][2] = axis[1] * axis[2] * oneMinusCosAngle - axis[0] * sAngle; transform[2][0] = axis[2] * axis[0] * oneMinusCosAngle - axis[1] * sAngle; transform[2][1] = axis[2] * axis[1] * oneMinusCosAngle + axis[0] * sAngle; transform[2][2] = axis[2] * axis[2] * oneMinusCosAngle + cAngle; if (!origin.Equals(new Point3(0, 0, 0))) { transform[0][3] = -((transform[0][0] - 1) * origin[0] + transform[0][1] * origin[1] + transform[0][2] * origin[2]); transform[1][3] = -(transform[1][0] * origin[0] + (transform[1][1] - 1) * origin[1] + transform[1][2] * origin[2]); transform[2][3] = -(transform[2][0] * origin[0] + transform[2][1] * origin[1] + (transform[2][2] - 1) * origin[2]); } transform[3][0] = transform[3][1] = transform[3][0] = 0.0; transform[3][3] = 1; return(transform); }
public RaycastResult?AlaphaRaycast(Vector3 position, Vector3 direction, float distance = 20) { Vector3 increase = Vector3.Normalize(direction) * 0.05f; Point3 last = new Point3(); Point3 result; int count = (int)(distance / 0.05f); for (int i = 0; i < count; i++) { result = new Point3(ToCell(position.x), ToCell(position.y), ToCell(position.z)); if (!result.Equals(last)) { int value = terrain.GetCellValue(result.X, result.Y, result.Z); if (value != BlockTerrain.NULL_BLOCK_VALUE && BlockTerrain.GetContent(value) != 0) { return(new RaycastResult { Position = result, LastPosition = last, BlockValue = value, Distance = i * 0.05f }); } last = result; } position += increase; } return(null); }
public void It_Divides_A_Point3d_By_A_Number() { // Arrange Point3 p = new Point3(-10, 15, 5); Point3 expectedPoint = new Point3(-5, 7.5, 2.5); // Act Point3 divisionResult = p / 2; // Assert divisionResult.Equals(expectedPoint).Should().Be(true); }
/// <summary> /// Creates non uniform scale transformation matrix with the origin as the fixed point. /// </summary> /// <param name="anchorPoint">The anchor point from the scale transformation is computed.</param> /// <param name="factorX">Scale factor x direction.</param> /// <param name="factorY">Scale factor y direction.</param> /// <param name="factorZ">Scale factor z direction.</param> /// <returns>Scale transformation matrix where the diagonal is (factorX, factorY, factorZ, 1)</returns> public static Transform Scale(Point3 anchorPoint, double factorX, double factorY, double factorZ) { var origin = new Point3(0.0, 0.0, 0.0); Transform scale = Scale(factorX, factorY, factorZ); if (anchorPoint.Equals(origin)) { return(scale); } var dir = anchorPoint - origin; Transform t0 = Translation(-dir); Transform t1 = Translation(dir); return(t1 * scale * t0); }
public void It_Returns_The_Centroid_By_Vertices() { // Arrange Polygon poly2D = new Polygon(Planar2D); Polygon poly3D = new Polygon(Planar3D); Point3 centroid2DExpected = new Point3(3.5, 5.5, 0.0); Point3 centroid3DExpected = new Point3(86.266409, 29.701102, -0.227864); // Act Point3 poly2DCentroid = poly2D.CentroidByVertices; Point3 poly3DCentroid = poly3D.CentroidByVertices; // Assert poly2DCentroid.Equals(centroid2DExpected).Should().BeTrue(); poly3DCentroid.EpsilonEquals(centroid3DExpected, GSharkMath.MaxTolerance).Should().BeTrue(); }
public void VectorAdditionAndSubtraction() { IVector <DoubleComponent> Point1 = MatrixFactory <DoubleComponent> .CreateVector3D(1, 1, 1); //new Vector3D(); //Point1.Set(1, 1, 1); IVector <DoubleComponent> Point2 = MatrixFactory <DoubleComponent> .CreateVector3D(2, 2, 2); //Point2.Set(2, 2, 2); IVector <DoubleComponent> Point3;; Point3 = Point1.Add(Point2); Assert.IsTrue(Point3.Equals(MatrixFactory <DoubleComponent> .CreateVector3D(3, 3, 3))); Point3 = Point1.Subtract(Point2); Assert.IsTrue(Point3.Equals(MatrixFactory <DoubleComponent> .CreateVector3D(-1, -1, -1))); Point3.AddEquals(Point1); Assert.IsTrue(Point3.Equals(MatrixFactory <DoubleComponent> .CreateVector3D(0, 0, 0))); Point3.AddEquals(Point2); Assert.IsTrue(Point3.Equals(MatrixFactory <DoubleComponent> .CreateVector3D(2, 2, 2))); Point3.SetFrom(MatrixFactory <DoubleComponent> .CreateVector3D(3, -4, 5)); Assert.IsTrue(Point3.GetMagnitude().GreaterThan(7.07) && Point3.GetMagnitude().LessThan(7.08)); IVector <DoubleComponent> InlineOpLeftSide = MatrixFactory <DoubleComponent> .CreateVector3D(5.0f, -3.0f, .0f); IVector <DoubleComponent> InlineOpRightSide = MatrixFactory <DoubleComponent> .CreateVector3D(-5.0f, 4.0f, 1.0f); Assert.IsTrue( InlineOpLeftSide.Add(InlineOpRightSide) .Equals( MatrixFactory <DoubleComponent> .CreateVector3D(.0f, 1.0f, 1.0f) )); Assert.IsTrue( InlineOpLeftSide.Subtract(InlineOpRightSide) .Equals( MatrixFactory <DoubleComponent> .CreateVector3D(10.0f, -7.0f, -1.0f)) ); }
public bool Equals(ChunkCoordinate other) { return(Depth == other.Depth && Position.Equals(other.Position)); }
static void exemplo2() { Point3 p1 = new Point3(5, 7, 11); Point3 p2 = new Point3(5, 7, 11); Console.WriteLine("{0}.Equals({1}) = {2}", p1, p2, p1.Equals(p2)); }
public bool Equals(Device other) => base.Equals(other) && Point.Equals(other.Point);
void VoxelListener_OnVoxelDestroyed(Point3 voxelID) { if (voxelID.Equals(VoxelID)) { GetRootComponent().Die(); } }
public void equal_coordtriple() { var a = new Point3(1, 2, 0); var b = new Point3(3, 4, 1); var c = new Point3(3, 4, 1); ICoordinateTriple<double> nil = null; Assert.False(a.Equals((ICoordinateTriple<double>)b)); Assert.False(a.Equals((ICoordinateTriple<double>)c)); Assert.False(b.Equals((ICoordinateTriple<double>)a)); Assert.True(b.Equals((ICoordinateTriple<double>)c)); Assert.False(c.Equals((ICoordinateTriple<double>)a)); Assert.True(c.Equals((ICoordinateTriple<double>)b)); Assert.False(a.Equals(nil)); }