Trapezoidal Scale / Map Curve from Rectangle to Trapezoid

Hello!

I’m trying to scale a curve in a non-uniform way and was wondering if anyone could help me with my grasshopper script or suggest a better way to approach the problem.

Basically, I’m trying to scale a curve within a rectangular boundary into a trapezoidal boundary. For example, If I was to scale a square inside of a square boundary to a trapezoid boundary, it would look like a smaller version of the new trapezoid (see image below). Here, all I’ve done is scale the bottom edge of the square by 0.5 to create the trapezoid.

I would like to apply this same principle to a compound surface consisting of multiple rectangular surfaces and transform it to a similar compound surface consisting of multiple trapezoids. I tried to accomplish this in a simple GH script using “Map to Surface” and “Sporph” to no avail.


Trapezoid_Scale.gh (20.3 KB)

I’m sure there’s a smart way to do this, but I’m currently a bit stuck. Mathematically, it should be the same as what is happening when a perspective is applied to a geometry. There’s also probably a way to do it with a transform matrix.

Any ideas/help would be greatly appreaciated :slight_smile:

-GG

I think I would use @DanielPiker MeshCageMorph2 to do this.

Reference and target mesh need to have identical topology. You can manipulate the mesh by dragging vertices or eddges in Rhino using the gumball or some automated approach in Grasshopper. You probably want to rebuild the resulting curve…

trapezoid_morph.gh (7.6 KB)

Check this topic here:

1 Like

Hi @martinsiegrist! Thanks for your reply and sorry for taking so long to get back to you.

I downloaded the script you sent me with the component from Daniel Piker. I noticed that that there were some weird kinks in the curve after scaling with the MeshCageMorpher component and that sometimes it failed altogether (see pictures below). I would expect some kinks because of the discontinuities between rate of change of my scaling factor along the Y-Axis, but there are some weird deformations from the MeshCageMorpher within individual trapezoid scaling areas.

I only need to scale my curves in one direction (here along the X-Axis), so I updated my script to use a straightforward, brute-force approach (which I call “Control Point Scale”) to compare with the MeshCageMorpher. My approach scales each of the curve’s control points horizontally based on the width of the trapezoid versus the width of the reference rectangle at the height of the control point along the Y-Axis. I wrote the script to work with both NURBS curves and polylines and it seems to produce pretty good results. The main downside is that it will be computationally heavy once I start to scale many curves at once (which I intend to do later).

It’s hard for me to really say which approach is best, but at least the control point scale approach seems more stable. I compared the relative interior areas of the curves to that of the reference rectangle and scaling trapezoids to try and see which approach maintains this ratio best.

Please let me know if you have any thoughts or a better / more efficient way to approach this problem.

-GG

Trapezoid_Scale.gh (48.2 KB)

IMAGES:

Approach Comparison

MeshCageMorpher


Control Point Scale

Comparison

Area Comparison

Brute-Force Approach - NURBS vs Polyline

CP Scale - NURBS


CP Scale - Polyline

MeshCageMorpher Doesn't Always Work

MeshCageMorpher Problem

I verified my CP Scale approach by mapping UV points between rectangular and trapezoidal surfaces. It’s important to note, though, that my approach only works for symmetric trapezoids that are only being scaled in one direction (in this case horizontally along the X-Axis).