Solved

How to resize polygon (rectangle, square)?

  • 13 February 2019
  • 8 replies
  • 36 views

Badge

Dear,

 

I have a rectangle with width 2 and length 3. How do I increase the width to 3 and length 5? The angle can not be changed.

 

Thank you!

icon

Best answer by gio 13 February 2019, 17:15

View original

8 replies

Userlevel 5
Badge +25

You can use the Scaler to do that, but the catch is that it will scale either from the origin (0,0) of your coordinate system -or- the centerpoint of your object.

If you want to scale from that leftmost corner you'll need to need to get its coordinates, use the Offsetter to bring that corner to 0,0, scale and then offset back to the original position.

Userlevel 1
Badge +10

You can use the Scaler to do that, but the catch is that it will scale either from the origin (0,0) of your coordinate system -or- the centerpoint of your object.

If you want to scale from that leftmost corner you'll need to need to get its coordinates, use the Offsetter to bring that corner to 0,0, scale and then offset back to the original position.

I think a scaler will only work on angled rectangles if there is the x and y scale factors are the same. If the length to width ratio of the rectangle changes as in the example it won't work.

Userlevel 2
Badge +12

I would try this:

Chopper (2 vertices) to get lines for the sides.

LineExtender (extend by 2 if @Length() = 3, extend by 1 if @Length() = 2).

AreaBuilder to reconstruct the polygon.

Userlevel 1
Badge +10

You will probably have to rotate the rectangle, move it to 0,0, scale then move it back. It can be done in a python caller or using a number of transformers. There's probably a question over what is length and what is width in this scenario

scale_angled_rectangle.fmwt

Badge +3

@joaotacio

 

There are a couple of ways to do it as always.

If you don't intend to respect the aspect ratio, then the move and scale tips are invalid.

 

-Chop by 2 and extending is a valid one as it is a rectangle and therefore only has 5 vertices (begin and end being the same)

-chop by 2 and scale using begin or end point as center of scaling and scale factor= new_width/width

 

-chop by 2 and get angle using for instance azimuthcalculator and then get just 1 vertex. Clone it by 3.

Move 2 clones using a vector.

dX= @Evaluate(-$(OFFSET)*@cos($(angle)))

)))

This is same as using Offsetter in polar mode (so you don't need to like enter the expressions yourself).

 

Rebuild by oriented boundingbox on the points.

 

etc.

.

You always need to (of course) relate the new length and width to the objects before any of these processes.

 

Badge +3

@joaotacio

 

There are a couple of ways to do it as always.

If you don't intend to respect the aspect ratio, then the move and scale tips are invalid.

 

-Chop by 2 and extending is a valid one as it is a rectangle and therefore only has 5 vertices (begin and end being the same)

-chop by 2 and scale using begin or end point as center of scaling and scale factor= new_width/width

 

-chop by 2 and get angle using for instance azimuthcalculator and then get just 1 vertex. Clone it by 3.

Move 2 clones using a vector.

dX= @Evaluate(-$(OFFSET)*@cos($(angle)))

)))

This is same as using Offsetter in polar mode (so you don't need to like enter the expressions yourself).

 

Rebuild by oriented boundingbox on the points.

 

etc.

.

You always need to (of course) relate the new length and width to the objects before any of these processes.

 

@joaotacio

Here is a example of a possibility...

XYscaleBox.fmw

 

Badge +3

@joaotacio

 

here is a pic in case the workspace refuses to upload.

Creator and rotator are just for sample creation.

 

Badge

You will probably have to rotate the rectangle, move it to 0,0, scale then move it back. It can be done in a python caller or using a number of transformers. There's probably a question over what is length and what is width in this scenario

scale_angled_rectangle.fmwt

Dear,

 

Thank you for attention. This is solution was perfect!

Reply