public void CalculateParallelCubeIntersectionFigureTest(double x1, double y1, double z1, double edge1, double x2, double y2, double z2, double edge2, double rwidth, double rlength, double rdepth) { // En los parámetros no se puede poner el sufijo m de decimal decimal cx1, cy1, cz1, ce1, cx2, cy2, cz2, ce2; FromDoubleToDecimal(x1, y1, z1, edge1, x2, y2, z2, edge2, out cx1, out cy1, out cz1, out ce1, out cx2, out cy2, out cz2, out ce2); var width = (decimal)rwidth; var length = (decimal)rlength; var depth = (decimal)rdepth; IIntersectionCalculator intersectionCalculator = new IntersectionCalculator(); Cube firstCube = CubeBuilder.CreateCube() .CenteredAt(cx1, cy1, cz1) .WithEdgeLength(ce1) .Build(); Cube secondCube = CubeBuilder.CreateCube() .CenteredAt(cx2, cy2, cz2) .WithEdgeLength(ce2) .Build(); Ortoedro result = intersectionCalculator.CalculateParallelCubeIntersectionFigure(firstCube, secondCube); Assert.IsTrue(result.Width == width && result.Length == length && result.Depth == depth, "The resultant ortoedro dimensions are not the expected."); }
public void CubesIntersectionDoNotCollideTest(double x1, double y1, double z1, double edge1, double x2, double y2, double z2, double edge2) { // En los parámetros no se puede poner el sufijo m de decimal decimal cx1, cy1, cz1, ce1, cx2, cy2, cz2, ce2; FromDoubleToDecimal(x1, y1, z1, edge1, x2, y2, z2, edge2, out cx1, out cy1, out cz1, out ce1, out cx2, out cy2, out cz2, out ce2); #region .: Configure mocks :. _intersectionCalculatorMock.Expects.AtLeastOne.Method(m => m.FindParallelCubeIntersection(null, null)).WithAnyArguments().WillReturn(false); _intersectionCalculatorMock.Expects.AtLeastOne.Method(m => m.CalculateParallelCubeIntersectionFigure(null, null)).WithAnyArguments().WillReturn(new Ortoedro()); _volumeCalculatorMock.Expects.AtLeastOne.Method(m => m.CalculateOrtoedroVolume(null)).WithAnyArguments().WillReturn(1); #endregion .: Configure mocks :. ICubesIntersection cubesIntersection = new CubesIntersection(_intersectionCalculatorMock.MockObject, _volumeCalculatorMock.MockObject); Cube firstcube = CubeBuilder.CreateCube().CenteredAt(cx1, cy1, cz1).WithEdgeLength(ce1).Build(); Cube secondCube = CubeBuilder.CreateCube().CenteredAt(cx2, cy2, cz2).WithEdgeLength(ce2).Build(); Tuple <bool, decimal> result = cubesIntersection.GetCubesIntersection(firstcube, secondCube); Assert.IsFalse(result.Item1, "Intersection should not have been found."); Assert.IsTrue(result.Item2 == 0, "Wrong volume."); }
private Tuple <bool, decimal> ProcessInput(InputDTO inputDTO) { Cube firstCube = CubeBuilder.CreateCube() .CenteredAt(inputDTO.Abscisse1, inputDTO.Ordinate1, inputDTO.Applicate1) .WithEdgeLength(inputDTO.EdgeSize1) .Build(); Cube secondCube = CubeBuilder.CreateCube() .CenteredAt(inputDTO.Abscisse2, inputDTO.Ordinate2, inputDTO.Applicate2) .WithEdgeLength(inputDTO.EdgeSize2) .Build(); return(_cubesIntersection.GetCubesIntersection(firstCube, secondCube)); }
public void FindParallelCubeIntersectionNoCollidingTes(double x1, double y1, double z1, double edge1, double x2, double y2, double z2, double edge2) { // En los parámetros no se puede poner el sufijo m de decimal decimal cx1, cy1, cz1, ce1, cx2, cy2, cz2, ce2; FromDoubleToDecimal(x1, y1, z1, edge1, x2, y2, z2, edge2, out cx1, out cy1, out cz1, out ce1, out cx2, out cy2, out cz2, out ce2); IIntersectionCalculator intersectionCalculator = new IntersectionCalculator(); Cube firstCube = CubeBuilder.CreateCube() .CenteredAt(cx1, cy1, cz1) .WithEdgeLength(ce1) .Build(); Cube secondCube = CubeBuilder.CreateCube() .CenteredAt(cx2, cy2, cz2) .WithEdgeLength(ce2) .Build(); Assert.IsFalse(intersectionCalculator.FindParallelCubeIntersection(firstCube, secondCube), "An intersection have been found but cubes do not collide."); }
//private void rotateX_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) //{ // RotateX(e.NewValue); //} //private void rotationY_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) //{ // RotateY(e.NewValue); //} //private void rotationZ_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) //{ // RotateZ(e.NewValue); //} //public void RotateX(double angle) //{ // rotX.Angle = angle; //} //public void RotateY(double angle) //{ // rotY.Angle = angle; //} //public void RotateZ(double angle) //{ // rotZ.Angle = angle; //} //private void Window_MouseWheel(object sender, MouseWheelEventArgs e) //{ // mCamera.Position = new System.Windows.Media.Media3D.Point3D( // mCamera.Position.X, // mCamera.Position.Y, // mCamera.Position.Z - e.Delta / 250D); //} private void BuildColumn3DGraph(Column column) { CubeBuilder cubeBuilder = null; CuadraticPrismBuilder cuadraticPrismBuilder = null; //PiramidBuilder piramidBuilder = null; var offsetX = 0; var offsetY = 0; var cubeSide = 5; var lastHeight = 0; var i = 0; var j = 0; while (i < 5) { offsetX += 7; while (j < 5) { offsetY += 7; foreach (var layer in column.ListOfLayers.AsEnumerable().Reverse()) { var layerControl = new LayerControl(layer.LayerName); switch (layer.LayerName) { case "DP-I": cubeBuilder = new CubeBuilder(ModelBuilder.ColorGreen); cubeBuilder.CreateCube(offsetX, offsetY, lastHeight, cubeSide, group); //mainViewport.Children.Add(cubeBuilder.CreateCube(offsetX, offsetY, lastHeight, cubeSide)); lastHeight += cubeSide; break; case "DP-II": cubeBuilder = new CubeBuilder(ModelBuilder.ColorOrange); cubeBuilder.CreateCube(offsetX, offsetY, lastHeight, cubeSide, group); //mainViewport.Children.Add(cubeBuilder.CreateCube(offsetX, offsetY, lastHeight, cubeSide)); lastHeight += cubeSide; break; case "AND": cuadraticPrismBuilder = new CuadraticPrismBuilder(ModelBuilder.ColorYellow); cuadraticPrismBuilder.CreateCuadraticPrism(offsetX, offsetY, lastHeight, cubeSide, 20, group); //mainViewport.Children.Add(cuadraticPrismBuilder.CreateCuadraticPrism(offsetX, offsetY, lastHeight, cubeSide, 20)); lastHeight += 20; break; case "INPUT": cuadraticPrismBuilder = new CuadraticPrismBuilder(ModelBuilder.ColorViolet); cuadraticPrismBuilder.CreateCuadraticPrism(offsetX, offsetY, lastHeight, cubeSide, 10, group); //mainViewport.Children.Add(cuadraticPrismBuilder.CreateCuadraticPrism(offsetX, offsetY, lastHeight, cubeSide, 10)); lastHeight += 10; break; case "OR": cuadraticPrismBuilder = new CuadraticPrismBuilder(ModelBuilder.ColorRed); cuadraticPrismBuilder.CreateCuadraticPrism(offsetX, offsetY, lastHeight, cubeSide, 10, group); //mainViewport.Children.Add(cuadraticPrismBuilder.CreateCuadraticPrism(offsetX, offsetY, lastHeight, cubeSide, 10)); lastHeight += 10; break; } } lastHeight = 0; j++; } offsetY = 0; j = 0; i++; } var center = ModelBuilder.GetCenter(group); Vector3D cVect = new Vector3D(center.X, center.Y, center.Z); group.Transform = new TranslateTransform3D(-cVect); }