Округление:
Код:
fn roundeNX n x = (((n as integer)/x)*x)

fn round a = if abs(floor(a) - a)>.5 then floor(a)+1.0 else floor(a)

fn xround x = (
  fx = floor x
  cx = ceil x
  return if 0.5 * (fx + cx) > x then fx else cx
 )
 
 fn round_to val n =
(
      local mult = 10.0 ^ n
            (floor ((val * mult) + 0.5)) / mult
)
-- example
-- round_to 3.625 2			->	3.63
-- round_to 3.6254521 4		->	3.6255
Максимум,Минимум:
Код:
fn minimum a b = ( if a <b then a else b)

fn maximum a b = ( if a <b then b else a)

fn maximum_3 a b c = (if (maximum a b)<c then c else if (maximum b c)<a then a else b)

fn minimum_3 a b c = (if (minimum a b)>c then c else if (minimum b c)>a then a else b)

fn minimumArr Arr =(
a=Arr[Arr.count-1]
for i=Arr.count-1 to 1 by -1 do
(
if a>Arr[i+1] then a=Arr[i+1]
)
return a
)

fn maximumArr Arr =(
a=Arr[Arr.count-1]
for i=Arr.count-1 to 1 by -1 do
(
if a<Arr[i+1] then a=Arr[i+1]
)
return a
)
Среднее арифметическое:
Код:
fn midariphm a b = ((a+b)/2)

fn midariphm3x a b c = ((a+b+c)/3) 

fn midAriphmArr Arr = (
	a=0
	for i=1 to Arr.count do(a+=Arr[i])
	b=a/Arr.count
	return b
	)
Поворот камеры расположенной в точке F в направлении точки L. (F и L являются point3):
Код:
fn rotatecam F L=(
m_r=L-F
worldUpVector = [0,0,1] --(inverse(obj2.transform)).row3
rightVector = normalize (cross worldUpVector m_r)
upVector = normalize ( cross rightVector m_r)
cam_rotate=matrix3 rightVector upVector m_r L
return cam_rotate)