DGS Studio

Linear Algebra / Matrices

Rotation

Rotate the unit square about the origin.

rotation(45) turns the plane by 45 degrees counterclockwise about the origin. The matrix is [[cos θ, −sin θ], [sin θ, cos θ]] with θ in radians inside the engine.

A 90° turn sends (x, y) to (−y, x). A 45° turn uses equal sine and cosine, √2/2, so the unit square's corners land on the diagonals. The determinant of a rotation is 1, so areas and orientation stay the same.

Equation

rotation(45)

What the matrix does to the plane

A 2D linear transformation sends the plane through a matrix. The columns of the matrix are the images of the unit vectors (1, 0) and (0, 1). The unit square is the default shape, so you can see where the square goes.

The determinant is the signed area scale. A negative determinant flips orientation. A zero determinant collapses the square onto a line or a point, and the inverse does not exist. Eigenvectors, when they are real, are directions the matrix only stretches.

Reading the input

Try a change

Generate Graph posts the expression to the studio graph engine and draws the result on the homepage. The editable field is the entire input, including every line.

Edit and generate

Generate Graph opens the studio homepage and runs this field. Open in DGS Studio loads the same text and waits for you to generate it. The equation is sent once, as a query parameter.

Related examples