Dataset Viewer
Auto-converted to Parquet Duplicate
Search is not available for this dataset
image
imagewidth (px)
665
2.11k
label
class label
4 classes
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
0circle
1ellipse
1ellipse
1ellipse
1ellipse
1ellipse
1ellipse
1ellipse
1ellipse
1ellipse
End of preview. Expand in Data Studio

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

AnalyticSDF

Automatic Diagram Generation for Analytic Geometry Problems using Signed Distance Fields

Example Output

Python PyTorch Accuracy Problems License


Introduction

AnalyticSDF is an automatic system that converts mathematical geometry problem text into accurate visualizations. By leveraging Signed Distance Fields (SDF) combined with differentiable optimization, the system can automatically generate precise conic section diagrams from symbolic geometric expressions.

Traditional geometry diagram generation often relies on manual drawing or rule-based methods. This system takes a different approach: it models geometric constraints as differentiable loss functions and uses gradient-based optimization to find curve parameters that satisfy all constraints, ultimately rendering high-quality geometric diagrams.

Key Features

  • Fully Automated: Generate PNG diagrams directly from JSON-formatted geometry problems without manual intervention
  • High Accuracy: Achieves 96.7% validation pass rate on parseable problems
  • Large-Scale Validation: Tested on 10,861 geometry problems across 3 datasets
  • Rigorous Verification: Multi-dimensional geometric property validation including focus position, eccentricity, and asymptote slope

Supported Curve Types

The system supports four classical conic sections, each with complete SDF representation and constraint validation:

Curve Type Standard Form Validated Properties
Ellipse xΒ²/aΒ² + yΒ²/bΒ² = 1 Focus distance cΒ²=aΒ²-bΒ², eccentricity, points on curve
Hyperbola xΒ²/aΒ² - yΒ²/bΒ² = 1 Focus distance cΒ²=aΒ²+bΒ², asymptote slope, eccentricity
Parabola yΒ² = 4px Focus position, directrix equation, points on curve
Circle (x-h)Β² + (y-k)Β² = rΒ² Center position, radius, points on curve

How It Works

The system follows a four-stage pipeline:

Text Parsing β†’ SDF Construction β†’ Constraint Optimization β†’ Diagram Rendering

1. Text Parsing

Extract geometric parameters from mathematical expressions. For example:

Input:  "ellipse xΒ²/4 + yΒ²/9 = 1"
Output: Ellipse(a=2, b=3, center=(0,0))

The parser supports various expression formats including fractions, radicals, and LaTeX-formatted mathematical expressions.

2. SDF Construction

Build a signed distance field function for each curve type. The SDF value represents the signed distance from any point in space to the curve boundary:

  • Positive: point is outside the curve
  • Negative: point is inside the curve
  • Zero: point is exactly on the curve

3. Constraint Optimization

Optimize curve parameters via gradient descent to satisfy all geometric constraints:

# Total loss = point constraint + focus constraint + eccentricity constraint + crowd penalty
L_total = λ₁·L_point + Ξ»β‚‚Β·L_focus + λ₃·L_ecc + Ξ»β‚„Β·L_crowd

Using the AdamW optimizer, convergence typically occurs within 100-200 iterations.

4. Diagram Rendering

Extract the zero-level set of the SDF (i.e., the curve itself) and render in Chinese Gaokao (ι«˜θ€ƒ) analytic geometry style: white background, black curves, arrow axes through origin with O/x/y labels, feature point annotations (foci, vertices), and auxiliary elements (asymptotes, directrix) as dashed lines. No problem text, grid, or legend is included in the output.


Datasets and Results

The system has been fully tested on three datasets:

Dataset Total Problems Parseable Successful Parseable Accuracy
dev 1,035 809 788 97.4%
test 2,069 1,649 1,596 96.8%
train 7,757 6,052 5,849 96.6%
Total 10,861 8,510 8,233 96.7%

Note: "Parseable" refers to problems with explicit geometric expressions (e.g., xΒ²/4 + yΒ²/9 = 1) rather than implicit or parametric forms. Approximately 22% of problems cannot be parsed due to overly complex or incomplete expressions.

Curve Type Distribution

