---
title: "Calculate the slope, y-intercept, line equation, angle, and distance between two points in a 2D Cartesian plane. Given coordinates (x1, y1) and (x2, y2), computes slope (rise/run), y-intercept, the equation in slope-intercept form (y = mx + b), angle in degrees relative to the x-axis, and Euclidean distance. Handles vertical and horizontal lines as special cases. Useful for surveying, civil engineering grade calculations, linear regression visualization, and physics kinematics problems."
method: POST
path: "/api/slope_calc"
tags: ["general"]
---

# Calculate the slope, y-intercept, line equation, angle, and distance between two points in a 2D Cartesian plane. Given coordinates (x1, y1) and (x2, y2), computes slope (rise/run), y-intercept, the equation in slope-intercept form (y = mx + b), angle in degrees relative to the x-axis, and Euclidean distance. Handles vertical and horizontal lines as special cases. Useful for surveying, civil engineering grade calculations, linear regression visualization, and physics kinematics problems.

`POST /api/slope_calc`

## Request

- Base URL: `https://calc.engineer`
- URL: `https://calc.engineer/api/slope_calc`
- Auth: none declared

## Request body

- object
  - `x1` number, required: X-coordinate of the first point
  - `y1` number, required: Y-coordinate of the first point
  - `x2` number, required: X-coordinate of the second point
  - `y2` number, required: Y-coordinate of the second point

## Response `200`

Computed result for slope_calc

- object
  - `result` object, required
    - `slope` number, nullable, required: Slope of the line (null for vertical lines)
    - `y_intercept` number, nullable, required: Y-intercept of the line (null for vertical lines)
    - `equation` string, required: Line equation in slope-intercept form or 'x = c' for vertical
    - `angle_degrees` number, required: Angle of the line relative to the positive x-axis in degrees
    - `distance` number, required: Euclidean distance between the two points
    - `is_vertical` boolean, required: True if the line is vertical (undefined slope)
    - `is_horizontal` boolean, required: True if the line is horizontal (slope = 0)
  - `tool` string, required
  - `version` string, required
  - `computed_at` string, date-time, required
  - `chain` object, required
    - `feeds` unknown[]
      - unknown
    - `accepts_from` unknown[]
      - unknown

## Other responses

- `400`: Validation error or invalid JSON
- `404`: Tool not found

---

[API](https://skmtc.dev/calc/apis/calc-engineer-api.md) · [All operations](https://skmtc.dev/calc/apis/calc-engineer-api/llms.txt) · [OpenAPI document](https://skmtc.dev/calc/apis/calc-engineer-api/revisions/8830480ec488?raw)
