Reference

Home Reference Index Editor Element Tab

Formula Elements



Introduction

The formula elements allow advanced users to create elements of track based on equations to mathematically shape the track. The idea is to create program code using available functions and variables that will generate track positions and roll point information using a time variable going from 0 to 1 as input. The formula element language and concept is very similar to the Elementary tool from Gravimetric Studios. The main difference is that the program in NoLimits 2 formula elements are stateless. This means, that the content of variables will get lost after each iteration. Variables will implicitly be initialized to 0.


Examples

Example 1: The following example will create a 10 meter long staight. length is a custom variable that will be set to 10. x, y, z are the output variables for the positions. t is the time input variable that will go from 0 to 1.

  length = 10
  x = 0
  y = 0
  z = t * length


Example 2: The following example will create three thirds of a circle (270 degrees) with a radius of 10 meters. sin, cos are built-in functions, pi is a built-in constant.

  radius = 10
  angle = 270
  rad = t * angle / 180 * pi
  x = radius * sin(rad)
  z = radius * cos(rad)



Development Environment

New

Starts a blank formula.

Open

Opens an existing formula and its settings from a .nl2formelem file.

Save

Saves the current formula and settings to a .nl2formelem file using the file name from the last Save As command.

Save As

Saves the current formula and settings to a new .nl2formelem file.

Help

Opens this help window

Wizard

Opens the Wizard Setup for creating or changing Wizard questions.

Create

Creates an element (series of vertices and roll points) inside the editor. An active coaster needs to be present inside the park.

Cancel

Closes the development environment

Number of Roll Points

The number of roll points that will be created along the element. The minimum is two roll points(one point at the beginning and one at the end).

Formula

The text area used to program the lines of formulas.

Line

The current line of the cursor inside the formula text area. This may help to identify the location of syntax errors.


Language

Core Functionality

=   Assign value to variable
+   Addition
-   Subtraction (Or denote negative value)
*   Multiplication
/   Division
;   Comment

Switch ( X ) {
    case [ Min, Max ] {
        ; will be executed if Min <= X <= Max.
    }
    case ] Min, Max [ {
        ; will be executed if Min < X < Max.
    }
    case ] Min, Max ] {
        ; will be executed if Min < X <= Max.
    }
    case [ Min, Max [ {
        ; will be executed if Min <= X < Max.
    }
    case [ Val ] {
        ; will be executed if X = Val.
    }
    else {
        ; optional else branch, will be executed if no other case matches.
    }
}

Reserved Variables

T  = Loop Time at element (0..1) Input variable
X  = Plot Position X (meters) at Current Time Output variable
Y  = Plot Position Y (meters) at Current Time Output variable
Z  = Plot Position Z (meters) at Current Time Output variable
B  = Banking (radians) at Current Time Output variable
VertRoll  = Banking Type (set to 0 for horizontal roll, set to <>0 for vertical roll) Output variable

Constant Variables

Pi  = 3.14159265358979323846
Eg  = 9.81 (m/s) Earth Gravity

Functions

Sin( Val )Sine of Val using radians
Cos( Val )Cosine of Val using radians
Tan( Val )Tangent of Val using radians
ASin( Val )Arcsine of Val
ACos( Val )Arccosine of Val
ATan( Val )Arctangent of Val
ATan2( Val1, Val2 )Arctangent of Val1/Val2
Abs( Val )Absolute Value of Val
Int( Val )Integer Value of Val
Rnd( Val )Random Value Between 0 and Val
Sign( Val )-1 for Val<0; 0 for Val=0; +1 for Val>0
Sqrt( Val )Square Root of Val
Pwr( Val1, Val2 )Value of Val1 to the Power of Val2
Log( Val )Natural logarithm of Val
Min( Val1, Val2 )Returns Smaller Value of Either Val1 or Val2
Max( Val1, Val2 )Returns Larger Value of Either Val1 or Val2



Wizard Setup

The Wizard setup allows creation and parameterization of questions that will be asked when the element will be selected from the Add Element option on the Track Tab inside the editor.

Name

Set a name that will be displayed when the element will be loaded.

Set Preview

Set the preview thumbnail picture that will be displayed on the File Browser. The image will be embedded inside the .nl2formelem file.

Variables

Lists all variables used in the formula element program.

Questions

List of questions that will get asked. [ > ] can be used to create a question from a selected variable. [ < ] will remove a question. The currently selected question can be parameterized using the following settings:

Brief Description

Short description of the current question that will get asked.

Detailed Description

Long description of the current question that will get asked.

Minimum Value

The minimum value the user can enter.

Maximum Value

The maximum value the user can enter.

Default Value

The default value of the variable.

Allow Decial Values

When not selected, the user can only enter integer numbers.

Allow Value of Zero

When not selected, the user cannot enter '0', even when it is in between the range of minimum and maximum.

Unit

Select a unit that will be displayed. The 'converted' options will automatically convert the entered values depending on the selected Unit System (imperial or metric).