Mathf Functions

Archimatix allows a subset of Unity’s Math functions for use in:

  • Parameter Expressions
  • Relation Expressions
  • Scene Handles
  • Runtime Handles
  • Turtle Scripts
math functionuse
Abs(var)
abs(f)
convert float to absolute (positive)
Acos(var)
acos(f)
returns the arc-cosine of f,
the angle in radians whose cosine is f.
Asin(var)
asin(f)
Returns the arc-sine of f,
the angle in radians whose sine is f.
Atan(var)
atan(f)
Returns the arc-tangent of f,
the angle in radians whose tangent is f.
Atan2(a,b)
atan2(a,b)
arctan(a,b)
Returns the angle in radians whose Tan is y/x.
Ceil(f)
ceil(f)
CeilToInt(var)
ceilToInt(f)
Returns the smallest integer greater to or equal to f.
Clamp01(var)
clamp01(f)
Clamps value between 0 and 1 and returns value.
Cos(var)
cos(f)
Returns the cosine of angle f.
Epsilon
epsilon
constant (read-only): the smallest enum
Exp(var)
exp(
f)
Returns e raised to the power of f.
e is ~2.718282
Floor(var)
floor(f)
FloorToInt(var)
floorToInt(f)
Returns the largest integer smaller than or equal to f.
Greater(a,b)
greater(a,b)
picks the greater of 2 values,
can be equal
int(f)same as floor()
IsEven(var)
isEven(f)
iseven(f)
bool returns true when value is even
Lerp(a,b,time)
lerp(a,b,t)
Linearly interpolates between a and b by t.
Lesser(a,b)
lesser(a,b)
picks the lesser of 2 values,
can be equal
Max(a,b)
max(
a,b)
Returns largest of two values.
Min(a,b)
min(
a,b)
Returns the smallest of two values.
Modulo(a,n)
modulo(a,n)
remainder of int a divided by float n, where n is not zero (NaN)
MoveTowards(a,b,t)
moveTowards(
a,b,t)
Moves a value current towards target.
MoveTowardsAngle(a,b,t)
moveTowardsAngle(
a,b,t)
Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
PI
pi
constant (read-only): ~3.141593
Pow(f,p)
pow(
a,b)
Returns f raised to power p.
Range(var,a,b)
range(var,a,b)
clamps a value between 2 floats/ints.
b must be greater than a
Repeat(time,length)
repeat(
a,b)
Loops the value t, so that it is never larger than length and never smaller than 0.
rnd(f)
rnd(a,b)
random float between zero and f
random range between a and b
Round(var)
round(
f)
Returns f rounded to the nearest integer.
Sign(var)
sign(
f)
Returns the sign of f.
(-1 or 1)
Sin(var)
sin(f)
Returns the sine of angle f.
Sqrt(var)
sqrt(f)
Returns square root of f.
Tan(var)
tan(f)
Returns the tangent of angle f in radians.

Example functions:

snapping1.0 ceil(var)
0.5 ceil(var*2)*.5
0.25 ceil(var*4)*.25
hypotenusesqrt(pow(width,2)+pow(height,2))
theta angleatan2(height,width)
difference
(distance)
greater(b-a,a-b)
abs(b-a)
round to .01round(var*100)*.01
random 0.1 – 1.0round(rnd(10))*.1
random bool
set bool_switcher round(rnd(1))
if bool_switcher EQ 0
set my_bool 0
endif
if bool_switcher EQ 1
set my_bool 1
endif

Comments are closed.