Skip to main content

Jsmath

Intro

Use JavaScript to perform mathematical operations on values.

UI

Expression - An area to input mathematical operations/JavaScript expressions.

Result - A read only attribute previewing the result of the Expression.

Add - Use this button to add more indices to the UI.

0: Number - The first index in the array.

info

To reference a row in the expression use the syntax n[index number]. For example, to reference the index labelled 0: Number use the syntax n0.

Any strings with n followed by a value will be coloured to help visually identify them within an expression.

Example

Adding the values of two attributes together.

  1. Create 3 Shapes.
  2. Create a Jsmath Utility.
  3. Connect basicShape1.position.xjsmath.number0.
  4. Connect basicShape2.position.xjsmath.number1.
  5. Enter n0 + n1 into the Expression input.
  6. Connect jsmath.idbasicShape3.position.x to output the result.
Example

Move Shape1 in X at a value of Shape2\sqrt{Shape2}.

  1. Create 2 Shapes.
  2. Create a Jsmath Utility.
  3. Connect basicShape1.position.xjsmath.number0
  4. Enter Math.sqrt(n0) into the Expression input.
  5. Connect jsmath.idbasicShape2.position.x
info

See https://htmlcheatsheet.com/js/ for some JavaScript syntax.

info

To remove indices from the array, select a row or rows, right click and choose Delete Selected Attribute(s).

Right click on an index row and select Rename to rename an index.

Reorder indices by right clicking on a index row and select Reorder.

If Statement

It's possible to write If Statements with the Jsmath Layer. For example...

if (n0 > n1) {1} else {0} or the equivalent ternary n0 > n1 ? 1 : 0

...translate to "If n0 is greater than n1 then output 1. If not, output 0"