- From: Joe Pea via GitHub <sysbot+gh@w3.org>
- Date: Sat, 21 Dec 2024 08:38:49 +0000
- To: public-fxtf-archive@w3.org
It seems like this can be closed, as I see the following in CSS-Transforms today, which is a 4x4 matrix (which is 3D right?): <img width="861" alt="Screenshot 2024-12-21 at 12 31 13 AM" src="https://github.com/user-attachments/assets/bd48998a-ce61-410e-aeba-cb113020d658" /> Maybe the spec text was at some point less accurate, but I recall back in 2015 that it linked me to the math to implement for my [geometry-interfaces polyfill](https://github.com/trusktr/geometry-interfaces/blob/109b0b68fc93925a626a26ed27743ac580e8647e/src/DOMMatrix.js). Here's [`rotateSelf`](https://github.com/trusktr/geometry-interfaces/blob/109b0b68fc93925a626a26ed27743ac580e8647e/src/DOMMatrix.js#L126C1-L136C6) from back then: ```js rotateSelf (angle, originX = 0, originY = 0) { this.translateSelf(originX, originY) // axis of rotation const [x,y,z] = [0,0,1] // We're rotating around the Z axis. this.rotateAxisAngleSelf(x, y, z, angle) this.translateSelf(-originX, -originY) return this } ``` which used [`rotateAxisAngleSelf`](https://github.com/trusktr/geometry-interfaces/blob/109b0b68fc93925a626a26ed27743ac580e8647e/src/DOMMatrix.js#L143-L147): ```js rotateAxisAngleSelf (x, y, z, angle) { const rotationMatrix = new DOMMatrix(rotateAxisAngleArray(x,y,z,angle)) this.multiplySelf(rotationMatrix) return this } ``` where `rotateAxisAngleArray` had the formulas from that image: ```js export function rotateAxisAngleArray(x: number, y: number, z: number, angle: number) { const {sin, cos} = Math const halfAngle = degreesToRadians(angle / 2) return [ 1 - 2 * (y * y + z * z) * sin(halfAngle) ** 2, 2 * (x * y * sin(halfAngle) ** 2 + z * sin(halfAngle) * cos(halfAngle)), 2 * (x * z * sin(halfAngle) ** 2 - y * sin(halfAngle) * cos(halfAngle)), 0, 2 * (x * y * sin(halfAngle) ** 2 - z * sin(halfAngle) * cos(halfAngle)), 1 - 2 * (x * x + z * z) * sin(halfAngle) ** 2, 2 * (y * z * sin(halfAngle) ** 2 + x * sin(halfAngle) * cos(halfAngle)), 0, 2 * (x * z * sin(halfAngle) ** 2 + y * sin(halfAngle) * cos(halfAngle)), 2 * (y * z * sin(halfAngle) ** 2 - x * sin(halfAngle) * cos(halfAngle)), 1 - 2 * (x * x + y * y) * sin(halfAngle) ** 2, 0, 0, 0, 0, 1, ] } ``` -- GitHub Notification of comment by trusktr Please view or discuss this issue at https://github.com/w3c/fxtf-drafts/issues/354#issuecomment-2558051323 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Saturday, 21 December 2024 08:38:50 UTC