ug4
math_util.lua File Reference

Functions

function util CreateConstUserMatrix2d (m00, m01, m10, m11)
 
function util CreateConstUserMatrix3d (m00, m01, m02, m10, m11, m12, m20, m21, m22)
 
function util CreateConstUserVector2d (v0, v1)
 
function util CreateConstUserVector3d (v0, v1, v2)
 
function util FactorizeInPowersOfTwo (n)
 
function util IsNaturalNumber (n)
 
function util IsPowerOfTwo (n)
 

Function Documentation

◆ CreateConstUserMatrix2d()

function util CreateConstUserMatrix2d ( m00  ,
m01  ,
m10  ,
m11   
)

creates a Const User Matrix 2d

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / math_util.lua :37-44

function util.CreateConstUserMatrix2d(m00, m01, m10, m11)
local mat = ConstUserMatrix2d()
mat:set_entry(0, 0, m00)
mat:set_entry(0, 1, m01)
mat:set_entry(1, 0, m10)
mat:set_entry(1, 1, m11)
return mat
end
int local(bglp_vertex_descriptor p)
Definition: parallel_matrix.h:57

◆ CreateConstUserMatrix3d()

function util CreateConstUserMatrix3d ( m00  ,
m01  ,
m02  ,
m10  ,
m11  ,
m12  ,
m20  ,
m21  ,
m22   
)

creates a Const User Matrix 3d

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / math_util.lua :47-59

function util.CreateConstUserMatrix3d(m00, m01, m02, m10, m11, m12, m20, m21, m22)
local mat = ConstUserMatrix3d()
mat:set_entry(0, 0, m00)
mat:set_entry(0, 1, m01)
mat:set_entry(0, 2, m02)
mat:set_entry(1, 0, m10)
mat:set_entry(1, 1, m11)
mat:set_entry(1, 2, m12)
mat:set_entry(2, 0, m20)
mat:set_entry(2, 1, m21)
mat:set_entry(2, 2, m22)
return mat
end

◆ CreateConstUserVector2d()

function util CreateConstUserVector2d ( v0  ,
v1   
)

creates a Const User Vector 2d

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / math_util.lua :62-67

function util.CreateConstUserVector2d(v0, v1)
local vec = ConstUserVector2d()
vec:set_entry(0, v0)
vec:set_entry(1, v1)
return vec
end

◆ CreateConstUserVector3d()

function util CreateConstUserVector3d ( v0  ,
v1  ,
v2   
)

creates a Const User Vector 3d

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / math_util.lua :70-76

function util.CreateConstUserVector3d(v0, v1, v2)
local vec = ConstUserVector3d()
vec:set_entry(0, v0)
vec:set_entry(1, v1)
vec:set_entry(2, v2)
return vec
end

◆ FactorizeInPowersOfTwo()

function util FactorizeInPowersOfTwo ( )

function to factorise number which has to be a power of 2 in two factors which differ at most by a factor of 2 and returns both (first the smaller one, then the larger one).

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / math_util.lua :105-120

function util.FactorizeInPowersOfTwo(n)
if not util.IsPowerOfTwo(n) then
print("Number to factorise must be a power of 2. Aborting.")
exit()
end
local number firstFactor = n
local number secFactor = 1
while (firstFactor > 2*secFactor) do
firstFactor = firstFactor/2
secFactor = secFactor*2
end
return secFactor, firstFactor
end
function table print(data, style)
double number
Definition: types.h:124
while((*yyd++= *yys++) !='\0') continue

◆ IsNaturalNumber()

function util IsNaturalNumber ( )

function returns true if the number is a natural number

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / math_util.lua :94-100

function util.IsNaturalNumber(n)
if n-math.floor(n) == 0 then
return true
else
return false
end
end

◆ IsPowerOfTwo()

function util IsPowerOfTwo ( )

function returns true if the number is a power of two

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / math_util.lua :83-91

function util.IsPowerOfTwo(n)
local number compare = 1
while (compare < n) do
compare = compare*2
end
return compare==n
end