Calculus Mesh Viewer API
Compute volume, surface area, and generate a 3D mesh (STL) for common calculus solids.
Overview
URL: https://api.marsthelimit.com/calculate
Authentication: API Key required via header ("Authorization": "Bearer YOUR_API_KEY")
Supported format: JSON
The Calculus Mesh Viewer lets you:
-
Compute volume of solids using disk, washer, or cross-section methods
-
Approximate surface area
-
Generate a downloadable 3D STL model
All requests are made via a JSON payload.
Request Method
POST
https://calculus-mesh-viewer.p.rapidapi.com/calculus-mesh-visual
Body: JSON
Features
Disk
(disk)
Rotates a single function around a horizontal axis (y = constant) using the disk method.
Example:
1{ 2 "method": "disk", 3 "function": "x", 4 "bounds": { 5 "x_min": 0, 6 "x_max": 2 7 }, 8 "rotation-axis": "y=0", 9 "resolution": 100 10}
Notes
-
rotation-axisis optional (defaults to "y=0") -
Function should be written in Python syntax
Multi-Region Disk
(disk-multiregion)
Use this when your solid must be built from multiple piecewise regions.
Example:
1{ 2 "method": "disk-multiregion", 3 "regions": [ 4 { 5 "function": "acos(x)", 6 "x_min": 0.5403023059, 7 "x_max": 1 8 }, 9 { 10 "function": "log(x)", 11 "x_min": 1, 12 "x_max": 2.718281828 13 } 14 ], 15 "resolution": 100, 16 "rotation-axis": "y=1" 17}
Washer
(washer)
Rotates a region between two curves around a horizontal axis.
outer-function must be greater than or equal to inner-function over the interval.
Example:
1{ 2 "method": "washer", 3 "outer-function": "x^2", 4 "inner-function": "x", 5 "bounds": { 6 "x_min": 3, 7 "x_max": 4 8 }, 9 "rotation-axis": "y=0", 10 "resolution": 100 11}
Sections
(section)
Constructs solids with known cross-sections perpendicular to the x-axis.
Supported shapes:
-
semicircle
"semicircle" -
square
"square" -
rectangle
"rectangle" -
equilateral triangle
"equilateral" -
isosceles right triangle (leg as base)
"isosceles-right-leg" -
isosceles right triangle (hypotenuse as base)
"isosceles-right-hypotenuse"
Example:
1{ 2 "method": "section", 3 "outer-function": "x**2", 4 "inner-function": "0", 5 "bounds": { 6 "x_min": 1, 7 "x_max": 10 8 }, 9 "resolution": 100, 10 "section-type": "rectangle", 11 "factor": 2 12}
Parameters
| Field | Description |
|---|---|
section-type | Shape of cross section |
factor | Width/height ratio (only used for rectangles) |
Common Parameters
| Field | Required | Description |
|---|---|---|
bounds.x_min | yes | Start of interval |
bounds.x_max | yes | End of interval |
resolution | yes | Number of slices (higher = more accurate) |
rotation-axis | optional | Format "y=<number>" |
Usage and Example
The api will return json in the following format:
1{ 2 "output_url": "https://api.marsthelimit.com/tmp/models/7d5178ab-e891-400c-8caa-dfc3c7709286.stl", 3 "surface_area": 10.721228382589963, 4 "volume": 2.0438602006652666 5}
To access your 3D model, visit the link and it should automatically download. If it doesn't, please contact me or try again.
Example of an API request in Python that automatically downloads the 3D model:
1import json 2import requests 3import webbrowser 4 5# Load request body from file 6with open('data.json', 'r') as f: 7 data = json.load(f) 8 9url = "https://calculus-mesh-viewer.p.rapidapi.com/calculus-mesh-visual" 10 11headers = { 12 "Content-Type": "application/json", 13 "X-RapidAPI-Key": "YOUR_RAPIDAPI_KEY_HERE", 14 "X-RapidAPI-Host": "calculus-mesh-viewer.p.rapidapi.com" 15} 16 17# Send request 18response = requests.post(url, json=data, headers=headers) 19 20# Basic error handling 21if response.status_code != 200: 22 print("Request failed:", response.status_code) 23 print(response.text) 24 exit() 25 26# Parse result 27result = response.json() 28 29# Extract values 30url = result.get('output_url') 31volume = result.get('volume') 32surface_area = result.get('surface_area') 33 34# Open model automatically 35if url: 36 webbrowser.open(url) 37 38# Print results 39print("3D Model URL:", url) 40print("Approximate Volume:", volume) 41print("Approximate Surface Area:", surface_area)
Notes & Best Practices
-
Use higher resolution for smoother meshes (100–500 recommended)
-
Ensure functions are continuous on the interval
-
Washer method requires outer greater than or equal to inner
-
Large resolutions increase computation time
Need Help?
I'm always happy to help! Contact me at https://marsthelimit.com/contact
About the Author
This article was written by Boden Bensema, an electronics hobbyist focused on teaching beginner-friendly circuit design, breadboarding, and electronics fundamentals.
About page