by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Spatial Relations
Introduced first in SolidGeometry 1.6, Creation date: 2014-11-21, Last change: 2025-09-14
PL=PLtransR(PL,R)
PL: | Point List (nx2) | |
R: | Rotation matrix 2x2 |
PL: | Transformed Point list |
Rotate a square
PL=PLcircle(10,4);
CPLplot([PL;NaN NaN;PLtransR(PL,rot(pi/6))]);
This function, PLtransR, is designed to rotate a list of 2D points using a given rotation matrix. Below is a detailed explanation of the algorithm and its parameters.
n x 2 matrix, where each row corresponds to a point in 2D space.2 x 2 rotation matrix. If R is a scalar, it is assumed to be an angle in radians, and the function rot(R) is called to convert it into a rotation matrix.R is a scalar. If true, convert it to a rotation matrix using the rot function.PL by multiplying the rotation matrix R with the transpose of PL, and then transpose the result back.nargout == 0), plot the transformed points using SGfigure and PLplot.To rotate a square, you can use the following example:
PL = PLcircle(10, 4); CPLplot([PL; NaN NaN; PLtransR(PL, rot(pi/6))]);
This example creates a circle of points and then rotates it by pi/6 radians.