Commit d36667e7 authored by Elijah Andrews's avatar Elijah Andrews

Added asymmetric slot generator.

parent 94f22ab8
......@@ -249,6 +249,124 @@ def gen_varied_slot(n=3000, H=3, W=2, length=50, depth=50, w_thresh=6, density_r
return centroids, normals, areas
def gen_asymmetric_varied_slot(n=3000, H=3, W=2, length=50, depth=50, w_thresh=6, density_ratio=0.25,
asym_angle=np.pi / 8, save_to_files=False):
"""
Generates a slot with varying panel density.
:param n: Approximate number of panels
:param H: Slot height
:param W: Slot width
:param length: Geometry length
:param depth: Geometry depth
:param w_thresh: w threshold at which to reduce density (density reduced starting after position w_thresh * w / 2)
:param density_ratio: Ratio of densities
:return: centroids, normals, areas
"""
if w_thresh < 0:
raise ValueError(f"gen_varied_slot w_thresh cannot be less than zero ({w_thresh})")
if W * w_thresh > length:
warnings.warn("w threshold too high, reverting to gen_slot")
return gen_slot(n, H, W, length, depth)
centroids = []
normals = []
areas = []
total_asym_offset = H * np.tan(asym_angle)
if total_asym_offset / 2 >= W or total_asym_offset / 2 >= W * w_thresh / 2 - W:
raise ValueError(f"asym_angle is too high ({asym_angle}), "
f"width is too low ({W}), "
f"or w_thresh is too low ({w_thresh})")
total_surface_length = length + 2 * H
dense_surface_length = 2 * H + W * w_thresh
sparse_surface_length = total_surface_length - dense_surface_length
zeta = dense_surface_length / (density_ratio * sparse_surface_length)
n_dense = n * zeta / (1 + zeta)
n_sparse = n - n_dense
n_slot_floor = int(round(n_dense * W / dense_surface_length))
n_slot_wall = int(round(n_dense * H / dense_surface_length))
n_dense_surface_boundary = int(round(n_dense * (W * (w_thresh - 1)) / 2) / dense_surface_length)
n_sparse_surface_boundary = int(round(n_sparse / 2))
######################
# Surface boundaries #
######################
filename = "model_outputs/left_sparse.csv" if save_to_files else None
p_centroids, p_normals, p_areas = gen_plane([W / 2 + total_asym_offset / 2, 0, - depth / 2],
[W / 2 + total_asym_offset / 2, 0, depth / 2],
[W * w_thresh / 2, 0, - depth / 2],
n_dense_surface_boundary, filename=filename)
centroids.extend(p_centroids)
normals.extend(p_normals)
areas.extend(p_areas)
filename = "model_outputs/left_dense.csv" if save_to_files else None
p_centroids, p_normals, p_areas = gen_plane([W * w_thresh / 2, 0, - depth / 2],
[W * w_thresh / 2, 0, depth / 2],
[length / 2, 0, - depth / 2],
n_sparse_surface_boundary, filename=filename)
centroids.extend(p_centroids)
normals.extend(p_normals)
areas.extend(p_areas)
filename = "model_outputs/right_dense.csv" if save_to_files else None
p_centroids, p_normals, p_areas = gen_plane([-W * w_thresh / 2, 0, - depth / 2],
[-W * w_thresh / 2, 0, depth / 2],
[-W / 2, 0, - depth / 2],
n_dense_surface_boundary, filename=filename)
centroids.extend(p_centroids)
normals.extend(p_normals)
areas.extend(p_areas)
filename = "model_outputs/right_sparse.csv" if save_to_files else None
p_centroids, p_normals, p_areas = gen_plane([-length / 2, 0, - depth / 2],
[-length / 2, 0, depth / 2],
[-W * w_thresh / 2, 0, - depth / 2],
n_sparse_surface_boundary, filename=filename)
centroids.extend(p_centroids)
normals.extend(p_normals)
areas.extend(p_areas)
######################
# Slot floor #
######################
filename = "model_outputs/floor.csv" if save_to_files else None
p_centroids, p_normals, p_areas = gen_plane([-W / 2, -H, - depth / 2],
[-W / 2, -H, depth / 2],
[W / 2 - total_asym_offset / 2, -H, - depth / 2],
n_slot_floor, filename=filename)
centroids.extend(p_centroids)
normals.extend(p_normals)
areas.extend(p_areas)
######################
# Slot walls #
######################
filename = "model_outputs/left_wall.csv" if save_to_files else None
p_centroids, p_normals, p_areas = gen_plane([-W / 2, 0, - depth / 2],
[-W / 2, 0, depth / 2],
[-W / 2, -H, - depth / 2],
n_slot_wall, filename=filename)
centroids.extend(p_centroids)
normals.extend(p_normals)
areas.extend(p_areas)
filename = "model_outputs/right_wall.csv" if save_to_files else None
p_centroids, p_normals, p_areas = gen_plane([W / 2 - total_asym_offset / 2, -H, - depth / 2],
[W / 2 - total_asym_offset / 2, -H, depth / 2],
[W / 2 + total_asym_offset / 2, 0, - depth / 2],
n_slot_wall, filename=filename)
centroids.extend(p_centroids)
normals.extend(p_normals)
areas.extend(p_areas)
return centroids, normals, areas
def gen_varied_step(n=3000, H=3, length=50, depth=50, thresh_dist=6, density_ratio=0.25, save_to_files=False):
"""
Generates a step with varying panel density.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment