Commit 9e15d2ae authored by LiberIT's avatar LiberIT

added preliminary support for path avoidance

parent 5ac4264d
......@@ -42,9 +42,9 @@ const input_json = {
Hardyness: hardyness,
Rating: 0,
Full_Shade_Rating: 1,
Heavy_Clay_Rating: 1,
Heavy_Clay_Rating: 3,
Semi_Shade_Rating: 3,
No_Shade_Rating: 4,
No_Shade_Rating: 5,
Nitrogen_Rating: 0,
length: land_length/*m*/,
width: land_width/*m*/,
......@@ -97,8 +97,79 @@ const input_json = {
const strict = "true";
function derive_depth(height) {
return height; //height/Math.tan(0.4);
function derive_depth(plant) {
//return height; //height/Math.tan(0.4);
// derive depth based on row
// emergent_height
// canopy_height
// tree_height
// shrub_height
// herb_height
// ground_cover_height
const path = 0.3;
const widepath = 0.6;
const ground_cover_width = 1;
const herb_width = 2;
const shrub_width = 4;
const tree_width = 8;
const canopy_width = 16;
const emergent_width = 16;
const height = plant.Height;
const depth = height;
const radius = derive_radius(plant);
const seedling_radius = 0.3;
let min_depth = path;
if (depth - radius < min_depth) {
return min_depth + radius;
}
min_depth += ground_cover_width + path;
let max_depth = min_depth + ground_cover_width;
if (depth < max_depth) {
return radius + depth < max_depth? depth: max_depth - radius;
}
min_depth += ground_cover_width + path;
if (depth - radius < min_depth) {
return min_depth + radius;
}
max_depth = min_depth + herb_width;
if (depth < max_depth) {
return radius + depth < max_depth? depth: max_depth - radius;
}
min_depth += herb_width + path;
if (depth - radius < min_depth) {
return min_depth + radius;
}
max_depth = min_depth + shrub_width;
if (depth < max_depth) {
return radius + depth < max_depth? depth: max_depth - radius;
}
min_depth += shrub_width + path;
// this is for trees, they are over 3 meters high so radius can overlap;
if (depth < min_depth) {
return min_depth + seedling_radius;
}
max_depth += tree_width;
if (depth < max_depth) {
return seedling_radius + depth < max_depth? depth: max_depth -
seedling_radius;
}
min_depth += tree_width + widepath;
if (depth < min_depth) {
return min_depth + seedling_radius;
}
max_depth = min_depth + canopy_width;
if (depth < max_depth) {
return seedling_radius + depth < max_depth? depth: max_depth -
seedling_radius;
}
min_depth += canopy_width + widepath;
if (depth < min_depth) {
return min_depth + seedling_radius;
}
max_depth = min_depth + emergent_width;
return depth;
}
function check_available(config, plant) {
......@@ -408,11 +479,33 @@ function fill_height_row(full_plant_list, height, row_length) {
}
return total;
}
function fill_depth_row(full_plant_list, depth, row_length) {
const plant_list = full_plant_list.filter((plant) => {
return derive_depth(plant) == depth? true: false;
});
const random_plant_list = shuffle(plant_list);
// for each plant until row length is filled put in a pair of plants
let row_fill = 0;
let total = new Array();
while (row_fill < row_length) {
const random_index = Math.floor(Math.random()*random_plant_list.length);
const plant = random_plant_list[random_index];
const radius = derive_radius(plant);
const overlap_reduction = derive_overlap_reduction(plant.Height);
const spacing = (radius + radius*overlap_reduction)*2;
//row_fill += radius*4 - crown_overlap*radius*4;
row_fill += spacing*2;
if (row_fill > row_length) break;
total.push(plant);
total.push(plant);// 💚 couple
}
return total;
}
function row_to_SCAD(row_plants, direction) {
let row_fill = 0;
return row_plants.reduce((total, plant, index) => {
const depth = land_offset + derive_depth(plant.Height);
const depth = land_offset + derive_depth(plant);
const radius = derive_radius(plant);
const overlap_reduction = derive_overlap_reduction(plant.Height);
//const this_crown_overlap = crown_overlap - overlap_reduction;
......@@ -439,9 +532,16 @@ function row_to_SCAD(row_plants, direction) {
function depth_filter(total, plant) {
const depth = derive_depth(plant);
if (total.indexOf(depth) == -1) {
return total.concat(depth);
}
return total;
}
function print_SCAD(result) {
let svg = "";
let produce = "";
const filter_by_height = result.filter((plant) => {
return plant.Height > 0? true: false;
});
......@@ -481,30 +581,59 @@ function print_SCAD(result) {
return total;
}, new Array());
svg = svg.concat(no_shade_heights.reduce((total, height) => {
const depth = derive_depth(height); //Math.atan(45)*plant.Height;
const no_shade_depths = no_shade.reduce((total, plant) => {
return depth_filter(total, plant);
}, new Array());
const semi_shade_depths = semi_shade.reduce((total, plant) => {
return depth_filter(total, plant);
}, new Array());
const full_shade_depths = full_shade.reduce((total, plant) => {
return depth_filter(total, plant);
}, new Array());
// produce = produce.concat(no_shade_heights.reduce((total, height) => {
// const depth = derive_depth(height); //Math.atan(45)*plant.Height;
// const row_length = input_json.length-land_offset*2-depth*2;
// const row_plants = fill_height_row(no_shade, height, row_length);
// return total.concat(row_to_SCAD(row_plants, 'S'));
// }, new String()));
// produce = produce.concat(semi_shade_heights.reduce((total, height) => {
// const depth = derive_depth(height); //Math.atan(45)*plant.Height;
// const row_length = input_json.length-land_offset*2-depth*2;
// const row_plants = fill_height_row(semi_shade, height, row_length);
// return total.concat(row_to_SCAD(row_plants, 'E')).concat(
// row_to_SCAD(row_plants, 'W'));
// }, new String()));
// produce = produce.concat(full_shade_heights.reduce((total, height) => {
// const depth = derive_depth(height); //Math.atan(45)*plant.Height;
// const row_length = input_json.length-land_offset*2-depth*2;
// const row_plants = fill_height_row(full_shade.concat(semi_shade),
// height, row_length);
// return total.concat(row_to_SCAD(row_plants, 'N'));
//
// }, new String()));
produce = produce.concat(no_shade_depths.reduce((total, depth) => {
const row_length = input_json.length-land_offset*2-depth*2;
const row_plants = fill_height_row(no_shade, height, row_length);
const row_plants = fill_depth_row(no_shade, depth, row_length);
return total.concat(row_to_SCAD(row_plants, 'S'));
}, new String()));
svg = svg.concat(semi_shade_heights.reduce((total, height) => {
const depth = derive_depth(height); //Math.atan(45)*plant.Height;
produce = produce.concat(semi_shade_depths.reduce((total, depth) => {
const row_length = input_json.length-land_offset*2-depth*2;
const row_plants = fill_height_row(semi_shade, height, row_length);
const row_plants = fill_depth_row(semi_shade, depth, row_length);
return total.concat(row_to_SCAD(row_plants, 'E')).concat(
row_to_SCAD(row_plants, 'W'));
}, new String()));
svg = svg.concat(full_shade_heights.reduce((total, height) => {
const depth = derive_depth(height); //Math.atan(45)*plant.Height;
produce = produce.concat(full_shade_depths.reduce((total, depth) => {
const row_length = input_json.length-land_offset*2-depth*2;
const row_plants = fill_height_row(full_shade.concat(semi_shade),
height, row_length);
const row_plants = fill_depth_row(full_shade.concat(semi_shade),
depth, row_length);
return total.concat(row_to_SCAD(row_plants, 'N'));
}, new String()));
//// can integrate latin name on trunk or something
return svg;
return produce;
}
// a new way of doing the tree planting
......@@ -514,24 +643,24 @@ function print_SCAD(result) {
// tree-web (grid)
// should start with the large plants, then fill in with the smaller ones
// also start with middle can then spiral outwards.
function tree_web_plant(plant_list) {
const web_length = 300;
let tree_web = new Array(web_length);
tree_web.seal();
tree_web = tree_web.map(() => {
return new Array(web_length);
});
//const centre = web_length/2;
const sorted_plant_list = plant_list.sort((first, compare) => {
const height_compare = compare.Height - first.Height;
return height_compare != 0? height_compare:
compare.Rating - first.Rating;
});
sorted_plant_list.reduce((total, plant) => {
let location = {x: derive_depth, y: derive_depth};
return total.concat(plant_print(plant, location)); },
new String());
}
// function tree_web_plant(plant_list) {
// const web_length = 300;
// let tree_web = new Array(web_length);
// tree_web.seal();
// tree_web = tree_web.map(() => {
// return new Array(web_length);
// });
// //const centre = web_length/2;
// const sorted_plant_list = plant_list.sort((first, compare) => {
// const height_compare = compare.Height - first.Height;
// return height_compare != 0? height_compare:
// compare.Rating - first.Rating;
// });
// sorted_plant_list.reduce((total, plant) => {
// let location = {x: derive_depth, y: derive_depth};
// return total.concat(plant_print(plant, location)); },
// new String());
// }
connection.connect((err) => {
......
......@@ -30,8 +30,8 @@ module tree(height_in_m, width_in_m, x_loc, y_loc) {
height_in_m < 10? width_in_m :
height_in_m < 31? 10: 20;
trunk(m_to_mm(height_in_m), m_to_mm(width_in_m/2*trunk_ratio));
canopy(m_to_mm(height_in_m), m_to_mm(width_in_m/2),
m_to_mm(canopy_height));
//canopy(m_to_mm(height_in_m), m_to_mm(width_in_m/2),
// m_to_mm(canopy_height));
}
}
......@@ -91,7 +91,7 @@ module path() {
}
module slough (length, width, depth, offset) {
module swale (length, width, depth, offset) {
polyhedron (points=[[0,0,0],[0,length,0],[offset,length,-depth],
[offset,0,-depth],
......@@ -100,33 +100,33 @@ polyhedron (points=[[0,0,0],[0,length,0],[offset,length,-depth],
}
slough_width = m_to_mm(3);
swale_width = m_to_mm(3);
golden = 1.618;
module the_slough() {
module the_swale() {
length = m_to_mm(100)/golden;
width = slough_width;
width = swale_width;
depth = m_to_mm(1.06);
offset = m_to_mm(1.85);
color("cyan") {
translate([full_road_width/2,slough_width*3,0]) {
slough(length, width, depth, offset);
translate([full_road_width/2,swale_width*3,0]) {
swale(length, width, depth, offset);
}
}
}
module green_field() {
translate([full_road_width/2, slough_width,0]) {
translate([full_road_width/2, swale_width,0]) {
color("green",0.1) {
cube(size=[m_to_mm(48*2),m_to_mm(48*2),100], center=false);
}
}
}
module slough2() {
module swale2() {
translate([0,-full_road_width/2+path_width/2,0]) {
mirror([1,0,0]) {
rotate([0,0,90]) {
the_slough();
the_swale();
}
}
}
......@@ -162,19 +162,27 @@ module a_road(from, to, radius) {
}
function m2mm(m)=m*1000;
a_road([m2mm(6),m2mm(5)],[m2mm(6),m2mm(100-6*2)], m2mm(0.6));
a_road([m2mm(6+5),m2mm(5)],[m2mm(6+5),m2mm(100)], m2mm(0.3));
a_road([m2mm(16),m2mm(5)],[m2mm(16),m2mm(100)], m2mm(0.6));
a_road([m2mm(6),m2mm(5)],[m2mm(100),m2mm(5)], m2mm(0.6));
a_road([m2mm(6),m2mm(11)],[m2mm(100),m2mm(11)], m2mm(0.3));
a_road([m2mm(6),m2mm(16)],[m2mm(100),m2mm(16)], m2mm(0.6));
a_road([m2mm(6),m2mm(5)],[m2mm(6),m2mm(100-6)], m2mm(0.3));
a_road([m2mm(8),m2mm(5)],[m2mm(8),m2mm(100-6)], m2mm(0.3));
a_road([m2mm(12),m2mm(5)],[m2mm(12),m2mm(100-6)], m2mm(0.3));
a_road([m2mm(20),m2mm(5)],[m2mm(20),m2mm(100-6)], m2mm(0.6));
a_road([m2mm(36),m2mm(5)],[m2mm(36),m2mm(100-6)], m2mm(0.6));
a_road([m2mm(6),m2mm(5)],[m2mm(94),m2mm(5)], m2mm(0.3));
a_road([m2mm(6),m2mm(7)],[m2mm(94),m2mm(7)], m2mm(0.3));
a_road([m2mm(6),m2mm(11)],[m2mm(94),m2mm(11)], m2mm(0.3));
a_road([m2mm(6),m2mm(19)],[m2mm(94),m2mm(19)], m2mm(0.6));
a_road([m2mm(6),m2mm(35)],[m2mm(94),m2mm(35)], m2mm(0.6));
//a_road([m2mm(6),m2mm(11)],[m2mm(100),m2mm(11)], m2mm(0.3));
//a_road([m2mm(6),m2mm(16)],[m2mm(100),m2mm(16)], m2mm(0.6));
road();
path();
the_slough();
the_swale();
green_field();
slough2();
swale2();
tinyhome();
person();
......
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