mathrok
Version:
AI-powered symbolic mathematics library combining traditional Computer Algebra System (CAS) capabilities with natural language processing for math problem solving
118 lines • 3.34 kB
TypeScript
/**
* Graph generation module for Mathrok
* Provides lightweight plotting capabilities for mathematical functions
*/
import { MathEngine } from '../core/engine/index.js';
/**
* Graph point
*/
export interface Point {
x: number;
y: number;
z?: number;
}
/**
* Graph options
*/
export interface GraphOptions {
width?: number;
height?: number;
xMin?: number;
xMax?: number;
yMin?: number;
yMax?: number;
zMin?: number;
zMax?: number;
xLabel?: string;
yLabel?: string;
zLabel?: string;
title?: string;
gridLines?: boolean;
axisLabels?: boolean;
points?: number;
lineColor?: string;
backgroundColor?: string;
axisColor?: string;
gridColor?: string;
pointColor?: string;
lineWidth?: number;
pointSize?: number;
showLegend?: boolean;
}
/**
* Graph data
*/
export interface GraphData {
points: Point[];
expression: string;
variable: string;
type: '2d' | '3d' | 'parametric';
color?: string;
label?: string;
}
/**
* Graph renderer interface
*/
export interface GraphRenderer {
render(container: HTMLElement, data: GraphData[], options: GraphOptions): void;
renderToSVG(data: GraphData[], options: GraphOptions): string;
renderToCanvas(data: GraphData[], options: GraphOptions): HTMLCanvasElement;
renderToImage(data: GraphData[], options: GraphOptions): string;
}
/**
* Graph generator class
*/
export declare class GraphGenerator {
private engine;
private renderer;
constructor(engine: MathEngine);
/**
* Set the renderer
*/
setRenderer(renderer: GraphRenderer): void;
/**
* Generate points for a 2D function
*/
generatePoints2D(expression: string, variable?: string, options?: GraphOptions): GraphData;
/**
* Generate points for a 3D function
*/
generatePoints3D(expression: string, options?: GraphOptions): GraphData;
/**
* Generate points for a parametric function
*/
generateParametricPoints(expressionX: string, expressionY: string, parameter?: string, tMin?: number, tMax?: number, options?: GraphOptions): GraphData;
/**
* Plot a 2D function
*/
plot2D(container: HTMLElement, expression: string, variable?: string, options?: GraphOptions): void;
/**
* Plot a 3D function
*/
plot3D(container: HTMLElement, expression: string, options?: GraphOptions): void;
/**
* Plot a parametric function
*/
plotParametric(container: HTMLElement, expressionX: string, expressionY: string, parameter?: string, tMin?: number, tMax?: number, options?: GraphOptions): void;
/**
* Plot multiple functions
*/
plotMultiple(container: HTMLElement, expressions: string[], variable?: string, options?: GraphOptions): void;
/**
* Generate SVG for a 2D function
*/
generateSVG(expression: string, variable?: string, options?: GraphOptions): string;
/**
* Generate image for a 2D function
*/
generateImage(expression: string, variable?: string, options?: GraphOptions): string;
/**
* Evaluate an expression at a specific value
*/
private evaluateExpression;
/**
* Evaluate a 3D expression at specific x,y values
*/
private evaluateExpression3D;
}
//# sourceMappingURL=graph.d.ts.map