private static void ResizeHeight(ICellGeometry a, ICellGeometry b) { // First we need to check whether either a top or a bottom is between b top or b bottom. bool between = a.TopCenter.Y <b.TopCenter.Y && a.TopCenter.Y> b.BottomCenter.Y || a.BottomCenter.Y > b.BottomCenter.Y && a.BottomCenter.Y < b.TopCenter.Y; // If it is not between, then we don't need to do anything if (!between) { return; } // If the top of cell a sticks through to bottom of cell b above if (a.TopCenter.Y > b.BottomCenter.Y) { float difference = a.TopCenter.Y - b.BottomCenter.Y; a.TopCenter = new Vector3(a.TopCenter.X, b.BottomCenter.Y, a.TopCenter.Z); a.BottomCenter = new Vector3(a.BottomCenter.X, a.BottomCenter.Y - difference, a.BottomCenter.Z); } // If the bottom of cell a sticks through the top of cell b below if (a.BottomCenter.Y < b.TopCenter.Y) { float difference = b.TopCenter.Y - a.BottomCenter.Y; a.BottomCenter = new Vector3(a.BottomCenter.X, b.TopCenter.Y, a.BottomCenter.Z); a.TopCenter = new Vector3(a.TopCenter.X, a.TopCenter.Y + difference, a.TopCenter.Z); } }
private bool IsWithinHeight(ICellGeometry a, ICellGeometry b) { var topWithin = helper.IsWithinHeight(a.TopCenter, b.TopCenter, b.BottomCenter, true); var bottomWithin = helper.IsWithinHeight(a.BottomCenter, b.TopCenter, b.BottomCenter, true); return(topWithin || bottomWithin); }
private static Vector3 GetCellHalfWay(ICellGeometry geometry) { var top = geometry.TopCenter; var bottom = geometry.BottomCenter; return(new Vector3 { X = (top.X + bottom.X) / 2, Y = (top.Y + bottom.Y) / 2, Z = (top.Z + bottom.Z) / 2 }); }
private static void ChangeFace(ICellGeometry geo, Vector2 changedPoint, Vector2 direction) { geo.TopCenter += new Vector3(direction.X, 0, direction.Y); geo.BottomCenter += new Vector3(direction.X, 0, direction.Y); for (int i = 0; i < geo.Face.Points.Length; i++) { if (geo.Face.Points[i] == changedPoint) { continue; } geo.Face.Points[i] += direction; } }
public IPlantCell[] Divide(IPlantCell cell, IPlantPart plantPart) { ICellGeometry geo = cell.Geometry; Vector3 halfPoint = GetCellHalfWay(geo); ICellGeometry topCellGeometry = new CellGeometry(geo.TopCenter, halfPoint, geo.Face); ICellGeometry bottomCellGeometry = new CellGeometry(halfPoint, geo.BottomCenter, geo.Face); IPlantCell[] cells = new IPlantCell[2]; cells[0] = CreatePlantCell(cell.CellType, topCellGeometry, cell.Vacuole, cell.CellWall); cells[1] = CreatePlantCell(cell.CellType, bottomCellGeometry, cell.Vacuole, cell.CellWall); return(cells); }
/// <summary> /// Helper method to instantiate a new plant cell type based on the provided type /// </summary> /// <param name="type">The type of cell to new</param> /// <param name="geometry">The new geometry</param> /// <param name="vacuole">The vacuole organ</param> /// <param name="wall">The cell wall</param> /// <param name="neighbors">The neighboring plant cells</param> /// <returns>New cell of type <see cref="type"/> with provided parameters</returns> private IPlantCell InstantiateCell(PlantCellType type, ICellGeometry geometry, IVacuole vacuole, ICellWall wall) { switch (type) { case PlantCellType.Xylem: return(new XylemCell(geometry, vacuole, wall)); case PlantCellType.Phloem: return(new PhloemCell(geometry, vacuole, wall)); case PlantCellType.Sclerenchyma: return(new SclerenchymaCell(geometry, vacuole, wall)); case PlantCellType.Collenchyma: return(new CollenchymaCell(geometry, vacuole, wall)); case PlantCellType.Parenchyma: return(new ParenchymaCell(geometry, vacuole, wall)); default: throw new ArgumentOutOfRangeException(nameof(type), type, "Invalid Plant Cell Type"); } }
public PhloemCell(ICellGeometry geometry, IVacuole vacuole, ICellWall cellWall) { Geometry = geometry; Vacuole = vacuole; CellWall = cellWall; }
protected PlantCell(ICellGeometry geometry, ICellWall cellWall, IVacuole vacuole) { StarchStorage = new StarchStorage(0); }
private IPlantCell CreatePlantCell(PlantCellType type, ICellGeometry geometry, IVacuole vacuole, ICellWall cellWall) { return(cellFactory.CreateCell(type, geometry, vacuole, cellWall)); }
public ParenchymaCell(ICellGeometry geometry, IVacuole vacuole, ICellWall cellWall) { Geometry = geometry; Vacuole = vacuole; CellWall = cellWall; }
/// <summary> /// Helper method to instantiate a new plant cell type based on the provided type /// </summary> /// <param name="type">The type of cell to new</param> /// <param name="geometry">The new geometry</param> /// <param name="vacuole">The vacuole organ</param> /// <param name="wall">The cell wall</param> /// <param name="neighbors">The neighboring plant cells</param> /// <returns>New cell of type <see cref="type"/> with provided parameters</returns> public IPlantCell CreateCell(PlantCellType type, ICellGeometry geometry, IVacuole vacuole, ICellWall wall) { return(InstantiateCell(type, geometry, vacuole, wall)); }
public XylemCell(ICellGeometry geometry, IVacuole vacuole, ICellWall cellWall) : this() { Geometry = geometry; Vacuole = vacuole; CellWall = cellWall; }
public CollenchymaCell(ICellGeometry geometry, IVacuole vacuole, ICellWall cellWall) : base(geometry, cellWall, vacuole) { }