Type Dev Test Train Total
Ellipse 220 467 1,734 2,421
Hyperbola 293 565 2,025 2,883
Parabola 262 532 2,000 2,794
Circle 13 32 90 135

Installation and Usage

Requirements

  • Python >= 3.9
  • PyTorch >= 2.0.0
  • NumPy >= 1.24.0
  • Matplotlib >= 3.7.0
  • tqdm >= 4.65.0

Install Dependencies

pip install -r requirements.txt

Running Examples

# Process test dataset
python src/main.py --input data/test_en.json --output results/test/

# Process dev dataset
python src/main.py --input data/dev_en.json --output results/dev/

# Process train dataset (~30 minutes)
python src/main.py --input data/train_en.json --output results/train/

# Process only first 100 problems with verbose output
python src/main.py -i data/test_en.json -o results/test/ -m 100 -v

Command Line Arguments

Argument Description Default
-i, --input Input JSON file path data/test_en.json
-o, --output Output directory results/
-m, --max Maximum number of problems to process All
-v, --verbose Enable verbose output False

Python API

from src.sdf_geo import SDFBatchProcessor

# Create processor
processor = SDFBatchProcessor(output_dir='results/')

# Batch processing
results = processor.process_batch('data/test_en.json', max_problems=100)

# Calculate success rate
success_rate = sum(r['success'] for r in results) / len(results)
print(f"Success rate: {success_rate:.1%}")

Project Structure

Image_SDF/
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ dev_en.json          # Dev set (1,035 problems)
β”‚   β”œβ”€β”€ test_en.json         # Test set (2,069 problems)
β”‚   └── train_en.json        # Train set (7,757 problems)
β”œβ”€β”€ results/
β”‚   β”œβ”€β”€ dev/                 # Dev set results
β”‚   β”œβ”€β”€ test/                # Test set results
β”‚   └── train/               # Train set results
β”œβ”€β”€ samples/                 # Sample images (3 per curve type per dataset)
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.py              # CLI entry point
β”‚   └── sdf_geo/             # Core modules
β”‚       β”œβ”€β”€ primitives.py    # SDF geometric primitives
β”‚       β”œβ”€β”€ constraints.py   # Differentiable constraint functions
β”‚       β”œβ”€β”€ parser.py        # Expression parser
β”‚       β”œβ”€β”€ optimizer.py     # Gradient optimizer
β”‚       β”œβ”€β”€ processor.py     # Batch processing, validation & visualization
β”‚       └── renderer.py      # SDF field evaluation & curve rendering
β”œβ”€β”€ create_samples.py        # Generate sample images from results
β”œβ”€β”€ requirements.txt
└── README.md

Output Format

Each problem generates a PNG image in Chinese Gaokao (ι«˜θ€ƒ) analytic geometry style, containing:

  • Geometric Curve: Black curve rendered from the SDF zero-level set on white background
  • Feature Point Annotations: Foci (F₁, Fβ‚‚), vertices, center, marked as small black dots with labels
  • Coordinate System: Arrow axes through origin with O, x, y labels (no grid)
  • Auxiliary Elements: Asymptotes and directrix rendered as dashed lines

Results are organized by curve type:

results/test/
β”œβ”€β”€ summary.json        # Statistics summary
β”œβ”€β”€ circle/             # Circle diagrams
β”œβ”€β”€ ellipse/            # Ellipse diagrams
β”œβ”€β”€ hyperbola/          # Hyperbola diagrams
└── parabola/           # Parabola diagrams

Validation Standards

The system employs multi-dimensional geometric property validation to ensure mathematical correctness of generated diagrams:

Validation Item Tolerance Description
Point on curve 0.03 SDF(p) β‰ˆ 0
Eccentricity 0.05 |e_calculated - e_target| < tol
Focus position 0.05 |c_calculated - c_given| < tol
Asymptote slope 0.05 |b/a - slope| < tol

Methodology

This implementation is based on the methodology described in:

GeoSDF: Plane Geometry Diagram Synthesis via Signed Distance Field

The core ideas of using signed distance fields for geometric representation and differentiable optimization for constraint satisfaction are derived from this work.


License

MIT License

Downloads last month
6,912