Types and Operators
A type specifies the characteristics of a value and determines the set of operations available for the value. Operations include operators, functions and methods. Types that have methods are complex and can have members.
Expression types and cast names
Type | Cast Name | Description |
Boolean | bool | A value that can be True or False. |
Integer | int | A 32-bit signed integer. |
Real | double | A 64-bit floating point value. |
Vector | rVector | A 4 element vector of real values. |
Matrix | rMatrix | A 4x4 matrix of real values, for example 16 elements. |
String | rString | A sequence of characters. |
Reference | object | An address that stores object's variables or methods. |
N/A | A list of objects with the same type. |
Notes:
- The int and double types are mutually compatible.
- The cast name is the name used in a cast operation.
- Casting to String type is not supported.
- List type does not support cast operation.
Boolean types
A Boolean type represents a True or False value and is convertible to a numeric type. When converting a Boolean to numeric, True becomes 1 and False becomes 0. When converting a numeric to Boolean, 0 becomes False and any other number becomes True.
Logical Operators
Any logical operator will return a Boolean type. There are no explicit Boolean literals in expression syntax, so use 1 and 0 for True and False respectively.
Name | Description | |
Logical NOT:
! |
A unary prefix operator that inverts a given logical value.
|
|
Logical AND:
&& |
A binary operator that returns True if both arguments are True. That is, if first argument is False, second argument is not evaluated.
|
|
Logical OR:
|| |
A binary operator returns True if any of the arguments are true. That is, if first argument is True, second argument is not evaluated.
|
Numeric types
A numeric type expresses a scalar value and most have common operators.
Arithmetic Operators
For arithmetic operators, the type of result depends on the type of each argument. If arguments are the same, the common type is sued. If the arguments differ, the type with the highest range is used. This will change the behavior of some operators, for example division, where integer division is performed when both operands are integers.
Name | Description | |
Addition, Subtraction, Multiplication, Division
+ - * / |
Basic arithmetic operators.
|
|
Unary Plus and Minus
+ - |
Sign prefixes.
|
|
Increment and Decrement
++ -- |
Increment or decrement value by one, and then return the modified or original value depending on the prefix or suffix of variable.
|
Comparison Operators
For comparison operators, the result will always be a Boolean value.
Name | Description | |
Less Than, Less Than or Equal, Greater Than, Greater Than or Equal
< <= > >= |
Compares arguments, and then returns True if expression is True; otherwise returns False.
|
|
Equality, Inequality
== != |
The equality operator returns True if operands are equal; otherwise returns False. The inequality is the logical opposite of equality operator.
|
Assignment Operators
Name | Description | |
Simple assignment:
= |
Assigns right hand value to the left hand value, and then returns the left hand value after the assignment.
|
|
Modifying assignment:
+= -= *= /= |
Applies an operation on the values, and then stores the results in the left hand argument, and finally returns the left hand value after the assignment.
|
Type Integer
Integers are represented as 32-bit signed integers and have a cast name of int. Integers may be specified as literal values.
55 is decimal format 067 leading zero indicates octal format 0x37 is hexadecimal format(0X37 is also accepted) |
Methods
Integer values support the following operators in addition to standard numerical operators.
Name | Description | |
Modulo:
% |
Calculates the remainder of division between left and right arguments, and then returns that value.
|
|
Shift Left, Shift Right:
<< >> |
Returns the left argument value by shifting number of bits specified by right argument either left or right.
|
|
Bitwise complement:
~ |
Unary prefix operator that returns the 32-bit complement of its argument.
|
|
Bitwise AND, OR, XOR:
& | ^ |
Applies logic to both arguments, each bit at a time, and then returns the result.
|
Notes:
- All supported operators for integer type, except bitwise complement, exist as assignment operations: %=, <<=, >>=, &=, |= and ^=.
Type Real
Real type values are represented as 64-bit IEEE floating point values and have a cast name of double. Real types can be specified as literal values.
12.4 :integer part and fractional part .63 :only fraction present 2.4e6 is 2400000 integer part, fractional part and exponent .8e-3 0.0008 only fraction part with negative exponent |
Complex types
Complex types can be accessed or manipulated using members and methods, which are accessed using member access operator.
vec.X the X coordinate member value vec.Length() a method that returns the length or absolute value |
The main difference between members and methods is that methods are functions that take arguments, whereas members just access a part of the complex type. Generally, complex types only support a small number of operators.
Type Vector
A 4-dimensional array consisting of 4 double type elements with a cast name of rVector. A vector is often used to represent positions or directions.
Members
Name | Description |
X | X coordinate. |
Y | Y coordinate. |
Z | Z coordinate. |
W | W coordinate. |
Methods
Name | Description |
Length() | Returns the absolute length of vector as a real type value. |
Square() | Returns the square of vector length as a real type value. |
Set(x, y, z) | Sets the XYZ members of vector using given double type arguments, and then returns the modified rVector. |
Set(x, y, z, w) | Sets the XYZW members of vector using given real type arguments, and then returns the modified rVector. |
Operators
Name | Description |
Negative:
-Vector |
Returns the opposite of vector. |
Scaling:
Vector*real, real*Vector, Vector/real |
Multiplies or divides each component of vector with a scalar value. |
Scalar Product:
Vector*Vector |
Returns the scalar product of two vectors. |
Vector Product:
Vector^Vector |
Returns the vector product of two vectors. |
Addition and Subtraction:
Vector+Vector, Vector - Vector |
Returns the sum or difference of two vectors. |
Assignment:
Vector = Vector |
Simple vector assignment. |
Assignment:
Vector += Vector, Vector -= Vector |
Addition or subtraction vector assignment. |
Assignment:
Vector *= real, Vector /= real |
Scaling vector assginment. |
Type Matrix
A 4x4 matrix of double values with a cast name of rMatrix. A matrix is often used to represent positions in space and linear transformations.
Methods
A matrix has several methods for setting or modifying its value, all of which can be used as functions. In that case, a function is equivalent to using a method on identity matrix. All methods will return a modified matrix, so method calls can be chained.
Tx(100).Rz(45) translates and then rotates matrix |
The following methods can be used with a matrix. The unit for all angle parameters is degrees, unless you give a unit specification.
Name | Description |
Identity() | Sets matrix to its identity matrix. |
Rx(angle) | Rotates matrix around relative X-axis by a given angle. |
Ry(angle) | Rotates matrix around relative Y-axis relative by a given angle. |
Rz(angle) | Rotates matrix around relative Z-axis relative by a given angle. |
Tx(distance) | Translates matrix along relative X-axis by a given distance. |
Ty(distance) | Translates matrix along relative Y-axis by a given distance. |
Tz(distance) | Translates matrix along relative Z-axis by a given distance. |
Sx(factor) | Scales matrix relative to its X-axis by a given factor. |
Sy(factor) | Scales matrix relative to its Y-axis by a given factor. |
Sz(factor) | Scales matrix relative to its Z-axis by a given factor. |
Pos(x, y, z) | Sets the position of matrix to the given coordinate values. |
Euler(a, b, c) | Sets the orientation of matrix using given Euler angles. |
WPR(a, b, c) | Sets the orientation of matrix using yaw, pitch and roll values. |
IJK(i, j, k) | Aligns the Z-axis of matrix to a given vector. |
AxisAngle(i, j, k, angle) | Sets the orientation of matrix by rotating identity matrix around a given axis and angle. |
Quaternion(q1, q2, q3, q4) | Sets the orientation of matrix by using given quaternion values. |
Set(v1, v2, ..., v16) | Sets the values of matrix row by row. |
Operators
Name | Description |
Inverse:
-Matrix |
Calculates the inverse of matrix. |
Equality:
Matrix == Matrix |
Tests two matrices for equality. |
Transform:
Matrix*Vector |
Returns a vector transformed by matrix. |
Matrix Multiplication:
Matrix*Matrix, Matrix/Matrix |
Returns a matrix product or quotient. |
Assignment:
Matrix = Matrix |
Assigns one matrix to another matrix. |
Matrix Transform:
Matrix *= rMatrix, Matrix /= Matrix |
Pre-multiplies a matrix by a given matrix or its inverse. |
Type String
A string is a sequence of characters with a cast name of rString. The literal form of a string is surrounded by double quotes.
"Hello" a string literal surrounded by double quotes "\"Quoted\"" a string quote containing escaped quotes |
Methods
Name | Description |
length | Returns the number of characters in string.
Note: The expression language is case sensitive. Use small l in length. |
Operators
Name | Description |
Equality:
String == String, String != String |
Compares the equality and inequality of strings. |
Comparison:
String < String, String <= String, String > String, String >= String |
Implements a lexicographical sort based on the numeric value of characters in strings. |
Concatenation:
String + String |
Concatenates two strings into one. |
Assignment:
String = String, String += String |
Assigns or appends one string to another string. |
Type Reference
A reference is an address that stores variables and methods of an object. Reference type can store following types of objects: Component, Node, Feature, Behaviour, Material and Parameter.
Reference type supports member access operator to access properties of the object.
ref_comp.MyProp MyProp property of a reference object |
Operators
Name | Description |
Equality:
Reference == Reference, Reference != Reference Reference == String, Reference != String |
Compares the equality and inequality of two references or a reference and a string. When comparing reference against a string, the name property of the reference is used in comparison instead of the reference. |
Casting:
(bool)Reference (string)Reference |
Cast operator can be used to convert reference type to a bool type and a string type. Bool type value is False, if the reference is Null, and True, if the reference is not Null. String type value is the name of the object. |
Type List
Lists can only contain values of a single type or references to objects of a single type. Lists are also strongly typed, meaning that the referenced object type is known and cannot be changed. If a list contains references, and an object gets deleted, the reference becomes Null.
myList[0].Name Name of the first item of myList |
myList.length() Returns the length of the list as integer |