mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-12 01:34:12 +02:00
update docs
This commit is contained in:
BIN
docs/images/lib3x-mz_theta_cells-1.JPG
Normal file
BIN
docs/images/lib3x-mz_theta_cells-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 57 KiB |
BIN
docs/images/lib3x-mz_theta_cells-2.JPG
Normal file
BIN
docs/images/lib3x-mz_theta_cells-2.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
BIN
docs/images/lib3x-mz_theta_cells-3.JPG
Normal file
BIN
docs/images/lib3x-mz_theta_cells-3.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
@@ -1,12 +1,12 @@
|
||||
# mz_square_cells
|
||||
|
||||
This function returns cell data of a square maze. The data is a list of cells. A cell has the data structure `[x, y, wallType]`. `x` and `y` are 0-based. `x` means x-th column and `y` means y-th row for a cell. The value of `type` can be `0`, `1`, ``2`, `3` or `4`. Setting them to constants is convenient.
|
||||
This function returns cell data of a square maze. The data is a list of cells. A cell has the data structure `[x, y, type]`. `x` and `y` are 0-based. `x` means the x-th column and `y` means y-th row for a cell. The value of `type` can be `0`, `1`, ``2`, `3` or `4`. Setting them to constants is convenient.
|
||||
|
||||
NO_WALL = 0;
|
||||
TOP_WALL = 1;
|
||||
RIGHT_WALL = 2;
|
||||
TOP_RIGHT_WALL = 3;
|
||||
MASK = 4;
|
||||
NO_WALL = 0; // the cell has no wall
|
||||
TOP_WALL = 1; // the cell has a top wall
|
||||
RIGHT_WALL = 2; // the cell has a right wall
|
||||
TOP_RIGHT_WALL = 3; // the cell has a top wall and a right wall
|
||||
MASK = 4; // the cell is masked.
|
||||
|
||||
The cell data is seperated from views. You can use cell data to construct [different types of mazes](https://www.thingiverse.com/justinsdk/collections/maze-generator).
|
||||
|
||||
|
79
docs/lib3x-mz_theta_cells.md
Normal file
79
docs/lib3x-mz_theta_cells.md
Normal file
@@ -0,0 +1,79 @@
|
||||
# mz_theta_cells
|
||||
|
||||
This function returns cell data of a theta maze. The data is a two-dimensional list with different row lengths. A cell has the data structure `[ri, ci, type]`. `ri` and `ci` are 0-based. `ri` means the ri-th ring and `ci` means the ci-th (counter-clockwise) cell of the ring.
|
||||
|
||||

|
||||
|
||||
The value of `type` is the wall type of the cell. It can be `0`, `1`, ``2` or `3`. Setting them to constants is convenient.
|
||||
|
||||
NO_WALL = 0; // the cell has no wall
|
||||
INWARD_WALL = 1; // the cell has an inward wall
|
||||
CCW_WALL = 2; // the cell has a counter-clockwise wall
|
||||
INWARD_CCW_WALL = 3; // the cell has an inward wall and a clockwise wall
|
||||
|
||||

|
||||
|
||||
**Since:** 3.0
|
||||
|
||||
## Parameters
|
||||
rows, begining_columns
|
||||
- `rows` : The number of rings.
|
||||
- `beginning_number` : The number of cells in the first row.
|
||||
- `start` : The start point to travel the maze. Default to `[0, 0]`.
|
||||
- `seed` : The maze is traveling randomly. Use `seed` to initialize the pseudorandom number generator.
|
||||
|
||||
## Examples
|
||||
|
||||
use <maze/mz_theta_cells.scad>;
|
||||
use <hull_polyline2d.scad>;
|
||||
|
||||
rows = 8;
|
||||
beginning_number = 8;
|
||||
cell_width = 10;
|
||||
wall_thickness = 2;
|
||||
|
||||
NO_WALL = 0;
|
||||
INWARD_WALL = 1;
|
||||
CCW_WALL = 2;
|
||||
INWARD_CCW_WALL = 3;
|
||||
|
||||
function vt_from_angle(theta, r) = [r * cos(theta), r * sin(theta)];
|
||||
|
||||
maze = mz_theta_cells(rows, beginning_number);
|
||||
|
||||
// draw cell walls
|
||||
for(rows = maze) {
|
||||
for(cell = rows) {
|
||||
ri = cell[0];
|
||||
ci = cell[1];
|
||||
type = cell[2];
|
||||
thetaStep = 360 / len(maze[ri]);
|
||||
innerR = (ri + 1) * cell_width;
|
||||
outerR = (ri + 2) * cell_width;
|
||||
theta1 = thetaStep * ci;
|
||||
theta2 = thetaStep * (ci + 1);
|
||||
|
||||
innerVt1 = vt_from_angle(theta1, innerR);
|
||||
innerVt2 = vt_from_angle(theta2, innerR);
|
||||
outerVt2 = vt_from_angle(theta2, outerR);
|
||||
|
||||
if(type == INWARD_WALL || type == INWARD_CCW_WALL) {
|
||||
hull_polyline2d([innerVt1, innerVt2], width = wall_thickness);
|
||||
}
|
||||
|
||||
if(type == CCW_WALL || type == INWARD_CCW_WALL) {
|
||||
hull_polyline2d([innerVt2, outerVt2], width = wall_thickness);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// outmost walls
|
||||
thetaStep = 360 / len(maze[rows - 1]);
|
||||
r = cell_width * (rows + 1);
|
||||
for(theta = [0:thetaStep:360 - thetaStep]) {
|
||||
vt1 = vt_from_angle(theta, r);
|
||||
vt2 = vt_from_angle(theta + thetaStep, r);
|
||||
hull_polyline2d([vt1, vt2], width = wall_thickness);
|
||||
}
|
||||
|
||||

|
Reference in New Issue
Block a user