# Matrix 4x4 Transforms MCP for AI Agents MCP

> The Matrix 4x4 Transforms MCP handles all necessary linear algebra for advanced 3D graphics and simulation. It lets your AI client construct complex transformation pipelines by generating, composing, and applying specialized matrices—including translation, rotation, scale, and shear. You'll get precise control over model, view, and projection stages, converting between formats like quaternions and Euler angles to keep your rendering math accurate.

## Overview
- **Category:** mathematics
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_t9qyjwoYaMxt4rULFDjnoXzc2DJ8DDyXkYxd33os/mcp
- **Tags:** matrix, transform, rotation, quaternion, euler-angles, homogeneous-coordinates, 3d-math

## Description

Building a robust 3D graphics engine requires managing complex transformations, and this MCP gives you the tools for it. It lets your AI client generate foundational matrices—like those that position an object (translation) or orient it (rotation)—and then combine them in the correct mathematical order to create one composite matrix. You can also take a raw 3D point and apply a full transformation, managing perspective division automatically. For geometry pipelines, it's critical to switch between different representations, like converting rotation matrices into quaternions for smoother interpolation or extracting Euler angles when needed. If you're building simulations, this MCP provides the necessary structure; just connect it via Vinkius and your agent handles the heavy lifting of matrix math.

## Tools

### axis_angle_to_quaternion
Converts a rotation defined by an axis and angle into a quaternion format.

### compose_transforms
Combines several separate transformation matrices into one single, usable composite matrix.

### create_rotation_matrix
Generates a 4x4 rotation matrix around a specified axis for any given angle.

### create_scale_matrix
Creates a 4x4 matrix that uniformly or non-uniformly scales objects along the X, Y, and Z axes.

### create_shear_matrix
Generates a 4x4 shear matrix, allowing you to skew an object's geometry across its axes.

### create_translation_matrix
Produces a 4x4 transformation matrix used specifically for shifting objects from one coordinate point to another.

### matrix_to_euler_angles
Extracts the corresponding Euler angles (roll, pitch, yaw) from an existing rotation matrix.

### quaternion_to_axis_angle
Converts a quaternion representation of rotation back into an axis-angle pair.

### quaternion_to_rotation_matrix
Converts a quaternion value directly into a standard 3x3 rotation matrix.

### rotation_matrix_to_quaternion
Takes an existing 3x3 rotation matrix and converts it into its quaternion equivalent.

### transform_point
Applies a full 4x4 transformation to a single 3D point, adjusting for perspective division in the process.

## Prompt Examples

**Prompt:** 
```
I need to compose a transform that moves my character 10 units forward, scales it up by 1.5x, and rotates it 30 degrees around the Y-axis.
```

**Response:** 
```
The combined transformation matrix is ready. It incorporates scaling (1.5 on all axes), rotation (30° about Y), and translation (10 units Z). 

**Composite Matrix:** 
```
[ [ 1.5, 0, 0,  10 ]
[ 0, 1.5, 0,  0 ]
[ 0, 0, 1.5,  0 ]
[-0.5, 0, 0,  1 ]
]```
Use this matrix to render the model; it correctly handles all three stages of transformation.
```

**Prompt:** 
```
Convert a rotation from a quaternion into an axis-angle format for logging purposes.
```

**Response:** 
```
**Quaternion Input:** (0.5, 0.5, 0.5, 0.5)

**Conversion Result:**
*   **Axis:** (1/√3, 1/√3, 1/√3) ≈ (0.577, 0.577, 0.577)
*   **Angle:** 125.26°

The rotation is equivalent to an angle of approximately 125 degrees around the axis pointing through equal coordinates.
```

**Prompt:** 
```
Apply a full transformation matrix to the point (5, 10, 3) and tell me where it ends up.
```

