Grasshopper

algorithmic modeling for Rhino

i need an algorithm how to divide an area with into same size, but with different length and width

i have a piece of land. i need to divide the area into 10 equal part (look the splitting), the problem is the shape of the land is not a rectangular more like a trapezoid. anyone know how to do that in grasshopper?

thanks

Views: 4117

Attachments:

Replies to This Discussion

This is a trickier problem than it seems. It actually involves calculus! I'm gonna rotate your trapezoid so the straight edge is along the X axis, and exaggerate its slope to make it easier to see. 

The formula for the area of this trapezoid is H1*W + (H2-H1)*W / 2 - the rectangular portion + the triangular portion:

if we imagine a small segment of the trapezoid, starting from the left, with a width of X, we can calculate the area of that too: 

it will be X*H1 + X *(H2-H1)*(X/W) / 2 - the small rectangular portion + the small triangular portion.

Now, if we imagine some point on the left edge as X=0,Y=0, we can draw a graph of the area in the shaded region as we move to the left, increasing X. The equation of this graph is the area function we just figured out - Y = X*H1 + X * (H2-H1) * (X/W) / 2. This area graph is actually the integral of the equation of the sloped top edge of your trapezoid. We can rewrite that function like this:

H1*X + (H2-H1)/(2*W)*X^2

This function is in the form ax + bx^2, which is a quadratic function. Let's actually plot that graph using Grasshopper, with the lower left corner of the trapezoid as X=0,Y=0. (the Y scale is reduced so we can see the whole graph)

Now, if we know we want 10 equal area subdivisions, we *could* solve the quadratic equation for the areas we're after. But I like to think about this geometrically - and we can actually use grasshopper's geometry tools to calculate it geometrically too. The other advantage of doing this is that our solution will work for any shape along any axis - rather than having to do a bunch of algebra! 

If the idea is that the areas should be equal, then we can think about that as subdividing the area graph with even subdivisions along the Y axis, like so:

Then, we just need to take the X-locations along the graph where those even subdivisions occur, and map them back down to our original trapezoid.

Those lines will subdivide the trapezoid into equal area portions. 

I've attached a Grasshopper definition that solves this problem geometrically the way I've described above. It uses a few little tricks to make everything work, but it basically does what I've described here - graphs the area, divides the area graph into equal vertical segments, and then projects those back down to the driving curve shape. It should work with a region of any shape, divided along any axis! 

Attachments:

thanks a lot andrew for the enlightment :). very complicated, but ill try

Straight forward, nice approach, Andrew!

Here's a way of solving this with Kangaroo

Attachments:

thanks daniel

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service