Testing Waters
  • Scrapbook
  • Projects
    • Bamiyan Cultural Center
    • Bauhaus Museum
    • Better Hebbal
    • Bicycle Station
    • Cross Laminated Timber
    • Facade
    • Flowing Fabrication
    • Form from Images
    • Guggenheim Helsinki
    • National War Museum
    • National War Memorial
    • Indflorescence
    • Rectangular Compartments
    • Retail Space Layout
    • Noise Barrier : Swedevia Airport
    • Walden
    • Wilson Garden
  • Patterns
    • Area Graph
    • Array along Curve
    • Fibbonacci and Factorial
    • Gyroid
    • Hexagonal Pattern From Image
    • Hexagonal Grid
    • Koch Star
    • Mandelbrot Set
    • Pattern
    • Pattern
    • Pattern
    • Phyllotaxis
    • Random Strip Widths
    • Skewed Surface
    • Staggered Checkerboard
    • Triangle subdivision
    • Vector Field
    • Voronoi
    • Waves
    • Weave
  • Geometry
    • Boundary Curve
    • Bridging parallel curves
    • British Museum Great Court
    • Catenary
    • Delete Adjacent
    • Geodesic Sphere
    • Group Branching Curves
    • Group Circles
    • Group curves
    • K Mean
    • Nurbs Surface Irregular
    • Overlapping Petals
    • Pair Nearest
    • Parametric Shapes
    • Platonic Solids
    • Polyline to PolyArc
    • Roman Surface
    • Sagrada Familia Schools Roof
    • Sine Curve
    • Sine Ribbon
    • Spherical Transformations
    • Split Rectangle
    • Tangential Circle through Point
    • Travelling Salesman Problem
    • Unaligned Bounding Box
  • Lists
    • Alter by Boolean Sequence
    • Color by distance
    • Consecutive Points
    • Distancing
    • Divide Equally
    • Geometry from Image
    • Image based Point Density
    • Isovists
    • Reduce Color Palette
    • Replace Consecutive
    • Replace Multiple
    • Replace Recurring
    • Shadow Area
    • Shortest Path
    • Solar Analysis
    • Topography Analysis
  • Motion
    • Adjacency
    • Animate Sphere
    • Cellular Automation
    • Cloth
    • Hypotrochoid
    • Manakin
    • Rolling Spiral
    • Tan Curve
    • Trammel of Archemedes
    • Image to Integer
  • Articles
    • A Conceptual Approach to Integrating Computational Methods in Early Stage Design
    • Design Script's ambiguous and versatile Replication Guides <1>
    • Design Script's ambiguous and versatile Replication Guides <2>
Powered by GitBook
On this page
  1. Geometry

Split Rectangle

Split rectangle by specifying number of divisions, minimum and maximum area

PreviousSpherical TransformationsNextTangential Circle through Point

Last updated 4 years ago

rctg1 = Rectangle.ByWidthLength(10,10);
//Number of Lines
cnt;
//Minimum Area of Polygon
min;
//Maximum Area of Polygon
max;
//Max attempts
atm = 500;

[Imperative]
{
	surf1 = rctg1.Patch();
	lins1 = [];
	c = 0;
	t = [];
	sed = 0;
	test1 = true;
	sed = sed + 1;
	while(test1 && sed<atm)
	{
		lins1 = lins(rctg1,cnt,sed);
		surf1 = spl(rctg1,lins1);
		for (s in surf1)
		{
			if (s.Area<min || s.Area>max)
			{
				t[c] = true;
				c = c + 1;
			}
			else
			{
				t[c] = false;
				c = c + 1;
			}
		}
		sed = sed + 1;
		test1 = List.Contains(t,true);
	}
	return surf1;
};

//Functions
def lins(rec,cnt,sed)
{
	edgs1 = rec.Explode();
	parm1 = List.TakeItems(List.Shuffle(0.1..1..#(Math.Random(sed)*50)),cnt/2);
	parm2 = List.TakeItems(List.Shuffle(0.1..1..#(Math.Random(sed+1)*50)),cnt/2);
	parm3 = List.TakeItems(List.Shuffle(0.1..1..#(Math.Random(sed+2)*50)),cnt/2);
	parm4 = List.TakeItems(List.Shuffle(0.1..1..#(Math.Random(sed+3)*50)),cnt/2);
	pnts1 = edgs1[0].PointAtParameter(parm1);
	pnts2 = edgs1[1].PointAtParameter(parm2);
	pnts3 = edgs1[2].PointAtParameter(parm3);
	pnts4 = edgs1[3].PointAtParameter(parm4);
	lins1 = List.TakeItems(List.Flatten(Line.ByStartPointEndPoint([pnts1,pnts2],[pnts3,pnts4]),-1),cnt);
	return lins1;
};


def spl(rect,lines:var[]..[])
{
//Cutting Tool
tool = Solid.ByUnion(List.Flatten([rect,lines],-1).Extrude(Vector.ZAxis()).Thicken(0.4));

//Divisions
divisions = List.Clean(PolyCurve.ByJoinedCurves(rect.Patch().Split(tool).PerimeterCurves()),false).Offset(0.2,false).Patch();
return divisions;
};
15KB
splitRect.dyn