GXMATH class

class geosoft.gx.GXMATH
This is not a class. This is a collection of standard
mathematical functions, including most of the common
logarithmic and geometric functions.
static abs_double_((GXContext)ctx, (float)arg1) → float:
Calculate absolute value
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Dummy values return dummy
static abs_int_((GXContext)ctx, (int)arg1) → int:
Calculate absolute value
Parameters:
Returns:

integer

Return type:

int

New in version 6.0.1.

Note:

Dummy values return dummy
static and_((GXContext)ctx, (int)arg1, (int)arg2) → int:
Return the unary operation result of A & B

Returns                      an integer number

If A or B is a dummy, returns dummy.
Parameters:
Return type:

int

New in version 6.3.0.

static arc_cos_((GXContext)ctx, (float)arg1) → float:
Calculate the arccosine
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Dummy values or values < -1 or > 1 return dummy
static arc_sin_((GXContext)ctx, (float)arg1) → float:
Calculate the arcsin
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Dummy values or values < -1 or > 1 return dummy
static arc_tan2_((GXContext)ctx, (float)arg1, (float)arg2) → float:
Calculate ArcTan(Y/X)
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

If either X or Y is a dummy, returns dummy
static arc_tan_((GXContext)ctx, (float)arg1) → float:
Calculate the arctan
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Dummy values return dummy
static ceil_((GXContext)ctx, (float)arg1) → float:
Calculates the ceiling of the value
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Dummy values return dummy
static cos_((GXContext)ctx, (float)arg1) → float:
Calculate the cosine
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Dummy values return dummy
static cross_product_((GXContext)ctx, (float)arg1, (float)arg2, (float)arg3, (float)arg4, (float)arg5, (float)arg6, (float_ref)arg7, (float_ref)arg8, (float_ref)arg9) → None:
Cross product of two vectors.
Parameters:
Returns:

Nothing

Return type:

None

New in version 6.0.0.

static dot_product_3d_((GXContext)ctx, (float)arg1, (float)arg2, (float)arg3, (float)arg4, (float)arg5, (float)arg6) → float:
Compute Dot product of two vectors.
Parameters:
  • ctx (geosoft.gx.GXContext) – The GX execution context
  • arg1 (float) – X1 component
  • arg2 (float) – Y1 component
  • arg3 (float) – Z1 component
  • arg4 (float) – X2 component
  • arg5 (float) – Y2 component
  • arg6 (float) – Z2 component
Returns:

Dot product

Return type:

float

New in version 6.0.0.

static exp_((GXContext)ctx, (float)arg1) → float:
Calculate e raised to the power of X
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Dummy values return dummy
static floor_((GXContext)ctx, (float)arg1) → float:
Calculates the floor of the value
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Dummy values return dummy
static hypot_((GXContext)ctx, (float)arg1, (float)arg2) → float:
sqrt(X*X + Y*Y)
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

If either X or Y is a dummy, the returned value is dummy
static lambda_trans_((GXContext)ctx, (float)arg1, (float)arg2) → float:
Performs lambda transform on a value.
Parameters:
  • ctx (geosoft.gx.GXContext) – The GX execution context
  • arg1 (float) – Z Value
  • arg2 (float) – Lambda value
Returns:

The lambda transformed value

Return type:

float

New in version 6.0.1.

Note:

Returns 0 for input Z = 0.
returns log10(Z) for lambda = 0.
returns (Z^lambda - 1)/lambda for Z > 0.
returns dummy for Z = dummy.
static lambda_trans_rev_((GXContext)ctx, (float)arg1, (float)arg2) → float:
Performs a reverse lambda transform on a value.
Parameters:
  • ctx (geosoft.gx.GXContext) – The GX execution context
  • arg1 (float) – Lambda transformed Z Value
  • arg2 (float) – Lambda value
Returns:

The original non-lambda transformed value

Return type:

float

New in version 6.0.1.

Note:

