Rotating rectangles

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Rotating rectangles

Charles Watson
Good evening everyone!

I use the "Load Command File" to import simple rectangles in the format:

rect;-122.5,-50;@-9,-4
rect;-118.5,-54.5;@-7,-3
rect;-126.5,-54.5;@-7,-3
rect;-96.5,-57.5;@-7,-3
rect;-118.5,-57.5;@-7,-3
rect;-126.5,-57.5;@-7,-3
rect;-96.5,-60.5;@-7,-3

Is there any way to rotate the rectangles, say, to 37° on importing?

Many thanks.

Charles
Reply | Threaded
Open this post in threaded view
|

Re: Rotating rectangles

LordOfBikes
Administrator
Hi Charles,

you can use line instead of rectangle and relative polar coordinates.

For the first rectangle rotated e.g. use:
li;-122.5,-50;@9<180+37;@4<270+37;@9<0+37;@4<90+37

If it is required that the rectangle is a single entity, you can use polyline:
pl;-122.5,-50;@9<180+37;@4<270+37;@9<0+37;close

I used e.g. <180+37 to make the origin direction and the rotation angle visible. LibreCAD does the math for you.

For reference see https://docs.librecad.org/en/latest/ref/fundamentals.html?#polar


Armin
investing less than half an hour into Search function can save hours or days of waiting for a solution
Reply | Threaded
Open this post in threaded view
|

Re: Rotating rectangles

Charles Watson
Hello Armin

Many thanks, again, for a very helpful answer. I will give it a try.

Cheers.

Charles
Reply | Threaded
Open this post in threaded view
|

Re: Rotating rectangles

Charles Watson
In reply to this post by LordOfBikes
Hello Armin

I have had a look at this, and it is not doing exactly what I had hoped.

The method you proposed does rotate the rectangle, but it rotates it around the top right corner. I had hoped to rotate it around the rectangles centre. Is there an easy way to achieve that?

Thanks in advance.

Charles
Reply | Threaded
Open this post in threaded view
|

Re: Rotating rectangles

LordOfBikes
Administrator
Hi Charles,

from command line or command file you can't use rotate tool. There is no way to communicate the center and angle this way.

But I still see some options, depending on the given conditions. I'll use the appended image to clarify my remarks.

So using the pure path method I mentioned above, you will have a rectangle with an additional line fragment. In this case start at the center (1), make a line of (a/2) to (2) and then follow the rectangles circumference (3-4-5-6-2) to create it.
The 1st line from (1) to (2) has then to be deleted after creation.
This method does not need much math, except some addition and subtraction. Even when the center is not given, it is easy calculated with (a/2) and (b/2) addition or subtraction.

When the rectangle commands are created with a spreadsheet, or by software, you can include some math and find the starting point (2) without the extra line.
Given the center (1), rotation angle (ß) and hypotenuse (a/2) you can use sine/cosine functions to compute x and y and thus calculate point 2 to start from. Then simply follow the path like above and have a rotated rectangle without the extra line. But it will be composed from 5 line segments, one side is split.

With a spreadsheet you can even use a bit more complex math and calculate the vector to one of the edge points and create a rectangle from 4 lines, without the splitted segment.

Search for online triangulation sites, there are many of them. There you can explore and develop the needed formulas.

Armin

investing less than half an hour into Search function can save hours or days of waiting for a solution
Reply | Threaded
Open this post in threaded view
|

Re: Rotating rectangles

Charles Watson
Hello Armin

Thanks again for your comprehensive answer. I had thought that this may be the route to take, but had hoped that there may have been a simpler method. Alas, not everything in life is easy!!!

Fortunately, I have used trigonometry throughout my working life and Excel VBA is something I am familiar with. With that in mind, I will use the more complex maths a little bit of pain at the start will lead to long term gains.

Cheers.

Charles