public void Cartesian2dCoordinate_CreateFromString_BeExpected(string pointCoordinates, double expectedX, double expectedY) { // 1. Prepare // Nothing to prepare // 2. Execute Cartesian2dCoordinate c = new Cartesian2dCoordinate(pointCoordinates); // 3. Verify Assert.Equal(expectedX, c.X, PRECISION_DOUBLE); Assert.Equal(expectedY, c.Y, PRECISION_DOUBLE); }
// Rotated Conversions public void Cartesian3dCoordinatesConverter_Convert3dTo2d_BeExpected(string cPlane, string c3d, string c2d) { // 1. Prepare Plane p = new Plane(cPlane); CartesianCoordinatesConverter converter = new CartesianCoordinatesConverter(p); Cartesian2dCoordinate expected = new Cartesian2dCoordinate(c2d); Cartesian3dCoordinate source = new Cartesian3dCoordinate(c3d); // 2. Execute Cartesian2dCoordinate result = converter.ConvertTo2d(source); // 3. Verify Assert.Equal(expected.X, result.X, PRECISION_DOUBLE); Assert.Equal(expected.Y, result.Y, PRECISION_DOUBLE); }
private void GetFace(string faceId) { CoreFace f = Core.GetFace(faceId); CartesianCoordinatesConverter c = new CartesianCoordinatesConverter(f.Coordinates); var blocks = Core.GetBlocksForFace(f.Id) .OfType <IPositionnedByCartesian3dVector>() .ToList(); blocks.Sort(new PlanePositionPointComparer(f.Coordinates)); foreach (Block b in blocks.OfType <Block>()) { Cartesian2dCoordinate c2 = c.ConvertTo2d(b.Position); System.Console.WriteLine($"{b.Id} {FormatCoordinates(b.Position)} {FormatCoordinates(c2)}"); } }
public void CircularVectorComparer_Compare2dVector_BeExpected(string xCoord, string yCoord, int expected) { // 1. Prepare Cartesian2dCoordinate x = new Cartesian2dCoordinate(xCoord); Cartesian2dCoordinate y = new Cartesian2dCoordinate(yCoord); // Plane has no impact in 2d, no need to change it. Plane p = new Plane("(1.0 0.0 0.0 1)"); var comparer = new CircularVectorComparer(p); // 2. Execute int result = comparer.Compare(x, y); int reverse = comparer.Compare(y, x); // 3. Verify Assert.Equal(expected, result); Assert.Equal(-expected, reverse); }
protected string FormatCoordinates(Cartesian2dCoordinate cc) => $"({cc.X:0.00}, {cc.Y:0.00})";