See rLambdaTrans.
static log10_((GXContext)ctx, (float)arg1) → float:
Calculate the base 10 log
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Dummy values return dummy
static log_((GXContext)ctx, (float)arg1) → float:
Calculate the natural log
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Dummy values return dummy
static log_z_((GXContext)ctx, (float)arg1, (int)arg2, (float)arg3) → float:
Given a Z value and the Log style and Log Minimum this
function will return the log value.
Parameters:
  • ctx (geosoft.gx.GXContext) – The GX execution context
  • arg1 (float) – Z Value
  • arg2 (int) – Log Mode (0 - Log, 1 - LogLinearLog)
  • arg3 (float) – Log Minimum (must be greater than 0)
Returns:

The Log Value.

Return type:

float

New in version 6.0.1.

Note:

Mode = 0 (regular log mode)

Returns:
Log10(Z)  for Z > minimum
Log10(minimum) for Z <= minimum

Mode = 1 (log / linear / negative log mode)

Returns:
minimum * ( log10( |Z| / minimum) + 1 )   for Z > minimum
   Z for |Z| <= minimum   (the linear part of the range)
-minimum * ( log10( |Z| / minimum) + 1 )   for Z < -minimum
static mod_double_((GXContext)ctx, (float)arg1, (float)arg2) → float:
Calculates the modulus of two reals (A mod B)
Parameters:
  • ctx (geosoft.gx.GXContext) – The GX execution context
  • arg1 (float) – A
  • arg2 (float) – B (must not be zero)
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

The modulus of A with respect to B is defined
as the difference of A with the largest integral multiple of B
smaller than or equal to A.

e.g.   A  mod B
       20 mod 10 = 0
       20 mod 9 = 2

f A or B is a dummy, returns dummy.
static mod_int_((GXContext)ctx, (int)arg1, (int)arg2) → int:
Calculates the modulus of two integers
Parameters:
  • ctx (geosoft.gx.GXContext) – The GX execution context
  • arg1 (int) – A
  • arg2 (int) – B (must not be zero)
Returns:

int

Return type:

int

New in version 6.0.1.

Note:

If A or B is a dummy, returns dummy.
static nicer_log_scale_((GXContext)ctx, (float_ref)arg1, (float_ref)arg2, (int)arg3) → None:
Finds nicer min, max values for logarithmic plot scales.
Parameters:
Returns:

Nothing

Return type:

None

New in version 6.0.1.

Note:

Will fail if the input upper bound is less than the lower
bound, but will work if the two values are equal.
The input bounds are overwritten.

Input lower and upper bounds, returns "nicer" values.
If the Fine flag is set to TRUE, the values will have the
form N x 10^Y, where N is a value from 1 to 9, and 10^Y
is an integral power of 10. If the Fine flag is set to
FALSE, the scaling is coarse, and the bounding exact
powers of 10 are returned.
For example,  the values (.034, 23) return (.03, 30) for
fine scaling, and (0.01, 100) for coarse scaling.
static nicer_scale_((GXContext)ctx, (float_ref)arg1, (float_ref)arg2, (float_ref)arg3, (int_ref)arg4) → None:
Compute a nicer scale for a given min and max.
Parameters:
Returns:

Nothing

Return type:

None

New in version 6.0.1.

static normalise_3d_((GXContext)ctx, (float_ref)arg1, (float_ref)arg2, (float_ref)arg3) → None:
Scale a vector to unit length.
Parameters:
Returns:

Nothing

Return type:

None

New in version 6.0.0.

Note:

Divides each component by the vector
magnitude.
static or_((GXContext)ctx, (int)arg1, (int)arg2) → int:
Return the unary operation result of A | B

Returns                      an integer number

If A or B is a dummy, returns dummy.
Parameters:
Return type:

int

New in version 6.3.0.

static pow_((GXContext)ctx, (float)arg1, (float)arg2) → float:
Calculate X raised to the power of Y
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

If either X or Y is a dummy, returns dummy
static rand_((GXContext)ctx) → float:
Get a  random number between 0 and 1
Parameters:ctx (geosoft.gx.GXContext) – The GX execution context
Returns:a real number
Return type:float

