Skip to content
Advertisement

Rotate a line by a specific angle

I have a line with lenght of l and p1 and p2 and i want to rotate it by angle. I was using this matrix but it doesn’t work.

matrix

I have this code in python:

JavaScript

Advertisement

Answer

You first need to specify an origin point, the rotation will be created around that point. You can adapt your code and use something like this:

JavaScript

You can then plot some point and see the results with:

JavaScript

line plot

Where you can clearly see the rotation around the middle point between the two lines.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement