public TextureBreakModel(TriangleData triangle, TextureController controller, TextureBreakModel parent) { IsSet = false; _triangle = triangle; _controller = controller; _pool = controller.Pool; _parent = parent; _currentVertices = new TriangleVertices(_triangle); Сentroid = _currentVertices.GetCentroid(); _hasChildren = _controller.IsAbleToHaveChildren(_currentVertices); if (_hasChildren) { SetChildren(); } if (_parent == null) { SetVertices(_currentVertices); } }
public void Clear() { TriangleVertices.Clear(); LineVertices.Clear(); dirty = false; ContentSize = CCSize.Zero; }
public void IsResultValid_CoordinatesFromVertices_InvalidInput() { var service = new TriangleService(); var input = new TriangleVertices(-2, -2, -2, -2, -2, -2); var result = service.GetCoordinateFromVertices(input); Assert.Null(result); }
protected void SetVertices(TriangleVertices vertices) { if (_meshTriangle == null) { _meshTriangle = _pool.GetTriangle(); _meshTriangle.UseTriangle(_triangle); } _meshTriangle.UpdateVertices(vertices); }
public void QueueTriangle(Vector2 p1, Vector2 p2, Vector2 p3, float depth, Color color1, Color color2, Color color3) { int count = TriangleVertices.Count; TriangleVertices.Add(new VertexPositionColor(new Vector3(p1.X, p1.Y, depth), color1)); TriangleVertices.Add(new VertexPositionColor(new Vector3(p2.X, p2.Y, depth), color2)); TriangleVertices.Add(new VertexPositionColor(new Vector3(p3.X, p3.Y, depth), color3)); TriangleIndices.Add((ushort)count); TriangleIndices.Add((ushort)(count + 1)); TriangleIndices.Add((ushort)(count + 2)); }
public void QueueTriangle(Vector3 p1, Vector3 p2, Vector3 p3, Color color1, Color color2, Color color3) { int count = TriangleVertices.Count; TriangleVertices.Add(new VertexPositionColor(p1, color1)); TriangleVertices.Add(new VertexPositionColor(p2, color2)); TriangleVertices.Add(new VertexPositionColor(p3, color3)); TriangleIndices.Add((ushort)count); TriangleIndices.Add((ushort)(count + 1)); TriangleIndices.Add((ushort)(count + 2)); }
public void QueueQuad(Vector2 corner1, Vector2 corner2, float depth, Color color) { int count = TriangleVertices.Count; TriangleVertices.Add(new VertexPositionColor(new Vector3(corner1.X, corner1.Y, depth), color)); TriangleVertices.Add(new VertexPositionColor(new Vector3(corner1.X, corner2.Y, depth), color)); TriangleVertices.Add(new VertexPositionColor(new Vector3(corner2.X, corner2.Y, depth), color)); TriangleVertices.Add(new VertexPositionColor(new Vector3(corner2.X, corner1.Y, depth), color)); TriangleIndices.Add((ushort)count); TriangleIndices.Add((ushort)(count + 1)); TriangleIndices.Add((ushort)(count + 2)); TriangleIndices.Add((ushort)(count + 2)); TriangleIndices.Add((ushort)(count + 3)); TriangleIndices.Add((ushort)count); }
public TriangleCoordinate GetCoordinateFromVertices(TriangleVertices vertices) { if (!AreValidVertices(vertices)) { return(null); } var isTop = vertices.TopLeftY == vertices.MiddleY; int col = ((vertices.MiddleX / 10) * 2) + (isTop ? 0 : 1); int rowNum = (_imgSize - vertices.BottomRightY) / _sqrSize; char row = NumToChar(rowNum); return(new TriangleCoordinate(row, col)); }
public RadialBindModel(TriangleData triangle, RadialController controller, RadialBindModel parent) { IsSet = false; _triangle = triangle; _controller = controller; _pool = controller.Pool; _parent = parent; _currentVertices = _targetVertices = new TriangleVertices(_triangle); _hasChildren = _controller.IsAbleToHaveChildren(_currentVertices); if (_hasChildren) { SetChildren(); } }
public ActionResult <TriangleCoordinate> GetCoordinate2([FromQuery] TriangleVertices vertices) { try { var result = _helper.GetCoordinateFromVertices(vertices); if (result == null) { return(BadRequest("Invalid vertices. Unable to find traingle coordinate")); } return(Ok(result)); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, $"Unexpected error occured: {e.Message}")); } }
private bool AreValidVertices(TriangleVertices vrtx) { if (vrtx == null) { return(false); } var vertices = new List <int> { vrtx.TopLeftX, vrtx.TopLeftY, vrtx.MiddleX, vrtx.MiddleY, vrtx.BottomRightX, vrtx.BottomRightY }; if (vertices.Count != 6) { return(false); } return(!vertices.Any(v => v < 0 || v > _imgSize || v % _sqrSize != 0)); }
public void Post() { TriangleController controller = new TriangleController(); // Act string json = "{\"Vertex1\": \"0,10\",\"Vertex2\": \"0,0\",\"Vertex3\": \"10,10\"}"; TriangleVertices vertices = Newtonsoft.Json.JsonConvert.DeserializeObject <TriangleVertices>(json); Triangle triangle = controller.Post(vertices); // Assert Assert.AreNotEqual(null, triangle); Assert.AreEqual('A', triangle.Row); Assert.AreEqual(1, triangle.Column); Assert.AreEqual(new Point(0, 10), triangle.Vertex1); Assert.AreEqual(new Point(0, 0), triangle.Vertex2); Assert.AreEqual(new Point(10, 10), triangle.Vertex3); }
protected override void UpdateSelf() { if (_isFirst) { _currentVertices.SetToVector((_targetVertices).GetCentroid()); _isFirst = false; } else { if (!_controller.IsAbleToTransform(_radius)) { return; } _currentVertices.Lerp(_targetVertices, Time.deltaTime * RadialController.SPEED); IsSet = _currentVertices.TheSame(_targetVertices, RadialController.DELTA); if (IsSet) { _currentVertices = _targetVertices; } } SetVertices(_currentVertices); }
public void AddTriangleVertex(CCV3F_C4B triangleVertex) { TriangleVertices.Add(triangleVertex); dirty = true; }
public bool IsAbleToHaveChildren(TriangleVertices vertices) { return(vertices.GetArea() > MIN_AREA); }
// POST api/triangle /// <summary> /// Gets the row and column of the triangle for the supplied vertices. /// </summary> /// <param name="vertices">The vertices of the triangle to find</param> /// <returns>A triangle object with the details of the triangle</returns> /// [Route("api/triangle public Triangle Post([FromBody] TriangleVertices vertices) { return(triangleService.GetTriangle(vertices.Vertex1, vertices.Vertex2, vertices.Vertex3)); }
public void UpdateVertices(TriangleVertices vertices) { _triangleData.UpdateVertices(vertices); _targetMeshData.UpdateTriangleVertices(_triangleData); }