数学函数参考 (iLogic)

iLogic 提供了一组可以添加到规则中的数学函数。

在 iLogic“编辑规则”对话框中,使用以下方法之一访问数学函数:

标准数学函数

标准的 VB.NET 数学库提供了 iLogic 中使用的大多数数学函数:

IsNumericPI
MinOfManySqrt
MaxOfManyAbs
RoundSign
Round decimal precisionInt
Round Closest to IncrementFix
Round Up to IncrementLog10
Round Down to IncrementLn
CeilPow
FloorMin
SinMax
CosCDbl
TanEqualWithinTolerance

iLogic 数学函数

iLogic 提供了一些数学函数。以下函数可模拟可在标准 Inventor 参数表达式中使用的函数:

Ceil (same as Math.Ceiling)
Sign0(a) = 1 if a > 0.0, = 0 otherwise
Ln (same as Math.Log)

因为某些 Inventor 函数与具有相同名称的 VB.NET 标准数学函数不同,因此当抓取这些函数以在 iLogic 规则中使用时,会对它们进行转换:

三角函数

Sin(0) = 0Cos(PI) = -1
Sin(PI) = 0Tan(0) = 0
Sin(PI/2) = 1Tan(PI/4) = 1
Cos(0) = 1PI = 3.1415926......
Cos(PI/2) = 0 

Sin()Cos()Tan() 是标准的三角函数,它们使用以弧度(而非度)表示的参数。

如果您在“编辑规则”对话框中对三角公式使用“捕获当前状态”选项,则不会将该公式转换为 VB.NET 代码。而该公式将保持为 Inventor 公式。您可以手动编辑该公式,以将其更改为 VB.NET 公式(使用以弧度单位表示的角度)。

若要从度转换为弧度,请使用以下公式:

弧度 = 度 * (PI/180)

其他数学函数

函数目的示例
Abs()返回参数的绝对值。

Abs(10) = 10

Abs(-9.87) = 9.87

Sqrt()返回参数的平方根。

Sqrt(25) = 5

Sqrt(100) = 10

Sqrt(3) = 1.732051

Sign()返回指示参数符号的数值。

如果值为正,则 Sign(value) = 1

如果值为负,则 Sign(value) = -1

如果值为零,则 Sign(value) = 0

Round()将参数舍入为整数,或者舍入为带有指定小数位数的数值。

语法:Round(argument, 可选的所需小数位数)

Round(2.55689) = 3

Round(2.55689, 1) = 2.6

Round(2.55689, 3) = 2.557

Round(PI, 4) = 3.1416

Ceil()将参数舍入为最接近的大于参数的整数。

Ceil(2.56) = 3

Ceil(Sqrt(3))= 2

Floor()将参数舍入为最接近的小于参数的整数。

Floor(1.789) = 1

Floor(PI) = 3

Log10()返回参数以 10 为底的对数。

Log10(10) = 1

Log10(100) = 2

Log10(15) = 1.176091

Ln()返回参数的自然对数(以 e 为底的对数)。

Ln(5) = 1.609438

Ln(37) = 3.610918

Pow(argument1, argument2)返回 argument1 的 argument2 次幂的结果。

Pow(2, 2) = 2 2 = 4

Pow(2, 3) = 2 3 = 8

Pow(3, 2) = 3 2 = 9

比较函数

函数目的示例
Min(argument1, argument2)返回两个参数中较小的一个。

Min(2, 4) = 2

Min(9, 4) = 4

Min(Sqrt(2), Sqrt(3)) = 1.4142.....

Max(argument1, argument2)返回两个参数中较大的一个。

Max(2, 4) = 4

Max(9, 4) = 9

Sqrt(3)) = 1.73205.....

MinOfMany( ,,, )返回众多参数中最小的一个。

MinOfMany(2,4,3,6,7,8) = 2

MinOfMany(9,4,5,67,3,5) = 3

MinOfMany(Sqrt(2), Sqrt(3), Sin(PI/2)) = 1

MaxOfMany( ,,, )返回众多参数中最大的一个。

MaxOfMany(2,4,3,6,7,8) = 8

MaxOfMany(9,4,5,67,3,5) = 67

MaxOfMany(Sqrt(2), Sqrt(3), Sin(PI/ignored>/2)) = 1.73205.....

EqualWithinTolerance(a, b, 0.001)比较两个参数(由 ab 表示)的值,并将差值与公差值进行比较(此处将公差值指定为 0.001)。如果差值小于公差,则函数将返回布尔值 True。如果差值大于公差,则函数将返回布尔值 False。

If a = 10.00 and b=10.01

EqualWithinTolerance(a, b, 0.015) = True [Abs(a-b) is less than the tolerance value of 0.015 in]

EqualWithinTolerance(a, b, 0.001) = False [Abs(a-b) is greater than the tolerance value of 0.001]

EqualWithinTolerance(a,b)使用默认公差 0.0000001