SyMBac.cell_geometry

SyMBac.cell_geometry.centroid(vertices)[source]

Return the centroid of a list of vertices

Parameters

vertices (list(tuple)) – A list of tuples containing x,y coordinates.

SyMBac.cell_geometry.get_vertices(cell_length, cell_width, angle, resolution)[source]

Generates coordinates for a cell centered aronud (0,0)

Parameters
  • cell_length (float) – The length of the STRAIGHT part of the cell’s wall. Total length is cell_length + cell_width because the poles are models as semi-circles.

  • cell_width (float) – Total thickness of the cell, defines the poles too.

  • angle (float) – Angle in radians to rotate the cell by (counter-clockwise)

  • resolution (int) – Number of points defining the cell wall geometry

Return type

list of lists containing cell x and y coords

Examples

Create a cell of length 10+4 rotated by 1 radian with a resolution of 20:

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> verts = get_vertices(10,4,1,20)
>>> verts_y = [y[0] for y in verts]
>>> verts_x = [x[1] for x in verts]
>>> plt.plot(verts_x,verts_y)
SyMBac.cell_geometry.rotate(origin, point, angle)[source]

Rotate a point counterclockwise by a given angle around a given origin.

The angle should be given in radians.

SyMBac.cell_geometry.wall(thickness, start, end, t_or_b, resolution)[source]

Generates the straight part of the cell wall’s coordinates (all but the poles)

Parameters
  • thickness (float) – The distance from the top cell wall to the bottom cell wall

  • start (float) – The start coordinate of the cell wall

  • end (float) – The end coordinate of the cell wall

  • t_or_b (int) – 0 for top wall 1 for bottom wall

  • resolution (int) – Number of points defining the cell wall geometry

Returns

return[0] is the wall’s x coordinates return[0] is the wall’s y coordiantes

Return type

tuple(Numpy Array, Numpy Array)

Examples

Create two cell walls of length 10, 3 apart

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> top_wall = wall(3,0,10,0,20)
>>> bottom_wall = top_wall = wall(3,0,10,1,20)
>>> plt.plot(walls[0], walls[1])
>>> plt.plot(walls[0], walls[1])
>>> plt.show()