**Response:** 
```
**Input Point:** (X=5, Y=10, Z=3)
**Applied Matrix:** *[Full 4x4 Matrix]

The resulting transformed coordinates are approximately **(2.1, 8.9, 7.6)**.

*Note: The final coordinate set is calculated after applying the perspective divide (W component).* This means the point has been correctly projected into the view space.
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

**Prompt:** 
```
undefined
```

**Response:** 
```
undefined
```

## Capabilities

### Build a comprehensive transformation pipeline
Combine multiple specialized matrices into one final matrix that defines an object's complete position, orientation, and size in the scene.

### Define basic spatial transformations
Generate core 4x4 matrices for simple shifts (translation), uniform sizing changes (scale), or skewing/shearing along axes.

### Transform coordinates in 3D space
Apply a complete transformation matrix to an individual 3D point, handling perspective division correctly for accurate rendering.

### Convert rotational data formats
Switch between rotation matrices, quaternions, and axis-angle representations, solving common mathematical problems like gimbal lock detection.

## Use Cases

### Placing a character in the virtual world
The agent needs to move a character model from its starting point (A) to a target position (B). It uses `create_translation_matrix` and then combines that with existing rotation matrices to ensure the final placement is mathematically sound.

### Simulating camera movement
The simulation needs to apply both translation (moving through space) and rotational view changes. The agent uses `compose_transforms` to build a combined View Matrix, giving the AI client precise control over the camera's perspective.

### Exporting geometry for rendering
A model needs to be scaled up by 3x and then rotated 45 degrees before being viewed. The agent uses `create_scale_matrix` and `create_rotation_matrix`, composing them together to pass the final matrix to the renderer.

### Analyzing object orientation data
The system receives a raw rotation matrix from an external source. The agent uses `matrix_to_euler_angles` to immediately understand the physical pitch, yaw, and roll of the object for debugging or display purposes.

## Benefits

- Build complete object placements: Use `compose_transforms` to combine scale, rotation, and translation into one matrix, eliminating manual multiplication errors.
- Handle data conversion instantly: Need to switch between formats? Convert rotations using `quaternion_to_rotation_matrix` or back with `matrix_to_euler_angles` without writing complex math code.
- Perfect point placement: Never guess where an object ends up again. Use `transform_point` to apply any full matrix transformation to a specific 3D coordinate.
- Define core geometry changes: Instantly generate base matrices for movement (`create_translation_matrix`), sizing (`create_scale_matrix`), or skewing (`create_shear_matrix`).
- Robust rotation handling: Use `rotation_matrix_to_quaternion` to stabilize calculations and avoid issues like gimbal lock when interpolating object orientation.

## How It Works

The bottom line is you feed it raw geometric data—a point or a list of required transforms—and it returns the mathematically correct output for your graphics engine.

1. Start by generating the necessary foundational matrix (e.g., using `create_translation_matrix` or `create_rotation_matrix`) based on your desired shift, size, or orientation.
2. Use `compose_transforms` to multiply these matrices in the correct order, creating a single composite matrix that defines the object's final state for rendering.
3. Finally, pass this composite matrix and the target 3D point into `transform_point` to get the resulting coordinates after all transformations are applied.

## Frequently Asked Questions

**What is homogeneous coordinates and why are they used?**
Homogeneous coordinates represent 3D points as 4D vectors [x, y, z, w]. This representation enables translation and projection operations to be expressed as linear transformations using 4x4 matrices. Points are converted back to 3D by dividing by the w-component (perspective divide) when w ≠ 1.

**How do I compose multiple transformation matrices?**
Use the `compose_transforms` tool with an array of matrices in application order. The first listed matrix is applied first to the point. Composition uses right-to-left multiplication: if a point transforms first by matrix A then by matrix B, the composition is B × A.

**What is gimbal lock and how does this tool handle it?**
Gimbal lock occurs when rotation axes align, causing loss of a degree of freedom. The `matrix_to_euler_angles` tool detects this condition and returns a `gimbal_lock` flag with an explanation. This helps identify problematic rotation sequences in your graphics pipeline.

**Why use quaternions instead of rotation matrices?**
Quaternions avoid gimbal lock and are numerically stable for interpolation and composition. The `quaternion_to_rotation_matrix`, `quaternion_to_axis_angle`, and `axis_angle_to_quaternion` tools enable seamless conversion between quaternion and matrix representations for optimal performance in different scenarios.