OMD Documentation

omdEquationNode

Represents a mathematical equation, consisting of a left side, a right side, and an equals sign. This class provides extensive functionality for manipulating the equation, such as applying operations to both sides, swapping sides, simplification, and rendering to various visualization formats.

Class Definition

export class omdEquationNode extends omdNode

Constructor

new omdEquationNode(ast)

Creates a new omdEquationNode instance.

Static Methods

fromString(equationString)

Creates an omdEquationNode instance from a string representation of an equation.

Public Properties

Public Methods

addToBothSides(value)

Returns a new equation with a value added to both sides.

subtractFromBothSides(value)

Returns a new equation with a value subtracted from both sides.

multiplyBothSides(value)

Returns a new equation with both sides multiplied by a value.

divideBothSides(value)

Returns a new equation with both sides divided by a value.

applyFunction(functionName)

Applies a function (e.g., sqrt, log) to both sides of the equation.

applyOperation(value, operation, side = 'both')

Applies an arithmetic operation to one or both sides of the equation.

swapSides()

Swaps the left and right sides of the equation.

simplify()

Simplifies both sides of the equation using the simplification engine.

clone()

Creates a deep clone of the equation node, preserving its structure and provenance.

toString()

Converts the equation to its string representation.

evaluate(variables)

Evaluates both sides of the equation with a given set of variables.

setBackgroundStyle(style)

Configures the background styling for the equation node. This can include backgroundColor, cornerRadius, and pill (for a pill-shaped background).

getEqualsAnchorX()

Returns the horizontal X-coordinate of the center of the equals sign relative to this node's origin. Useful for aligning equations in a sequence.

getBackgroundPaddingX()

Returns the horizontal padding applied by the background style.

getEffectiveBackgroundPaddingX()

Returns the effective horizontal padding used in layout, accounting for factors like pill clamping.

renderTo(visualizationType, options)

Renders the equation to different visualization formats (e.g., graph, table, balance hanger, tile equation).

getLeft()

Returns the omdNode representing the left side of the equation.

getRight()

Returns the omdNode representing the right side of the equation.

Internal Methods

↑ Top