Read. Observe. Learn. :-) DCW Endeavors

Matrix Vector 2D 3D Calculator

Hello, all my web visitors! I present to you another one of my math programming adventures :-)

The top portion of this program is similar to my matrix calculator while the other three sections are:

Here is a blog about some of the details in my reverse engineering effort of the JS 3D rotating cube. Using the basic code model of the rotating cube I was able to create the 3D graphing section of this program.

IMPORTANT for matrix calculations: If entering large numbers, especially numbers with many digits beyond the decimal point it would be best to use From A or From B. Then enter the numbers in the table structure and click To A or To B to continue with the calculations.

If you find any bugs in this program, please contact me at dcwendeavors@gmail.com Thank you :-)

Matrix Vector 2D 3D Calculator

Matrix A

Matrix B

Regular Functions

Vector Calculations

2D Vectors

Vector a

Vector b

c

3D Vectors

Vector a

Vector b

c

3D Functions

Enter required values or angles to create a 3D matrix in the text field at the bottom of this section. Note that n stands for a normal vector (length of 1) and will automatically be calculated when entering your vector. For example, if looking for rotation around an arbitrary axis (2, 3, 4), then just enter 2 for nx, 3 for ny, and 4 for nz, along with an angle value.

The JS code for the calculations below was modeled after matrices explained in the wonderful math book 3D Math Primer for Graphics and Game Development.

Note: make sure to select either Deg (degrees) or Rad (radians) for angle values. Otherwise, the default value is degrees.

Rotations

Enter an angle (left-handed coordinate system).

3D Rotation about X Axis

3D Rotation about Y Axis

3D Rotation about Z Axis

3D Rotation about Arbitrary Axis

Scaling

Enter a number to scale per axis (left-handed coordinate system) with k representing the scale amount per axis. For example scaling 2 times in x direction only would be kx = 2, ky = 0, and kz = 0.

Scaling along cardinal axes

Scaling in arbitrary direction

Projections

Click on a button to provide the needed projection matrix, and then click 'To B' to multiply by a 1x3, 2x3, or 3x3 matrix in A.

Projection onto xy plane

Projection onto xz plane

Projection onto yz plane

Projection onto an arbitrary plane (n is perpendicular to the plane).

Reflections

Enter n (or just enter a vector) that is perpendicular to the reflection plane. A good means to find n is to calculate the cross product of two adjacent vectors on the reflection plane.

Reflection over a plane

Shearing

Example: Suppose we have a 3D cube. Hxy indicates x, y coordinates are shifted at the corresponding s, t inputs. Then, if each point of the 3D cube is multiplied by this matrix, the z values will remain the same, but the x, y values will change, shearing the cube. If 0 is entered for either x or y (s or t) then the corresponding x or y values will not change.