Rotate
Method: point.rotate(centre, angle)
Parameters:
centre— the centre of rotation as aPointangle— the rotation angle in radians (positive = counter-clockwise)
Returns: Point
Description
Rotating a point \(P\) about a centre \(C\) by angle \(\theta\) is performed in three steps:
Translate \(P\) so that \(C\) is at the origin: \(P' = P - C\)
Apply the 2D rotation matrix:
Translate back: add \(C\) to the result.
Written out component-wise:
Sign convention
Following the standard mathematical convention, positive angles rotate counter-clockwise. To rotate clockwise, pass a negative angle.
A full revolution is \(2\pi\) radians (\(360°\)). Common conversions:
Degrees |
Radians |
|---|---|
90° |
\(\pi / 2 \approx 1.571\) |
180° |
\(\pi \approx 3.14159\) |
270° |
\(3\pi / 2\) |
360° |
\(2\pi\) |
Implementation
rotate(centre, angle) {
const x = centre.x + (this.x - centre.x) * Math.cos(angle)
- (this.y - centre.y) * Math.sin(angle);
const y = centre.y + (this.x - centre.x) * Math.sin(angle)
+ (this.y - centre.y) * Math.cos(angle);
return new Point(x, y, this.bulge, this.sequence);
}
Usage in Design
rotate underpins the Rotate command, where every point of each selected
entity is rotated about the user-specified base point by the given angle.
It is also used internally when generating arc geometry — for example, rotating a point around an arc centre to step through arc vertices — and in the AngularDimension to position arrow-head endpoints around a shared intersection point.