New in version 6.3.0.

Note:

Use geosoft.gx.GXMATH.s_rand_() to seed the random number generator before a series of
calls to this function are made.
The standard "C" function rand() is called.
static rotate_vector_((GXContext)ctx, (float)arg1, (float)arg2, (float)arg3, (float)arg4, (float)arg5, (float)arg6, (float)arg7, (float_ref)arg8, (float_ref)arg9, (float_ref)arg10) → None:
Rotate a vector about an axis.
Parameters:
  • ctx (geosoft.gx.GXContext) – The GX execution context
  • arg1 (float) – X1 component (vector to rotate)
  • arg2 (float) – Y1 component
  • arg3 (float) – Z1 component
  • arg4 (float) – Angle to rotate, CW in radians
  • arg5 (float) – X2 component (axis of rotation)
  • arg6 (float) – Y2 component
  • arg7 (float) – Z2 component
  • arg8 (geosoft.gx.float_ref) – X3 component (rotated vector, can
  • arg9 (geosoft.gx.float_ref) – Y3 component be the same as input)
  • arg10 (geosoft.gx.float_ref) – Z3 component
Returns:

Nothing

Return type:

None

New in version 6.0.0.

Note:

Rotates a vector by the input angle around an arbitrary axis.
Angles are measured clockwise looking along the axis (away from the origin).
Assumes a right hand coordinate system.
static round_double_((GXContext)ctx, (float)arg1, (int)arg2) → float:
Round to n significant digits
Parameters:
  • ctx (geosoft.gx.GXContext) – The GX execution context
  • arg1 (float) – real
  • arg2 (int) – number of significant digits to round to
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Negative values ending in 5XXX to n sig digits round down
Positive values ending in 5XXX to n sig digits round up
Dummy values return dummy
static round_int_((GXContext)ctx, (float)arg1) → int:
Round to the nearest whole number
Parameters:
Returns:

integer

Return type:

int

New in version 6.0.1.

Note:

Negative values with decimal parts larger than .5 round down (-1.5 -> 2.0)
Positive values with decimal parts larger than .5 round up (1.5 -> 2.0)
Dummy values return dummy
static s_rand_((GXContext)ctx) → None:
Seed the random-number generator with current time
Parameters:ctx (geosoft.gx.GXContext) – The GX execution context
Returns:Nothing
Return type:None

New in version 6.3.0.

Note:

Use the geosoft.gx.GXMATH.rand_() function to create a random number between  0 and 1.
The standard "C" function srand() is called.
static sign_((GXContext)ctx, (float)arg1, (float)arg2) → float:
Determine return value based on value of Z1
Parameters:
Returns:

|Z2| if Z1>0, -|Z2| if Z1<0, 0 if Z1 = 0, and Z2 if Z1 = Dummy

Return type:

float

New in version 6.0.1.

Note:

Dummy values return dummy
static sin_((GXContext)ctx, (float)arg1) → float:
Calculate the sin
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Dummy values return dummy
static sqrt_((GXContext)ctx, (float)arg1) → float:
Calculate the square root
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Dummy values return dummy
static tan_((GXContext)ctx, (float)arg1) → float:
Calculate the tangent
Parameters:
Returns:

real

Return type:

float

New in version 6.0.1.

Note:

Dummy values return dummy
static un_log_z_((GXContext)ctx, (float)arg1, (int)arg2, (float)arg3) → float:
Inverse of rLogZ
Parameters:
  • ctx (geosoft.gx.GXContext) – The GX execution context
  • arg1 (float) – log value
  • arg2 (int) – Log Mode (0 - Log, 1 - LogLinearLog)
  • arg3 (float) – Log Minimum (must be greater than 0)
Returns:

The original value

Return type:

float

New in version 6.0.1.

Note:

See Notes for rLogZ.
static xor_((GXContext)ctx, (int)arg1, (int)arg2) → int:
Return the unary operation result of A ^ B

Returns                      an integer number

If A or B is a dummy, returns dummy.
Parameters:
Return type:

int

New in version 6.3.0.