Skip to content

Bug in "Matrix math for the web" - manual rotation example discards original point angle #43525

@familyboat

Description

@familyboat

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Matrix_math_for_the_web

What specific section or headline is this issue about?

Rotation matrix

What information was incorrect, unhelpful, or incomplete?

const transformedPoint = [
  Math.cos(rotationInRadians) * distance,
  Math.sin(rotationInRadians) * distance,
];

The code above calculating transformed point misses the original point angle.

What did you expect to see?

In this case, the original point angle should be preserved.

const originalAngleInRadians = Math.atan2(point[1], point[0]);
const transformedPoint = [
  Math.cos(originalAngleInRadians + rotationInRadians) * distance,
  Math.sin(originalAngleInRadians + rotationInRadians) * distance,
];

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details

Metadata

Metadata

Assignees

No one assigned

    Labels

    Content:WebAPIWeb API docsaccepting PRFeel free to open a PR to resolve this issue

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions