Maths

public static class Maths
Mathematical trig functions.

Fields

Cross

#
public const char Cross = '×'
Gets the 'multiplication sign' x-like character oftentimes used in mathematical notation to denote multiplication.

DegToRad

#
public const double DegToRad = 0.017453292519943295
Conversion factor from Degrees to Radians.

DegToTurn

#
public const double DegToTurn = 0.002777777777777778
Conversion factor from Degrees to Turns.

Dot

#
public const char Dot = '·'
Gets the 'middle dot' character oftentimes used in mathematical notation to denote multiplication.

DoublePrecisionMaximumIntegerAccuracy

#
public const long DoublePrecisionMaximumIntegerAccuracy = 9007199254740992
The last value at which the double precision floating point epsilon assumes a value of 1.0. That is, the distance between this float and the first bigger one is > 1.0

DoublePrecisionMinimumIntegerAccuracy

#
public const long DoublePrecisionMinimumIntegerAccuracy = 4503599627370496
The first value at which the double precision floating point epsilon assumes a value of 1.0. That is, the distance between this float and first bigger one is exactly 1.0

HalfPi

#
public const double HalfPi = 1.5707963267948966
Pi over two.

HalfPiInverse

#
public const double HalfPiInverse = 0.6366197723675814
The reciprocal of pi over two.

Huge

#
public const double Huge = 1000000000000
Numbers larger than this are considered huge and will almost certainly result in problems when used in calculations or display.

Large

#
public const double Large = 1000000
Numbers larger than this but smaller than Huge are considered large. Although not necessarily a problem, users may be warned about them as they indicate a potential problem.

MaximumSafeArrayLength

#
public const int MaximumSafeArrayLength = 1000000000
Defines the maximum size of an array that Grasshopper is happy to create. This is hard-coded to 1-billion, or roughly half the maximum 32-bit integer maximum value. This constant was chosen to be high enough for any sensible computation, yet small enough so that two maximum sized arrays can still be indexed as a single big one.

OneMinusSmallSquared

#
public const double OneMinusSmallSquared = 0.999999999999
The squared cosine of a small angle, using the small angle approximation. This number is useful for comparing angles to a small angle when the angle is given by its cosine, for example as some scalar product. For example, to test whether a non-zero vector n has smaller angle to the z axis than Small radians, one can test for n.Z * n.Z >= OneMinusSmallSquared * n.SquareLength. This is efficient because it does not require a square root or trigonometric function.

OnePi

#
public const double OnePi = 3.141592653589793
Pi.

OnePiInverse

#
public const double OnePiInverse = 0.3183098861837907
The reciprocal of pi.

OneThird

#
public const double OneThird = 0.3333333333333333
One over three.

Phi

#
public const double Phi = 1.618033988749895
Golden ratio.

QuarterPi

#
public const double QuarterPi = 0.7853981633974483
Pi over four.

QuarterPiInverse

#
public const double QuarterPiInverse = 1.2732395447351628
The reciprocal of pi over four.

RadToDeg

#
public const double RadToDeg = 57.29577951308232
Conversion factor from Radians to Degrees.

RadToTurn

#
public const double RadToTurn = 0.15915494309189535
Conversion factor from Radians to Turns.

Root2

#
public const double Root2 = 1.4142135623730951
Square root of two.

Root2Inverse

#
public const double Root2Inverse = 0.7071067811865476
The reciprocal of square root two.

Root3

#
public const double Root3 = 1.7320508075688772
Square root of three.

Root3Inverse

#
public const double Root3Inverse = 0.5773502691896257
The reciprocal of square root three.

Root5

#
public const double Root5 = 2.23606797749979
Square root of five.

Root5Inverse

#
public const double Root5Inverse = 0.4472135954999579
The reciprocal of square root five.

RootOfDoubleMaxValue

#
public const double RootOfDoubleMaxValue = 1.34E+154
Represents the (approximate)square root of double.MaxValue

RootOfSingleMaxValue

#
public const double RootOfSingleMaxValue = 1.84E+19
Represents the (approximate)square root of float.MaxValue

RootOnePi

#
public const double RootOnePi = 1.772453850905516
The square root of pi.

RootTwoPi

#
public const double RootTwoPi = 2.5066282746310007
The square root of two times pi.

Small

#
public const double Small = 1E-06
Numbers smaller than this but larger than Tiny are considered small. Although not necessarily a problem, users may be warned about them as they indicate a potential problem.

ThirdPi

#
public const double ThirdPi = 1.0471975511965979
Pi over three.

ThirdPiInverse

#
public const double ThirdPiInverse = 0.954929658551372
The reciprocal of pi over three.

Tiny

#
public const double Tiny = 1E-12
Numbers smaller than this are considered tiny and are either assumed to be a rounding error away from zero, or a faulty value.

TurnToDeg

#
public const double TurnToDeg = 360
Conversion factor from Turns to Degrees.

TurnToRad

#
public const double TurnToRad = 6.283185307179586
Conversion factor from Turns to Radians.

TwoPi

#
public const double TwoPi = 6.283185307179586
Two times pi.

TwoPiInverse

#
public const double TwoPiInverse = 0.15915494309189535
The reciprocal of two pi.

TwoThirds

#
public const double TwoThirds = 0.6666666666666666
Two over three.

Properties

AllPrimes

#
public static IEnumerable<int> AllPrimes { get; }
Enumerate over all cached primes.

HighestPrime

#
public static int HighestPrime { get; }
Gets the highest cached prime, obviously not the highest *actual* prime, I'm keeping that one a secret.

PrimeCount

#
public static int PrimeCount { get; }
Gets the number of primes that can be accessed.

Methods

Acos

#
public static Complex Acos(Complex value)
Compute the arc cosine of a complex value.
value (Complex)Complex value.
Arc cosine of angle.

Acos

#
public static double Acos(double angle)
Compute the arc cosine of an angle in radians.
angle (double)Angle in radians.
Arc cosine of angle.

Acosh

#
public static Complex Acosh(Complex value)
Compute the hyperbolic arc cosine of a complex value.
value (Complex)Complex value.
Hyperbolic arc cosine of angle.

Acosh

#
public static double Acosh(double angle)
Compute the hyperbolic arc cosine of an angle in radians.
angle (double)Angle in radians.
Hyperbolic arc cosine of angle.

Acot

#
public static Complex Acot(Complex value)
Compute the arc cotangent of a complex value.
value (Complex)Complex value.
Arc cotangent of angle.

Acot

#
public static double Acot(double angle)
Compute the arc cotangent of an angle in radians.
angle (double)Angle in radians.
Arc cotangent of angle.

Acoth

#
public static Complex Acoth(Complex value)
Compute the hyperbolic arc cotangent of a complex value.
value (Complex)Complex value.
Hyperbolic arc cotangent of angle.

Acoth

#
public static double Acoth(double angle)
Compute the hyperbolic arc cotangent of an angle in radians.
angle (double)Angle in radians.
Hyperbolic arc cotangent of angle.

Acsc

#
public static Complex Acsc(Complex value)
Compute the arc secant of a complex value.
value (Complex)Complex value.
Arc secant of angle.

Acsc

#
public static double Acsc(double angle)
Compute the arc secant of an angle in radians.
angle (double)Angle in radians.
Arc secant of angle.

Acsch

#
public static Complex Acsch(Complex value)
Compute the hyperbolic arc cosecant of a complex value.
value (Complex)Complex value.
Hyperbolic arc cosecant of angle.

Acsch

#
public static double Acsch(double angle)
Compute the hyperbolic arc cosecant of an angle in radians.
angle (double)Angle in radians.
Hyperbolic arc cosecant of angle.

AGM

#
public static double AGM(double a, double b)
Compute the Arithmetic-Geometric mean of two numbers.
a (double)First number.
b (double)Second number.
Arithmetic-Geometric mean.

Airy

#
public static Complex Airy(AiryKind function, Complex z)
Compute the appropriate Airy function for the given argument.
function (Maths.AiryKind)Function to evaluate.
z (Complex)Real argument.
Result of Airy function.

Airy

#
public static double Airy(AiryKind function, double z)
Compute the appropriate Airy function for the given argument.
function (Maths.AiryKind)Function to evaluate.
z (double)Real argument.
Result of Airy function.

AM

#
public static Complex AM(Complex a, Complex b)
Compute the Arithmetic mean of two numbers.
a (Complex)First number.
b (Complex)Second number.
Arithmetic mean.

AM

#
public static double AM(double a, double b)
Compute the Arithmetic mean of two numbers.
a (double)First number.
b (double)Second number.
Arithmetic mean.

AM

#
public static Point3d AM(Point3d a, Point3d b)
Compute the Arithmetic mean of two points.
a (Point3d)First number.
b (Point3d)Second number.
Arithmetic mean.

AM

#
public static Vector3d AM(Vector3d a, Vector3d b)
Compute the Arithmetic mean of two vectors.
a (Vector3d)First number.
b (Vector3d)Second number.
Arithmetic mean.

ApproximateMaassWaveform

#
public static Complex ApproximateMaassWaveform(Complex z, double lambda)
z (Complex)
lambda (double)

AreAllInfinite

#
public static bool AreAllInfinite(params double[] values)
Test whether all values are infinite values.
values (params double[])Value to check.
True if all values are nan.

AreAllNaN

#
public static bool AreAllNaN(params double[] values)
Test whether all values are NaN values.
values (params double[])Value to check.
True if all values are nan.

ArithmeticDerivative

#
public static Fraction ArithmeticDerivative(Fraction rational)
Compute the arithmetic derivative of a fraction.
rational (Fraction)

Asec

#
public static Complex Asec(Complex value)
Compute the arc secant of a complex value.
value (Complex)Complex value.
Arc secant of angle.

Asec

#
public static double Asec(double angle)
Compute the arc secant of an angle in radians.
angle (double)Angle in radians.
Arc secant of angle.

Asech

#
public static Complex Asech(Complex value)
Compute the hyperbolic arc secant of a complex value.
value (Complex)Complex value.
Hyperbolic arc secant of angle.

Asech

#
public static double Asech(double angle)
Compute the hyperbolic arc secant of an angle in radians.
angle (double)Angle in radians.
Hyperbolic arc secant of angle.

Asin

#
public static Complex Asin(Complex value)
Compute the arc sine of a complex value.
value (Complex)Complex value.
Arc sine of angle.

Asin

#
public static double Asin(double angle)
Compute the arc sine of an angle in radians.
angle (double)Angle in radians.
Arc sine of angle.

Asinh

#
public static Complex Asinh(Complex value)
Compute the hyperbolic arc sine of a complex value.
value (Complex)Complex value.
Hyperbolic arc sine of angle.

Asinh

#
public static double Asinh(double angle)
Compute the hyperbolic arc sine of an angle in radians.
angle (double)Angle in radians.
Hyperbolic arc sine of angle.

Atan

#
public static Complex Atan(Complex value)
Compute the arc tangent of a complex value.
value (Complex)Complex value.
Arc tangent of angle.

Atan

#
public static double Atan(double angle)
Compute the arc tangent of an angle in radians.
angle (double)Angle in radians.
Arc tangent of angle.

Atanh

#
public static Complex Atanh(Complex value)
Compute the hyperbolic arc tangent of a complex value.
value (Complex)Complex value.
Hyperbolic arc tangent of angle.

Atanh

#
public static double Atanh(double angle)
Compute the hyperbolic arc tangent of an angle in radians.
angle (double)Angle in radians.
Hyperbolic arc tangent of angle.

Bessel

#
public static double Bessel(BesselKind function, double x)
Compute the appropriate Bessel function for the given argument.
function (Maths.BesselKind)Bessel function.
x (double)Argument.
Result of the Bessel function.

BesselFirstKindIntegral

#
public static double BesselFirstKindIntegral(int order, double x)
An approximate implementation of a Bessel function of the first kind using the Bessel integral between zero and pi. This method does not suffer from numeric instability but it is an approximate solver.
order (int)Order of bessel function. May not be negative.
x (double)Value to evaluate.

BesselSecondKindIntegral

#
public static double BesselSecondKindIntegral(int order, double x)
An approximate implementation of a Bessel function of the second kind using the Bessel integral between zero and pi. This method does not suffer from numeric instability but it is an approximate solver.
order (int)Order of bessel function. May not be negative.
x (double)Value to evaluate.

Beta

#
public static double Beta(double z, double w)
Computes the Euler Beta function.
z (double)First parameter.
w (double)Second parameter.
Beta value.

BetaLn

#
public static double BetaLn(double z, double w)
Computes the natural logarithm of the Euler Beta function.
z (double)First parameter.
w (double)Second parameter.
Beta value.

Bifurcation

#
public static Interval[] Bifurcation(double r, double ε = 0.001)
Evaluate the standard Feigenbaum bifurcation diagram using the logistic map. Due to the strong iterative nature of this computation, the values inside the process are always rounded to 6 decimal places.
r (double)R parameter (along the x-axis of the bifurcation diagram).
ε (double = 0.001)Tolerance for clusters. Value closer together than epsilon will be merged into a single interval.
Array of intervals containing the clustered values at r.

Binomial

#
public static double Binomial(double n, double k, CancellationToken token)
Compute the binomial coefficient using partial factorials (n choose k).
n (double)N parameter, must be non-negative.
k (double)K parameter, must be non-negative.
token (CancellationToken)Cancellation token.
Binomial coefficient.

Binomial

#
public static double Binomial(double n, double k)
obsoleteUse the overload which takes a cancellation token.
Compute the binomial coefficient using partial factorials (n choose k).
n (double)N parameter, must be non-negative.
k (double)K parameter, must be non-negative.
Binomial coefficient.

Binomial

#
public static double Binomial(int n, int k)
Compute the binomial coefficient (n choose k).
n (int)N parameter, must be non-negative.
k (int)K parameter, must be non-negative.
Binomial coefficient.

BinomialCoefficient

#
public static BigInteger BinomialCoefficient(int n, int k, CancellationToken token)
Compute the binomial coefficient of two integers.
n (int)
k (int)
token (CancellationToken)

BinomialCoefficient

#
public static BigInteger BinomialCoefficient(int n, int k)
obsoleteUse the overload which takes a cancellation token.
Compute the binomial coefficient of two integers.
n (int)
k (int)

BinomialLn

#
public static double BinomialLn(int n, int k)
Compute the natural logarithm of binomial coefficient (n choose k).
n (int)N parameter, must be non-negative.
k (int)K parameter, must be non-negative.
Logarithm of the binomial coefficient.

Cbrt

#
public static Complex Cbrt(Complex x)
Cube root.
x (Complex)

Cbrt

#
public static double Cbrt(BigInteger x)
Cube root.
x (BigInteger)

Cbrt

#
public static double Cbrt(double x)
Cube root.
x (double)

Cbrt

#
public static double Cbrt(int x)
Cube root.
x (int)

Ceiling

#
public static Complex Ceiling(Complex value)
Default Grasshopper ceiling method.
value (Complex)Value to round.
Rounded value.

Ceiling

#
public static decimal Ceiling(decimal value)
Default Grasshopper ceiling method.
value (decimal)Value to round.
Rounded value.

Ceiling

#
public static double Ceiling(double value)
Default Grasshopper ceiling method.
value (double)Value to round.
Rounded value.

Ceiling

#
public static float Ceiling(float value)
Default Grasshopper ceiling method.
value (float)Value to round.
Rounded value.

Ceiling

#
public static Point3d Ceiling(Point3d value)
Default Grasshopper ceiling method.
value (Point3d)Value to round.
Rounded value.

Ceiling

#
public static Vector3d Ceiling(Vector3d value)
Default Grasshopper ceiling method.
value (Vector3d)Value to round.
Rounded value.

CieDeltaE2000

#
[EditorBrowsable(EditorBrowsableState.Never)] public static double CieDeltaE2000(double lum1, double a1, double b1, double lum2, double a2, double b2)
Colour difference according to the CIE ΔE₀₀ standard.

This is a re-implementation of the gfiumara/CIEDE2000 C++ source at: https://github.com/gfiumara/CIEDE2000

Which in turn is based on the paper: http://www2.ece.rochester.edu/~gsharma/ciede2000/ciede2000noteCRNA.pdf

lum1 (double)
a1 (double)
b1 (double)
lum2 (double)
a2 (double)
b2 (double)

Clip

#
public static BigInteger Clip(BigInteger value, BigInteger min, BigInteger max)
Clip a value to two limits.
value (BigInteger)Value to clip.
min (BigInteger)Inclusive lower limit.
max (BigInteger)Inclusive upper limit.
Clipped value.

Clip

#
public static Complex Clip(Complex value, Complex min, Complex max)
Clip a value to two limits.
value (Complex)Value to clip.
min (Complex)Inclusive lower limit.
max (Complex)Inclusive upper limit.
Clipped value.

Clip

#
public static double Clip(double value, double min, double max)
Clip a value to two limits.
value (double)Value to clip.
min (double)Inclusive lower limit.
max (double)Inclusive upper limit.
Clipped value.

Clip

#
public static float Clip(float value, float min, float max)
Clip a value to two limits.
value (float)Value to clip.
min (float)Inclusive lower limit.
max (float)Inclusive upper limit.
Clipped value.

Clip

#
public static int Clip(int value, int min, int max)
Clip a value to two limits.
value (int)Value to clip.
min (int)Inclusive lower limit.
max (int)Inclusive upper limit.
Clipped value.

Clip

#
public static Point3d Clip(Point3d value, Point3d min, Point3d max)
Clip a value to two limits.
value (Point3d)Value to clip.
min (Point3d)Inclusive lower limit.
max (Point3d)Inclusive upper limit.
Clipped value.

Clip

#
public static Vector3d Clip(Vector3d value, Vector3d min, Vector3d max)
Clip a value to two limits.
value (Vector3d)Value to clip.
min (Vector3d)Inclusive lower limit.
max (Vector3d)Inclusive upper limit.
Clipped value.

Clip

#
public static void Clip(decimal min, decimal max, ref decimal a, ref decimal b, ref decimal c, ref decimal d, ref decimal e, ref decimal f)
Clip a set of values to a numeric domain.
min (decimal)Domain lower bound.
max (decimal)Domain upper bound.
a (ref decimal)Value to clip.
b (ref decimal)Value to clip.
c (ref decimal)Value to clip.
d (ref decimal)Value to clip.
e (ref decimal)Value to clip.
f (ref decimal)Value to clip.

Clip

#
public static void Clip(decimal min, decimal max, ref decimal a, ref decimal b, ref decimal c, ref decimal d, ref decimal e)
Clip a set of values to a numeric domain.
min (decimal)Domain lower bound.
max (decimal)Domain upper bound.
a (ref decimal)Value to clip.
b (ref decimal)Value to clip.
c (ref decimal)Value to clip.
d (ref decimal)Value to clip.
e (ref decimal)Value to clip.

Clip

#
public static void Clip(decimal min, decimal max, ref decimal a, ref decimal b, ref decimal c, ref decimal d)
Clip a set of values to a numeric domain.
min (decimal)Domain lower bound.
max (decimal)Domain upper bound.
a (ref decimal)Value to clip.
b (ref decimal)Value to clip.
c (ref decimal)Value to clip.
d (ref decimal)Value to clip.

Clip

#
public static void Clip(decimal min, decimal max, ref decimal a, ref decimal b, ref decimal c)
Clip a set of values to a numeric domain.
min (decimal)Domain lower bound.
max (decimal)Domain upper bound.
a (ref decimal)Value to clip.
b (ref decimal)Value to clip.
c (ref decimal)Value to clip.

Clip

#
public static void Clip(decimal min, decimal max, ref decimal a, ref decimal b)
Clip a set of values to a numeric domain.
min (decimal)Domain lower bound.
max (decimal)Domain upper bound.
a (ref decimal)Value to clip.
b (ref decimal)Value to clip.

Clip

#
public static void Clip(decimal min, decimal max, ref decimal a)
Clip a set of values to a numeric domain.
min (decimal)Domain lower bound.
max (decimal)Domain upper bound.
a (ref decimal)Value to clip.

Clip

#
public static void Clip(double min, double max, ref double a, ref double b, ref double c, ref double d, ref double e, ref double f)
Clip a set of values to a numeric domain.
min (double)Domain lower bound.
max (double)Domain upper bound.
a (ref double)Value to clip.
b (ref double)Value to clip.
c (ref double)Value to clip.
d (ref double)Value to clip.
e (ref double)Value to clip.
f (ref double)Value to clip.

Clip

#
public static void Clip(double min, double max, ref double a, ref double b, ref double c, ref double d, ref double e)
Clip a set of values to a numeric domain.
min (double)Domain lower bound.
max (double)Domain upper bound.
a (ref double)Value to clip.
b (ref double)Value to clip.
c (ref double)Value to clip.
d (ref double)Value to clip.
e (ref double)Value to clip.

Clip

#
public static void Clip(double min, double max, ref double a, ref double b, ref double c, ref double d)
Clip a set of values to a numeric domain.
min (double)Domain lower bound.
max (double)Domain upper bound.
a (ref double)Value to clip.
b (ref double)Value to clip.
c (ref double)Value to clip.
d (ref double)Value to clip.

Clip

#
public static void Clip(double min, double max, ref double a, ref double b, ref double c)
Clip a set of values to a numeric domain.
min (double)Domain lower bound.
max (double)Domain upper bound.
a (ref double)Value to clip.
b (ref double)Value to clip.
c (ref double)Value to clip.

Clip

#
public static void Clip(double min, double max, ref double a, ref double b)
Clip a set of values to a numeric domain.
min (double)Domain lower bound.
max (double)Domain upper bound.
a (ref double)Value to clip.
b (ref double)Value to clip.

Clip

#
public static void Clip(double min, double max, ref double a)
Clip a set of values to a numeric domain.
min (double)Domain lower bound.
max (double)Domain upper bound.
a (ref double)Value to clip.

Clip

#
public static void Clip(float min, float max, ref float a, ref float b, ref float c, ref float d, ref float e, ref float f)
Clip a set of values to a numeric domain.
min (float)Domain lower bound.
max (float)Domain upper bound.
a (ref float)Value to clip.
b (ref float)Value to clip.
c (ref float)Value to clip.
d (ref float)Value to clip.
e (ref float)Value to clip.
f (ref float)Value to clip.

Clip

#
public static void Clip(float min, float max, ref float a, ref float b, ref float c, ref float d, ref float e)
Clip a set of values to a numeric domain.
min (float)Domain lower bound.
max (float)Domain upper bound.
a (ref float)Value to clip.
b (ref float)Value to clip.
c (ref float)Value to clip.
d (ref float)Value to clip.
e (ref float)Value to clip.

Clip

#
public static void Clip(float min, float max, ref float a, ref float b, ref float c, ref float d)
Clip a set of values to a numeric domain.
min (float)Domain lower bound.
max (float)Domain upper bound.
a (ref float)Value to clip.
b (ref float)Value to clip.
c (ref float)Value to clip.
d (ref float)Value to clip.

Clip

#
public static void Clip(float min, float max, ref float a, ref float b, ref float c)
Clip a set of values to a numeric domain.
min (float)Domain lower bound.
max (float)Domain upper bound.
a (ref float)Value to clip.
b (ref float)Value to clip.
c (ref float)Value to clip.

Clip

#
public static void Clip(float min, float max, ref float a, ref float b)
Clip a set of values to a numeric domain.
min (float)Domain lower bound.
max (float)Domain upper bound.
a (ref float)Value to clip.
b (ref float)Value to clip.

Clip

#
public static void Clip(float min, float max, ref float a)
Clip a set of values to a numeric domain.
min (float)Domain lower bound.
max (float)Domain upper bound.
a (ref float)Value to clip.

ComputeOutlierMetrics

#
public static double[] ComputeOutlierMetrics(double[] values, int k)
Compute local outlier metrics for each value in a data set.
values (double[])
k (int)
Array of outlier metrics for each value.

Correlation

#
public static double Correlation(CorrelationMethod method, IEnumerable<double> a, IEnumerable<double> b)
Compute the Pearson product-moment correlation coefficient.
method (Maths.CorrelationMethod)Algorithm to use.
a (IEnumerable<double>)First data set.
b (IEnumerable<double>)Second data set.
Correlation coefficient.

Minus one represents total negative correlation.

Zero represents no correlation whatsoever.

Plus one represents total positive correlation.

Cos

#
public static Complex Cos(Complex value)
Compute the cosine of a complex value.
value (Complex)Complex value.
Cosine of angle.

Cos

#
public static double Cos(double angle)
Compute the cosine of an angle in radians.
angle (double)Angle in radians.
Cosine of angle.

Cosh

#
public static Complex Cosh(Complex value)
Compute the hyperbolic cosine of a complex value.
value (Complex)Complex value.
Hyperbolic cosine of angle.

Cosh

#
public static double Cosh(double angle)
Compute the hyperbolic cosine of an angle in radians.
angle (double)Angle in radians.
Hyperbolic cosine of angle.

CosineRule

#
public static double CosineRule(double a, double b, double c)
Apply the Law of Cosines to a triangle.
a (double)Triangle edge length.
b (double)Triangle edge length.
c (double)Triangle edge length.
Angle of triangle corner opposite edge a.

Cot

#
public static Complex Cot(Complex value)
Compute the cotangent of a complex value.
value (Complex)Complex value.
Cotangent of angle.

Cot

#
public static double Cot(double angle)
Compute the cotangent of an angle in radians.
angle (double)Angle in radians.
Cotangent of angle.

Coth

#
public static Complex Coth(Complex value)
Compute the hyperbolic cotangent of a complex value.
value (Complex)Complex value.
Hyperbolic cotangent of angle.

Coth

#
public static double Coth(double angle)
Compute the hyperbolic cotangent of an angle in radians.
angle (double)Angle in radians.
Hyperbolic cotangent of angle.

Count<T>

#
public static int Count<T>(Func<T, bool> check, params T[] items)
Count how many items pass the test.
check (Func<T, bool>)Check delegate.
items (params T[])Items to test.
Number of items that yield true.

CrossRatio

#
public static double CrossRatio(double z1, double z2, double z3, double z4)
Compute the cross ratio of four numbers.
z1 (double)
z2 (double)
z3 (double)
z4 (double)

CrossRatio

#
public static double CrossRatio(Point3d a, Point3d b, Point3d c, Point3d d)
Compute the cross ratio of four numbers. This only really makes sense if the points are collinear, but this constraint is not enforced.
a (Point3d)
b (Point3d)
c (Point3d)
d (Point3d)

Csc

#
public static Complex Csc(Complex value)
Compute the cosecant of a complex value.
value (Complex)Complex value.
Cosecant of angle.

Csc

#
public static double Csc(double angle)
Compute the cosecant of an angle in radians.
angle (double)Angle in radians.
Cosecant of angle.

Csch

#
public static Complex Csch(Complex value)
Compute the hyperbolic cosecant of a complex value.
value (Complex)Complex value.
Hyperbolic cosecant of angle.

Csch

#
public static double Csch(double angle)
Compute the hyperbolic cosecant of an angle in radians.
angle (double)Angle in radians.
Hyperbolic cosecant of angle.

CubicRoots

#
public static void CubicRoots(double a, double b, double c, double d, out double[] realRoots, out Complex[] complexRoots)
Solve the roots of a cubic polynomial in the form ax³+bx²+cx+d.
a (double)Cubic factor.
b (double)Quadratic factor.
c (double)Linear factor.
d (double)Constant factor.
realRoots (out double[])All real roots.
complexRoots (out Complex[])All complex roots.

CumulativeDensity

#
public static double CumulativeDensity(double z)
Compute the cumulative density, or Gaussian integral of a value x.
z (double)Argument.
Cumulative density up to z.

DescribeNumber

#
public static string DescribeNumber(double number, string negative = null, string zero = null, string normal = null)
Describe the magnitude of a numeric value.
number (double)Number to describe.
negative (string = null)Prefix text to insert for negative values.
zero (string = null)Text for zero values.
normal (string = null)Text for values which are neither small nor large.

DetectOutliersGrubbs

#
public static int[] DetectOutliersGrubbs(double[] values, double threshold)
Find outliers using the Grubbs-test.
values (double[])Values to analyse.
threshold (double)alpha (significance level, e.g., 0.05). Iterative two-sided Grubbs'.
Indices of outliers.

DetectOutliersModifiedZScore

#
public static int[] DetectOutliersModifiedZScore(double[] values, double threshold)
Find outliers using the modified Z-score test.
values (double[])Values to analyse.
threshold (double)modified Z-score cutoff (Iglewicz and Hoaglin recommend 3.5).
Indices of outliers.

DetectOutliersPercentile

#
public static int[] DetectOutliersPercentile(double[] values, double threshold)
Find percentile based outliers.
values (double[])Values to analyse.
threshold (double)Fraction trimmed from each tail (e.g., 0.05 trims bottom 5% and top 5%).
Indices of outliers.

DetectOutliersTrim

#
public static int[] DetectOutliersTrim(double[] values, double threshold)
Find outliers by trimming a fixed number of items from both ends of the sorted collection.
values (double[])Values to analyse.
threshold (double)Fraction of the item count trimmed from each tail.
Indices of outliers.

DetectOutliersTukey

#
public static int[] DetectOutliersTukey(double[] values, double threshold)
Find outliers using the Tukey-test.
values (double[])Values to analyse.
threshold (double)Tukey k multiplier, ranging from 1.5 = standard, to 3.0 = far outliers.
Indices of outliers.

DetectOutliersZScore

#
public static int[] DetectOutliersZScore(double[] values, double threshold)
Find outliers using the Z-score test.
values (double[])Values to analyse.
threshold (double)|z| cutoff, commonly 3.
Indices of outliers.

DiGamma

#
public static double DiGamma(double z)
Computes the DiGamma function for a real number. This is the defined as the derivative of the logarithm of the Gamma function.
z (double)Argument.
DiGamma value.

DiGammaInverse

#
public static double DiGammaInverse(double p)
Computes the inverse DiGamma function for a real number.
p (double)Argument.
DiGamma value.

DigitalRoot

#
public static int DigitalRoot(BigInteger integer)
Compute the digital root of a number. Negative numbers will retain negative roots. The digital root is the sum of all the digits in the number until only one digit remains.
integer (BigInteger)Integer to reduce.
Digital root.

DigitalRoot

#
public static int DigitalRoot(int integer)
Compute the digital root of a number. Negative numbers will retain negative roots. The digital root is the sum of all the digits in the number until only one digit remains.
integer (int)Integer to reduce.
Digital root.

DigitalRoot

#
public static int DigitalRoot(long integer)
Compute the digital root of a number. Negative numbers will retain negative roots. The digital root is the sum of all the digits in the number until only one digit remains.
integer (long)Integer to reduce.
Digital root.

Distance

#
public static double Distance(ColourMetric metric, Color a, Color b)
Measure the distance between two colours using a specific metric.
metric (Maths.ColourMetric)Difference metric.
a (Color)First colour.
b (Color)Second colour.
Measured difference.

Distance

#
public static double Distance(ColourMetric metric, Colour a, Colour b)
Measure the distance between two colours using a specific metric.
metric (Maths.ColourMetric)Difference metric.
a (Colour)First colour.
b (Colour)Second colour.
Measured difference.

Distance

#
public static double Distance(DistanceMetric metric, double[] a, double[] b)
Compute a custom distance metric between two positions.
metric (Maths.DistanceMetric)Distance metric to apply.
a (double[])First position.
b (double[])Second position.
Distance between a and b.

Distance

#
public static double Distance(DistanceMetric metric, Locus a, Locus b)
Compute a custom distance metric between two positions.
metric (Maths.DistanceMetric)Distance metric to apply.
a (Locus)First position.
b (Locus)Second position.
Distance between a and b.

Distance

#
public static double Distance(DistanceMetric metric, Point3d a, Point3d b)
Compute a custom distance metric between two positions.
metric (Maths.DistanceMetric)Distance metric to apply.
a (Point3d)First position.
b (Point3d)Second position.
Distance between a and b.

DistanceToQuadrance

#
public static double DistanceToQuadrance(double distance)
Convert a distance into a quadrance.
distance (double)Distance measure.
Quadrance.

DistanceToQuadrance

#
public static float DistanceToQuadrance(float distance)
Convert a distance into a quadrance.
distance (float)Distance measure.
Quadrance.

DoubleIf<T>

#
public static T DoubleIf<T>(bool aConditional, bool bConditional, Func<T> ab, Func<T> a, Func<T> b, Func<T> neither)
Perform a nested double conditional with lazy evaluation.
aConditional (bool)First conditional.
bConditional (bool)Second conditional.
ab (Func<T>)Value for when both are true.
a (Func<T>)Value for when only a is true.
b (Func<T>)Value for when only b is true.
neither (Func<T>)Value for then neither is true.

DoubleIf<T>

#
public static T DoubleIf<T>(bool aConditional, bool bConditional, T ab, T a, T b, T neither)
Perform a nested double conditional with greedy evaluation.
aConditional (bool)First conditional.
bConditional (bool)Second conditional.
ab (T)Value for when both are true.
a (T)Value for when only a is true.
b (T)Value for when only b is true.
neither (T)Value for then neither is true.

EdgeAverage

#
public static Point2d EdgeAverage(Point2d[] points)
Compute the average of the edges connecting a set of points.
points (Point2d[])

EdgeAverage

#
public static Point3d EdgeAverage(Point3d[] points)
Compute the average of the edges connecting a set of points.
points (Point3d[])

Erf

#
public static double Erf(double argument)
Solves the Error function for a given argument. The Error function is a sigmoid like curve from (-infinity, 0) to (+infinity, 1).
argument (double)Argument.

EstimateDecimals

#
public static int EstimateDecimals(string numericExpression)
Given a valid numeric expression, estimates the number of decimals. This is just the number of digits following the first decimal separator.
numericExpression (string)
-1 if the number has no decimals at all, otherwise the number of digits following the decimal symbol.

ExtractSubmergedByFlipping

#
public static Mesh ExtractSubmergedByFlipping(Mesh inputMesh, double[] waterLevelsPerVertex, double waterLevel, HashSet<int> wetFaces, CancellationToken ct)
Given a mesh, a water-level and the list of faces touching that lake, returns the part of the mesh *below* waterLevel by:
  1. flipping Z
  2. calling SplitMeshAtWaterLevels in single-lake mode
  3. flipping Z back
inputMesh (Mesh)
waterLevelsPerVertex (double[])
waterLevel (double)
wetFaces (HashSet<int>)
ct (CancellationToken)

Factorial

#
public static BigInteger Factorial(BigInteger n)
obsoleteUse the overload which takes a cancellation token.
Compute the factorial of a positive integer.
n (BigInteger)Integer to factorize.
Logarithm of the binomial coefficient.

Factorial

#
public static BigInteger Factorial(int n, CancellationToken token)
Compute the factorial of a positive integer.
n (int)Integer to factorize.
token (CancellationToken)Cancellation token.

Factorial

#
public static BigInteger Factorial(int n, int d, CancellationToken token)
Compute the factorial of n divided by the factorial of d.
n (int)N argument, must be one or higher.
d (int)D argument, must be between one and n inclusive.
token (CancellationToken)Cancellation token.

Factorial

#
public static BigInteger Factorial(int n, int d)
obsoleteUse the overload which takes a cancellation token.
Compute the factorial of n divided by the factorial of d.
n (int)N argument, must be one or higher.
d (int)D argument, must be between one and n inclusive.

Factorial

#
public static BigInteger Factorial(int n)
obsoleteUse the overload which takes a cancellation token.
Compute the factorial of a positive integer.
n (int)Integer to factorize.

Factorial

#
public static double Factorial(double x, CancellationToken token)
Compute the factorial of a floating point value using the Gamma function.
x (double)Value.
token (CancellationToken)Cancellation token.
Factorial of x.

Factorial

#
public static double Factorial(double x)
obsoleteUse the overload which takes a cancellation token.
Compute the factorial of a floating point value using the Gamma function.
x (double)Value.
Factorial of x.

FactorialInverse

#
public static double FactorialInverse(int k, CancellationToken token)
Compute the one-over-factorial of a positive integer.
k (int)Integer to reverse factorize.
token (CancellationToken)Cancellation token.
Inverse factorial of k.

FactorialInverse

#
public static double FactorialInverse(int k)
Compute the one-over-factorial of a positive integer.
k (int)Integer to reverse factorize.
Inverse factorial of k.

FactorialLn

#
public static double FactorialLn(int k)
Compute the natural logarithm of the factorial of an integer.
k (int)Integer to factorize.
Logarithm of the binomial coefficient.

FindCubicRoots

#
public static double[] FindCubicRoots(double a, double b, double c, double d)
Find the real roots of the cubic equation ax^3 + bx^2 + cx + d = 0. The solutions are typically accurate to within roughly 1e-15, though they are included as real solutions if they yield zeros within 1e-12. You may want to perform additional checking to see whether you are happy using all roots.
a (double)Cube factor.
b (double)Square factor.
c (double)Linear factor.
d (double)Constant factor.
An array containing zero, one, two or three real roots.

FindFactors

#
public static IEnumerable<(int A, int B)> FindFactors(int integer)
Find all the factors pairs for this integer. Pairs with 1xN are not included. If the integer is negative, the first factor is always negative while the second factor is always positive.
integer (int)Integer to factorize.
Array of factor pairs.

FindLinearRoot

#
public static double[] FindLinearRoot(double a, double b)
Find the real root of the linear equation ax + b = 0.
a (double)Linear factor.
b (double)Constant factor.
An array containing one real root, or no roots if a=0.

FindMinimum

#
public static (bool success, double bestParameter, double smallestDeviation) FindMinimum(Func<double, double> function, double lowerLimit, double upperLimit, int maximumIterations = 128)
Use the Brent minimizer provided by the Math.NET package to find where a function is lowest.
function (Func<double, double>)Function to sample.
lowerLimit (double)Initial lower limit for the x-bracketing.
upperLimit (double)Initial upper limit for the x-bracketing.
maximumIterations (int = 128)Maximum number of iterations before the finder gives up.
Result of search. Note that the found solution may be very good even if 'success' is false. And vice versa.

FindMonotoneY

#
public static double FindMonotoneY(Func<double, double> function, double start, double targetY)
Find the parameter in a monotone increasing function which yields the given target.
function (Func<double, double>)Function to search.
start (double)Start parameter.
targetY (double)Target y value to find.

FindQuadraticRoots

#
public static double[] FindQuadraticRoots(double a, double b, double c)
Find the real roots of the quadradic equation ax^2 + bx + c = 0.
a (double)Square factor.
b (double)Linear factor.
c (double)Constant factor.
An array containing zero, one or two real roots.

FindRoot

#
public static (bool success, double bestParameter, double smallestDeviation) FindRoot(Func<double, double> function, double lowerLimit, double upperLimit, double accuracy = 1E-08, int maximumIterations = 64)
Use the Brent root finder provided by the Math.NET package to find where a function equal zero or best approximates zero.
function (Func<double, double>)Function to sample.
lowerLimit (double)Hard lower limit of function(x) argument.
upperLimit (double)Hard upper limit of function(x) argument.
accuracy (double = 1E-08)Desired accuracy.
maximumIterations (int = 64)Maximum number of iterations before the finder gives up.

FindRoot

#
public static bool FindRoot(Func<double, double> function, (double lower, double upper) limits, double accuracy, int maxAttempts, out double root)
Find the root of a custom function using the Brent-Dekker algorithm.
function (Func<double, double>)Function to investigate.
limits ((double lower, double upper))Limits for root search.
accuracy (double)Desired accuracy.
maxAttempts (int)Maximum allowed attempts.
root (out double)Found root.
Found root or double.NaN

FindRoot

#
public static double FindRoot(Func<double, double> function, Func<double, double> derivative, double lower, double upper, double accuracy, int maxAttempts)
Find the root of a custom function using a robust Newton-Rhapson algorithm. This root finder requires a correct derivative.
function (Func<double, double>)Function to investigate.
derivative (Func<double, double>)Derivative of function.
lower (double)Lower limit for root search.
upper (double)Upper limit for root search.
accuracy (double)Desired accuracy.
maxAttempts (int)Maximum allowed attempts.
Found root or double.NaN

FindRootLoose

#
public static (bool success, double bestParameter, double smallestDeviation) FindRootLoose(Func<double, double> function, double lowerLimit, double upperLimit, double accuracy = 1E-08, int maximumIterations = 64)
Use the Brent root finder provided by the Math.NET package to find where a function equal zero or best approximates zero.
function (Func<double, double>)Function to sample.
lowerLimit (double)Cue for lower limit of function(x) argument. This limit will be expanded if a solution cannot be found otherwise.
upperLimit (double)Cue for upper limit of function(x) argument. This limit will be expanded if a solution cannot be found otherwise.
accuracy (double = 1E-08)Desired accuracy.
maximumIterations (int = 64)Maximum number of iterations before the finder gives up.

Floor

#
public static Complex Floor(Complex value)
Default Grasshopper floor method.
value (Complex)Value to round.
Rounded value.

Floor

#
public static decimal Floor(decimal value)
Default Grasshopper floor method.
value (decimal)Value to round.
Rounded value.

Floor

#
public static double Floor(double value)
Default Grasshopper floor method.
value (double)Value to round.
Rounded value.

Floor

#
public static float Floor(float value)
Default Grasshopper floor method.
value (float)Value to round.
Rounded value.

Floor

#
public static Point3d Floor(Point3d value)
Default Grasshopper floor method.
value (Point3d)Value to round.
Rounded value.

Floor

#
public static Vector3d Floor(Vector3d value)
Default Grasshopper floor method.
value (Vector3d)Value to round.
Rounded value.

Gamma

#
public static Complex Gamma(Complex z)
Computes the gamma function for a complex argument.
z (Complex)Argument.

Gamma

#
public static double Gamma(double z)
Computes the Gamma function for a real number.
z (double)Argument.
Gamma value.

GammaLn

#
public static double GammaLn(double z)
Computes the natural logarithm of the Gamma function for a real number.
z (double)Argument.
Gamma value.

GM

#
public static Complex GM(Complex a, Complex b)
Compute the Geometric mean of two numbers.
a (Complex)First number.
b (Complex)Second number.
Geometric mean.

GM

#
public static double GM(double a, double b)
Compute the Geometric mean of two numbers.
a (double)First number.
b (double)Second number.
Geometric mean.

GreatestCommonDivisor

#
public static BigInteger GreatestCommonDivisor(BigInteger a, BigInteger b)
Compute the greates common divisor shared between two positive integers a and b. The GCD (x) of two numbers is the biggest integer for which it is possible to write a=x*i and b=x*j.
a (BigInteger)First integer.
b (BigInteger)Second integer.
Highest common factor.

GreatestCommonDivisor

#
public static BigInteger GreatestCommonDivisor(params BigInteger[] numbers)
Compute the greates common divisor shared between a collection of positive integers a and b. The GCD (x) of a set of numbers is the biggest integer for which it is possible to write a=x*i, b=x*j, c=x*k, ...
numbers (params BigInteger[])Array of integers.
Greatest common divisor for all numbers.

GreatestCommonDivisor

#
public static int GreatestCommonDivisor(int a, int b)
Compute the greates common divisor shared between two positive integers a and b. The GCD (x) of two numbers is the biggest integer for which it is possible to write a=x*i and b=x*j.
a (int)First integer.
b (int)Second integer.
Greatest common divisor for a and b.

GreatestCommonDivisor

#
public static int GreatestCommonDivisor(params int[] numbers)
Compute the greates common divisor shared between a collection of positive integers a and b. The GCD (x) of a set of numbers is the biggest integer for which it is possible to write a=x*i, b=x*j, c=x*k, ...
numbers (params int[])Array of integers.
Greatest common divisor for all numbers.

Hankel1

#
public static Complex Hankel1(double order, Complex z)
Evaluate the Hankel function of the first kind.
order (double)Order of function.
z (Complex)Argument.

Hankel2

#
public static Complex Hankel2(double order, Complex z)
Evaluate the Hankel function of the second kind.
order (double)Order of function.
z (Complex)Argument.

Harmonic

#
public static double Harmonic(int n)
Compute the Nth harmonic number. This is the sum of the reciprocals of the first N natural numbers.
n (int)Number index.
The Nth harmonic number.

HarmonicGeneral

#
public static double HarmonicGeneral(int n, double exponent)
Compute the Nth generalised harmonic number. This is the sum of the reciprocals of the first N natural numbers, all raised to the given exponent.
n (int)Number index.
exponent (double)Custom exponent.
The Nth harmonic number.

Hash

#
public static void Hash(byte[] data, out byte[] hash)
Compute the hash value of the byte array.
data (byte[])Data to hash.
hash (out byte[])Hash array.

Hash

#
public static void Hash(byte[] data, out Guid hash)
Compute the hash value of the byte array.
data (byte[])Data to hash.
hash (out Guid)Hash ID.

Hash

#
public static void Hash(string data, out byte[] hash)
Compute the hash value of a string.
data (string)Data to hash.
hash (out byte[])Hash array.

Hash

#
public static void Hash(string data, out Guid hash)
Compute the hash value of a string.
data (string)Data to hash.
hash (out Guid)Hash ID.

HM

#
public static Complex HM(Complex a, Complex b)
Compute the Harmonic mean of two numbers.
a (Complex)First number.
b (Complex)Second number.
Harmonic mean.

HM

#
public static double HM(double a, double b)
Compute the Harmonic mean of two numbers.
a (double)First number.
b (double)Second number.
Harmonic mean.

InfinitySign

#
public static int InfinitySign(double value)
Sign implemented for infinities.
value (double)Value to test.
-1 for negative infinity, +1 for positive infinity, 0 for finite values.

IntegralAndFractional

#
public static bool IntegralAndFractional(double domain0, double domain1, double value, out long integral, out double fractional)
Gets the normalised integral and fractional portions of a number.
domain0 (double)Unit domain start.
domain1 (double)Unit domain end.
value (double)Value to examine.
integral (out long)Index of consecutive domain the value is in.
fractional (out double)Normalised fractional part of value within containing domain.

IntegralAndFractionalNormal

#
public static bool IntegralAndFractionalNormal(double value, out long integral, out double fractional)
Gets the normalised integral and fractional portions of a number within the repeated unit interval.
value (double)Value to examine.
integral (out long)Index of consecutive domain the value is in.
fractional (out double)Normalised fractional part of value within containing domain.

IntegrateExponentialTransform

#
public static double IntegrateExponentialTransform(Func<double, double> function, double x0, double x1, double error = 0.1)
Approximate an integral using the double exponential transformation. This integrator is suitable for smooth functions with poles and discontinuous in the derivative.
function (Func<double, double>)Function to integrate.
x0 (double)Start of integral domain.
x1 (double)End of integral domain.
error (double = 0.1)Target error.
Approximate integral.

IntegrateGaussLegendre

#
public static double IntegrateGaussLegendre(Func<double, double> function, double x0, double x1, int order)
Approximate an integral using the Gauss-Legendre rule. This integrator is suitable for polynomials with known degree.
function (Func<double, double>)Function to integrate.
x0 (double)Start of integral domain.
x1 (double)End of integral domain.
order (int)Polynomial order.
Approximate integral.

IntegrateNewtonCotes

#
public static double IntegrateNewtonCotes(Func<double, double> function, double x0, double x1, double error = 0.1)
Approximate an integral using the Newton-Cotes trapezoidal rule. This integrator often yields poor results, consider using IntegrateExponentialTransform(Func<double, double>, double, double, double) instead.
function (Func<double, double>)Function to integrate.
x0 (double)Start of integral domain.
x1 (double)End of integral domain.
error (double = 0.1)Target error.
Approximate integral.

IntegrateSimpson

#
public static double IntegrateSimpson(Func<double, double> function, double x0, double x1, int partitions)
Approximate an integral using Simpson's rule.
function (Func<double, double>)Function to integrate.
x0 (double)Start of integral domain.
x1 (double)End of integral domain.
partitions (int)Number of partitions.
Approximate integral.

IntervalFraction

#
public static double IntervalFraction(double val, Interval i)
Compute the fraction of the interval length defined by a value.
val (double)Value within the interval
i (Interval)Interval to consider
Fraction of interval length

IsAnyInfinite

#
public static bool IsAnyInfinite(params double[] values)
Test whether any value is infinite.
values (params double[])Value to check.
True if all values are nan.

IsAnyNaN

#
public static bool IsAnyNaN(params double[] values)
Test whether any value is NaN.
values (params double[])Value to check.
True if all values are nan.

IsPrime

#
public static bool IsPrime(int number)
Test whether a given integer is a known prime. If the number is less than HighestCachedPrime then this lookup is O(1), otherwise it'll be slow.
number (int)Number to check.
True if number is a known prime.

IsSquare

#
public static bool IsSquare(int integer, out int base)
Gets whether an integer is a perfect square.
integer (int)Integer to test.
base (out int)Number which, when squared, results in this integer.
True if the integer is a square.

IsSquare

#
public static bool IsSquare(int integer)
Gets whether an integer is a perfect square.
integer (int)Integer to test.
True if the integer is a square.

Kurtosis

#
public static double Kurtosis(IEnumerable<double> data)
Estimates the unbiased kurtosis of a population.
data (IEnumerable<double>)Population of values, must contain at least four numbers.
Estimated kurtosis.

LeastCommonMultiple

#
public static BigInteger LeastCommonMultiple(BigInteger a, BigInteger b)
Compute the least common multiple of two numbers. The lcm is the smallest positive number that is a multiple of both a and b.
a (BigInteger)First integer.
b (BigInteger)Second integer.
Least common multiple.

LeastCommonMultiple

#
public static BigInteger LeastCommonMultiple(int a, int b)
Compute the least common multiple of two numbers. The lcm is the smallest positive number that is a multiple of both a and b.
a (int)First integer.
b (int)Second integer.
Least common multiple.

LeastCommonMultiple

#
public static BigInteger LeastCommonMultiple(params BigInteger[] numbers)
Compute the least common multiple of a set of numbers. The lcm is the smallest positive number that is a multiple of a, b, c, ...
numbers (params BigInteger[])Array of integers.
Least common multiple.

LeastCommonMultiple

#
public static BigInteger LeastCommonMultiple(params int[] numbers)
Compute the least common multiple of a set of numbers. The lcm is the smallest positive number that is a multiple of a, b, c, ...
numbers (params int[])Array of integers.
Least common multiple.

LinearCrossing

#
public static double LinearCrossing(double x0, double y0, double x1, double y1, double yTarget)
Linearly extrapolate or interpolate two coordinates to intersect a contant Y value.
x0 (double)X of first sample.
y0 (double)Value of first sample.
x1 (double)X of second sample.
y1 (double)Value of second sample.
yTarget (double)Target value.
X linked to target value.

LinearRegression

#
public static bool LinearRegression(double[] x, double[] y, out double slope, out double intercept)
Perform simple linear regression on a set of values, resulting in the linear equation f(x) = slope*x + intercept
x (double[])Value x coordinates.
y (double[])Value y coordinates.
slope (out double)Regression slope.
intercept (out double)Regression intercept on y-axis.
True on success, false on failure.

Logistic

#
public static double Logistic(double x, double maximum, double steepness, double xNought)
Computes the Logistic function for custom parameters.
x (double)Value.
maximum (double)Maximum value (i.e. vertical scaling).
steepness (double)Steepness of curve at x-nought.
xNought (double)Horizontal centre of curve.
Logistic.

Logistic

#
public static double Logistic(double x)
Computes the Logistic function for standard parameters.
x (double)Value.
Logistic.

Logit

#
public static double Logit(double x, double maximum, double steepness, double xNought)
Computes the inverse logistic function for custom parameters.
x (double)Value between zero and maximum.
maximum (double)Maximum value (i.e. vertical scaling).
steepness (double)Steepness of curve at x-nought.
xNought (double)Horizontal centre of curve.
Logit.

Logit

#
public static double Logit(double x)
Computes the inverse logistic function for standard parameters.
x (double)Value between zero and one.
Logit.

LSystemIteration

#
public static string LSystemIteration(string axiom, Dictionary<char, string> rules, CancellationToken token)
Apply a single L-System iteration.
axiom (string)Initial string.
rules (Dictionary<char, string>)Set of rules.
token (CancellationToken)Cancellation token.
Modified string.

LSystemIteration

#
public static string LSystemIteration(string axiom, params (char symbol, string expansion)[] rules)
Apply a single L-System iteration.
axiom (string)Initial string.
rules (params (char symbol, string expansion)[])Set of rules.
Modified string.

Max

#
public static BigInteger Max(BigInteger a, BigInteger b)
Find the largest integer in a set.
a (BigInteger)
b (BigInteger)
Maximum of all supplied values.

Max

#
public static BigInteger Max(params BigInteger[] values)
Find the largest integer in a set.
values (params BigInteger[])
Maximum of all supplied values.

Max

#
public static Complex Max(Complex a, Complex b)
Create a complex value consisting of the largest real and imaginary parts.
a (Complex)
b (Complex)

Max

#
public static decimal Max(params decimal[] values)
Find the largest decimal in a set.
values (params decimal[])
Maximum of all supplied values.

Max

#
public static double Max(double a, double b, double c)
Find the largest double in a set.
a (double)
b (double)
c (double)
Maximum of all supplied values.

Max

#
public static double Max(double a, double b)
Find the largest double in a set.
a (double)
b (double)
Maximum of all supplied values.

Max

#
public static double Max(params double[] values)
Find the largest double in a set.
values (params double[])
Maximum of all supplied values.

Max

#
public static float Max(float a, float b, float c)
Find the largest float in a set.
a (float)
b (float)
c (float)
Maximum of all supplied values.

Max

#
public static float Max(float a, float b)
Find the largest float in a set.
a (float)
b (float)
Maximum of all supplied values.

Max

#
public static float Max(params float[] values)
Find the largest float in a set.
values (params float[])
Maximum of all supplied values.

Max

#
public static int Max(int a, int b, int c)
Find the largest integer in a set.
a (int)
b (int)
c (int)
Maximum of all supplied values.

Max

#
public static int Max(int a, int b)
Find the largest integer in a set.
a (int)
b (int)
Maximum of all supplied values.

Max

#
public static int Max(params int[] values)
Find the largest integer in a set.
values (params int[])
Maximum of all supplied values.

Max

#
public static Point3d Max(Point3d a, Point3d b)
Create a point with the largest three components.
a (Point3d)
b (Point3d)

Max

#
public static Size Max(Size a, Size b)
Find the biggest dimensions of two sizes.
a (Size)First size.
b (Size)Second size.
Highest of all supplied values.

Max

#
public static SizeF Max(SizeF a, SizeF b)
Find the biggest dimensions of two sizes.
a (SizeF)First size.
b (SizeF)Second size.
Highest of all supplied values.

Max

#
public static Vector3d Max(Vector3d a, Vector3d b)
Create a vector with the largest three components.
a (Vector3d)
b (Vector3d)

MaxIndex

#
public static int MaxIndex(params BigInteger[] values)
Find the index of the largest integer in a set.
values (params BigInteger[])
Index of largest value.

MaxIndex

#
public static int MaxIndex(params decimal[] values)
Find the index of the largest decimal in a set.
values (params decimal[])
Index of largest value.

MaxIndex

#
public static int MaxIndex(params double[] values)
Find the index of the largest double in a set.
values (params double[])
Index of largest value.

MaxIndex

#
public static int MaxIndex(params float[] values)
Find the index of the largest float in a set.
values (params float[])
Index of largest value.

MaxIndex

#
public static int MaxIndex(params int[] values)
Find the index of the largest integer in a set.
values (params int[])
Index of largest value.

Mean

#
public static Complex Mean(MeanKind kind, IEnumerable<Complex> data)
Compute the mean of a data set.
kind (Maths.MeanKind)Kind of mean to estimate.
data (IEnumerable<Complex>)Data to measure.
Mean.

Mean

#
public static double Mean(MeanKind kind, IEnumerable<BigInteger> data)
Compute the mean of a data set.
kind (Maths.MeanKind)Kind of mean to estimate.
data (IEnumerable<BigInteger>)Data to measure.
Mean.

Mean

#
public static double Mean(MeanKind kind, IEnumerable<double> data)
Compute the mean of a data set.
kind (Maths.MeanKind)Kind of mean to estimate.
data (IEnumerable<double>)Data to measure.
Mean.

Mean

#
public static double Mean(MeanKind kind, IEnumerable<int> data)
Compute the mean of a data set.
kind (Maths.MeanKind)Kind of mean to estimate.
data (IEnumerable<int>)Data to measure.
Mean.

Mean

#
public static Point3d Mean(MeanKind kind, IEnumerable<Point3d> data)
Compute the mean of a data set.
kind (Maths.MeanKind)Kind of mean to estimate.
data (IEnumerable<Point3d>)Data to measure.
Mean.

Mean

#
public static Vector3d Mean(MeanKind kind, IEnumerable<Vector3d> data)
Compute the mean of a data set.
kind (Maths.MeanKind)Kind of mean to estimate.
data (IEnumerable<Vector3d>)Data to measure.
Mean.

Median

#
public static double Median(double[] values)
Gets the median of an array of doubles.
values (double[])Value for median.

Median

#
public static double Median(float[] values)
Gets the median of an array of floats.
values (float[])Value for median.

Median

#
public static double Median(IEnumerable<double> values)
Gets the median of a collection of doubles.
values (IEnumerable<double>)Value for median.

Median

#
public static double Median(IEnumerable<float> values)
Gets the median of a collection of floats.
values (IEnumerable<float>)Value for median.

Median

#
public static double Median(IEnumerable<int> values)
Gets the median of a collection of integers.
values (IEnumerable<int>)Value for median.

Median

#
public static double Median(int[] values)
Gets the median of an array of integers.
values (int[])Value for median.

Mid

#
public static Complex Mid(params Complex[] values)
Compute the arithmetic mean of a data set.
values (params Complex[])Value to average.
Mean.

Mid

#
public static decimal Mid(params decimal[] values)
Compute the arithmetic mean of a data set.
values (params decimal[])Value to average.
Mean.

Mid

#
public static double Mid(params double[] values)
Compute the arithmetic mean of a data set.
values (params double[])Value to average.
Mean.

Mid

#
public static double Mid(params int[] values)
Compute the arithmetic integral mean of a data set.
values (params int[])Value to average.
Mean.

Mid

#
public static float Mid(params float[] values)
Compute the arithmetic mean of a data set.
values (params float[])Value to average.
Mean.

Mid

#
public static Point3d Mid(params Point3d[] values)
Compute the arithmetic mean of a data set.
values (params Point3d[])Value to average.
Mean.

Mid

#
public static Vector3d Mid(params Vector3d[] values)
Compute the arithmetic mean of a data set.
values (params Vector3d[])Value to average.
Mean.

MidIntegral

#
public static (BigInteger mean, double remainder) MidIntegral(params BigInteger[] values)
Compute the arithmetic integral mean of a data set.
values (params BigInteger[])Value to average.
Mean.

MidIntegral

#
public static (int mean, double remainder) MidIntegral(params int[] values)
Compute the arithmetic integral mean of a data set.
values (params int[])Value to average.
Mean.

Min

#
public static BigInteger Min(BigInteger a, BigInteger b)
Find the smallest integer in a set.
a (BigInteger)
b (BigInteger)
Minimum of all supplied values.

Min

#
public static BigInteger Min(params BigInteger[] values)
Find the smallest integer in a set.
values (params BigInteger[])
Minimum of all supplied values.

Min

#
public static Complex Min(Complex a, Complex b)
Create a complex value consisting of the smallest real and imaginary parts.
a (Complex)
b (Complex)

Min

#
public static decimal Min(params decimal[] values)
Find the smallest decimal in a set.
values (params decimal[])
Minimum of all supplied values.

Min

#
public static double Min(double a, double b, double c)
Find the smallest double in a set.
a (double)
b (double)
c (double)
Minimum of all supplied values.

Min

#
public static double Min(double a, double b)
Find the smallest double in a set.
a (double)
b (double)
Minimum of all supplied values.

Min

#
public static double Min(params double[] values)
Find the smallest double in a set.
values (params double[])
Minimum of all supplied values.

Min

#
public static float Min(float a, float b, float c)
Find the smallest float in a set.
a (float)
b (float)
c (float)
Minimum of all supplied values.

Min

#
public static float Min(float a, float b)
Find the smallest float in a set.
a (float)
b (float)
Minimum of all supplied values.

Min

#
public static float Min(params float[] values)
Find the smallest float in a set.
values (params float[])
Minimum of all supplied values.

Min

#
public static int Min(int a, int b, int c)
Find the smallest integer in a set.
a (int)
b (int)
c (int)
Minimum of all supplied values.

Min

#
public static int Min(int a, int b)
Find the smallest integer in a set.
a (int)
b (int)
Minimum of all supplied values.

Min

#
public static int Min(params int[] values)
Find the smallest integer in a set.
values (params int[])
Minimum of all supplied values.

Min

#
public static Point3d Min(Point3d a, Point3d b)
Create a point with the smallest three components.
a (Point3d)
b (Point3d)

Min

#
public static Size Min(Size a, Size b)
Find the smallest dimensions of two sizes.
a (Size)First size.
b (Size)Second size.
Lowest of all supplied values.

Min

#
public static SizeF Min(SizeF a, SizeF b)
Find the smallest dimensions of two sizes.
a (SizeF)First size.
b (SizeF)Second size.
Lowest of all supplied values.

Min

#
public static Vector3d Min(Vector3d a, Vector3d b)
Create a vector with the smallest three components.
a (Vector3d)
b (Vector3d)

MinIndex

#
public static int MinIndex(params BigInteger[] values)
Find the index of the smallest integer in a set.
values (params BigInteger[])
Index of smallest value.

MinIndex

#
public static int MinIndex(params decimal[] values)
Find the index of the smallest decimal in a set.
values (params decimal[])
Index of smallest value.

MinIndex

#
public static int MinIndex(params double[] values)
Find the index of the smallest double in a set.
values (params double[])
Index of smallest value.

MinIndex

#
public static int MinIndex(params float[] values)
Find the index of the smallest float in a set.
values (params float[])
Index of smallest value.

MinIndex

#
public static int MinIndex(params int[] values)
Find the index of the smallest integer in a set.
values (params int[])
Index of smallest value.

MinMax

#
public static void MinMax(BigInteger a, BigInteger b, out BigInteger min, out BigInteger max)
Distribute two values by magnitude.
a (BigInteger)First value.
b (BigInteger)Second value.
min (out BigInteger)Lowest of a and b.
max (out BigInteger)Highest of a and b.

MinMax

#
public static void MinMax(decimal a, decimal b, out decimal min, out decimal max)
Distribute two values by magnitude.
a (decimal)First value.
b (decimal)Second value.
min (out decimal)Lowest of a and b.
max (out decimal)Highest of a and b.

MinMax

#
public static void MinMax(double a, double b, out double min, out double max)
Distribute two values by magnitude.
a (double)First value.
b (double)Second value.
min (out double)Lowest of a and b.
max (out double)Highest of a and b.

MinMax

#
public static void MinMax(float a, float b, out float min, out float max)
Distribute two values by magnitude.
a (float)First value.
b (float)Second value.
min (out float)Lowest of a and b.
max (out float)Highest of a and b.

MinMax

#
public static void MinMax(int a, int b, out int min, out int max)
Distribute two values by magnitude.
a (int)First value.
b (int)Second value.
min (out int)Lowest of a and b.
max (out int)Highest of a and b.

Multiple

#
public static Complex Multiple(Complex value, Complex unit)
Default Grasshopper multiple method.
value (Complex)Value to round.
unit (Complex)Multiple unit size.
Value rounded to nearest integral multiple of unit.

Multiple

#
public static decimal Multiple(decimal value, decimal unit)
Default Grasshopper multiple method.
value (decimal)Value to round.
unit (decimal)Multiple unit size.
Value rounded to nearest integral multiple of unit.

Multiple

#
public static double Multiple(double A, double a, MultipleMethod method)
Count the number of times one value fits inside another.
A (double)Main value.
a (double)Partial value.
method (Maths.MultipleMethod)Counting method.

Multiple

#
public static double Multiple(double value, double unit)
Default Grasshopper multiple method.
value (double)Value to round.
unit (double)Multiple unit size.
Value rounded to nearest integral multiple of unit.

Multiple

#
public static float Multiple(float value, float unit)
Default Grasshopper multiple method.
value (float)Value to round.
unit (float)Multiple unit size.
Value rounded to nearest integral multiple of unit.

Multiple

#
public static Point3d Multiple(Point3d value, double unit)
Default Grasshopper multiple method.
value (Point3d)Value to round.
unit (double)Multiple unit size.
Value rounded to nearest integral multiple of unit.

Multiple

#
public static Vector3d Multiple(Vector3d value, double unit)
Default Grasshopper multiple method.
value (Vector3d)Value to round.
unit (double)Multiple unit size.
Value rounded to nearest integral multiple of unit.

MySplitMeshAtWaterLevels

#
public static (Mesh Dry, List<double> DryLevels, Mesh[] Submerged, Mesh[] LakeTops) MySplitMeshAtWaterLevels(Mesh inputMesh, double[] waterLevelsPerVertex, (double waterLevel, HashSet<int> wetFaces)[] lakes, CancellationToken ct, bool dryOnly = false)
Splits a mesh by multiple lakes at once. Returns:
  • Dry: everything never below *any* lake.
  • Submerged[i]: the pieces under lake #i.
Lakes[] is an array of (level, wetFaces) tuples, where wetFaces lists the original‐mesh face‐indices that lake i touches. For a single arbitrary-plane split (no terrain bookkeeping), use SplitMeshByPlane(Mesh, Plane, double, CancellationToken) instead.
inputMesh (Mesh)
waterLevelsPerVertex (double[])
lakes ((double waterLevel, HashSet<int> wetFaces)[])
ct (CancellationToken)
dryOnly (bool = false)

NansAndInfinities

#
public static bool NansAndInfinities(out int nans, out int infinities, params double[] values)
Count all nans and infinities in a collection of doubles.
nans (out int)Number of nans found.
infinities (out int)Number of infinities found.
values (params double[])Value to check.
True if any nans or infinities were found.

Normalise

#
public static void Normalise(double target, ref double a, ref double b, ref double c, ref double d, ref double e, ref double f)
Normalise six value so that their sum is equal to target.
target (double)Target of sum.
a (ref double)First value.
b (ref double)Second value.
c (ref double)Third value
d (ref double)Fourth value.
e (ref double)Fifth value.
f (ref double)Sixth value.

Normalise

#
public static void Normalise(double target, ref double a, ref double b, ref double c, ref double d, ref double e)
Normalise five value so that their sum is equal to target.
target (double)Target of sum.
a (ref double)First value.
b (ref double)Second value.
c (ref double)Third value
d (ref double)Fourth value.
e (ref double)Fifth value.

Normalise

#
public static void Normalise(double target, ref double a, ref double b, ref double c, ref double d)
Normalise four value so that their sum is equal to target.
target (double)Target of sum.
a (ref double)First value.
b (ref double)Second value.
c (ref double)Third value
d (ref double)Fourth value.

Normalise

#
public static void Normalise(double target, ref double a, ref double b, ref double c)
Normalise three value so that their sum is equal to target.
target (double)Target of sum.
a (ref double)First value.
b (ref double)Second value.
c (ref double)Third value

Normalise

#
public static void Normalise(double target, ref double a, ref double b)
Normalise two value so that their sum is equal to target.
target (double)Target of sum.
a (ref double)First value.
b (ref double)Second value.

NthPermutation

#
public static Maths.IndexMap NthPermutation(int sequenceLength, int n, CancellationToken token)
Compute the Nth permutation of an integer sequence using standard permutation patterns.
sequenceLength (int)Number of elements to permute.
n (int)Permutation index to create.
token (CancellationToken)Cancellation token.
The Nth permutation containing all the integers between zero and n-1 inclusive.

NthPrime

#
public static int NthPrime(int n)
Gets the Nth prime number.
n (int)Nth prime. N may range from 1 to PrimeCount.
Prime associated with index.

Parse

#
public static bool Parse(string notation, out BigInteger value)
Parse a notation possibly containing constants and exponents. This method starts with the Framework integer parser, then checks for Grasshopper scientific notation.
notation (string)Notation to parse.
value (out BigInteger)Value which seemed to be implied.
True if parsing worked.

Parse

#
public static bool Parse(string notation, out decimal value)
Parse a notation possibly containing constants and exponents. This method starts with the Framework decimal parser, then checks for Grasshopper scientific notation, and finally considers multiples of pi.
notation (string)Notation to parse.
value (out decimal)Value which seemed to be implied.
True if parsing worked.

Parse

#
public static bool Parse(string notation, out double value)
Parse a notation possibly containing constants and exponents. This method starts with the Framework double parser, then checks for Grasshopper scientific notation, and finally considers multiples of pi.
notation (string)Notation to parse.
value (out double)Value which seemed to be implied.
True if parsing worked.

Parse

#
public static bool Parse(string notation, out int value)
Parse a notation possibly containing constants and exponents. This method starts with the Framework integer parser, then checks for Grasshopper scientific notation.
notation (string)Notation to parse.
value (out int)Value which seemed to be implied.
True if parsing worked.

ParseNumberAt

#
public static bool ParseNumberAt(string notation, int start, out int end, out object value)
Try and parse a number from a sub-string. Note that this method does *not* pay attention to the preceding characters in the string. It only looks ahead. Types of notation this method understands include:

Straight up integers: 1, 8, -500000

Straight up floats: 4.8, -600.8, -.5

Scientific notation: 1e-6, -7.078e200, 5*10^20, 5·10², 55×10³

Pi suffixes: π, 5π, 0.5pi

Imaginary suffixes: i, 45.7i

Degree symbols: 45°, -180.5°

notation (string)String containing a potential number.
start (int)Index to start parsing from.
end (out int)Index *after* the parsed number on success, or just 'start' if parsing did not succeed.
value (out object)Numeric value. Either an int, a BigInteger, a double, a Complex, or an Angle.
True if a number could be parsed from the substring.

Permutations

#
public static IEnumerable<Maths.IndexMap> Permutations(int n, CancellationToken token, Random random = null)
Generate random permutations.
n (int)Length of list to permute.
token (CancellationToken)Cancellation token.
random (Random = null)Random engine for permutation shuffling.

Ping

#
public static BigInteger Ping(BigInteger value, BigInteger min, BigInteger max)
Ping-pong a value between two limits.
value (BigInteger)Value to clip.
min (BigInteger)Inclusive lower limit.
max (BigInteger)Inclusive upper limit.

Ping

#
public static Complex Ping(Complex value, Complex min, Complex max)
Ping-pong a value between two limits.
value (Complex)Value to clip.
min (Complex)Lower limit.
max (Complex)Upper limit.

Ping

#
public static decimal Ping(decimal value, decimal min, decimal max)
Ping-pong a value between two limits.
value (decimal)Value to clip.
min (decimal)Lower limit.
max (decimal)Upper limit.

Ping

#
public static double Ping(double value, double min, double max)
Ping-pong a value between two limits.
value (double)Value to clip.
min (double)Lower limit.
max (double)Upper limit.

Ping

#
public static float Ping(float value, float min, float max)
Ping-pong a value between two limits.
value (float)Value to clip.
min (float)Lower limit.
max (float)Upper limit.

Ping

#
public static int Ping(int value, int min, int max)
Ping-pong a value between two limits.
value (int)Value to clip.
min (int)Inclusive lower limit.
max (int)Inclusive upper limit.

Ping

#
public static Point3d Ping(Point3d value, Point3d min, Point3d max)
Ping-pong a value between two limits.
value (Point3d)Value to clip.
min (Point3d)Lower limit.
max (Point3d)Upper limit.

Ping

#
public static Vector3d Ping(Vector3d value, Vector3d min, Vector3d max)
Ping-pong a value between two limits.
value (Vector3d)Value to clip.
min (Vector3d)Lower limit.
max (Vector3d)Upper limit.

PrimeFactors

#
public static (int Prime, int Power)[] PrimeFactors(int integer)
Decompose an integer into its prime factors, each combined with the power it is raised to. Factors are ordered from small to large, and the product of all factors always equals the absolute value of the input. The sign of the input is ignored, -12 and +12 both decompose into 2² and 3.
integer (int)Integer to decompose. Zero is not a valid input.
Prime factors and their multiplicities. Empty if the input is ±1.

QuadranceToDistance

#
public static double QuadranceToDistance(double quadrance)
Convert a quadrance into a distance.
quadrance (double)Quadrance measure.
Distance.

QuadranceToDistance

#
public static float QuadranceToDistance(float quadrance)
Convert a quadrance into a distance.
quadrance (float)Quadrance measure.
Distance.

Quartiles

#
public static void Quartiles(IEnumerable<double> data, out double min, out double lower, out double median, out double upper, out double max)
Compute the five key statistical points with respect to quantile distribution.
data (IEnumerable<double>)Data to measure.
min (out double)Lowest value in data.
lower (out double)Lower quantile.
median (out double)Median value in data.
upper (out double)Upper quantile.
max (out double)Highest value in data.

Round

#
public static Complex Round(Complex value, int digits)
Default Grasshopper rounding method.
value (Complex)Value to round.
digits (int)Number of digits, will be automatically limited to [0, 28].
Rounded value.

Round

#
public static decimal Round(decimal value, int digits)
Default Grasshopper rounding method.
value (decimal)Value to round.
digits (int)Number of digits, will be automatically limited to [0, 28].
Rounded value.

Round

#
public static double Round(double value, int digits)
Default Grasshopper rounding method.
value (double)Value to round.
digits (int)Number of digits, will be automatically limited to [0, 15].
Rounded value.

Round

#
public static float Round(float value, int digits)
Default Grasshopper rounding method.
value (float)Value to round.
digits (int)Number of digits, will be automatically limited to [0, 15].
Rounded value.

Round

#
public static Point3d Round(Point3d value, int digits)
Default Grasshopper rounding method.
value (Point3d)Value to round.
digits (int)Number of digits, will be automatically limited to [0, 28].
Rounded value.

Round

#
public static Vector3d Round(Vector3d value, int digits)
Default Grasshopper rounding method.
value (Vector3d)Value to round.
digits (int)Number of digits, will be automatically limited to [0, 28].
Rounded value.

RoundWithinError

#
public static double RoundWithinError(double number, double error)
Round a value to the nearest 'nice' value, without exceeding the error margin.
number (double)
error (double)

Sec

#
public static Complex Sec(Complex value)
Compute the secant of a complex value.
value (Complex)Complex value.
Secant of angle.

Sec

#
public static double Sec(double angle)
Compute the secant of an angle in radians.
angle (double)Angle in radians.
Secant of angle.

Sech

#
public static Complex Sech(Complex value)
Compute the hyperbolic secant of a complex value.
value (Complex)Complex value.
Hyperbolic secant of angle.

Sech

#
public static double Sech(double angle)
Compute the hyperbolic secant of an angle in radians.
angle (double)Angle in radians.
Hyperbolic secant of angle.

Sin

#
public static Complex Sin(Complex value)
Compute the sine of a complex value.
value (Complex)Complex value.
Sine of angle.

Sin

#
public static double Sin(double angle)
Compute the sine of an angle in radians.
angle (double)Angle in radians.
Sine of angle.

Sinc

#
public static Complex Sinc(Complex angle, bool normalised = false)
Compute the sinus-cardinalis of an angle in radians.
angle (Complex)Complex angle in radians.
normalised (bool = false)If true, the normalised Sinc is computed.

Sinc

#
public static double Sinc(double angle, bool normalised = false)
Compute the sinus-cardinalis of an angle in radians.
angle (double)Angle in radians.
normalised (bool = false)If true, the normalised Sinc is computed.

Sinh

#
public static Complex Sinh(Complex value)
Compute the hyperbolic sine of a complex value.
value (Complex)Complex value.
Hyperbolic sine of angle.

Sinh

#
public static double Sinh(double angle)
Compute the hyperbolic sine of an angle in radians.
angle (double)Angle in radians.
Hyperbolic sine of angle.

Skewness

#
public static double Skewness(IEnumerable<double> data)
Estimates the unbiased skewness of a population.
data (IEnumerable<double>)Population of values, must contain at least three numbers.
Estimated skewness.

Smooth

#
public static double[] Smooth(SmoothKind kind, int radius, bool inclusive, double[] data)
Smooth a set of values, ignoring everything beyond the ends of the sequence.
kind (Maths.SmoothKind)Smoothing algorithm.
radius (int)Smoothing radius.
inclusive (bool)If true, the value itself is taken into account.
data (double[])Data to smooth.
Smoothed data.

Smooth

#
public static double[] Smooth(SmoothKind kind, int radius, bool inclusive, SmoothEdge edge, double[] data)
Smooth a set of values.
kind (Maths.SmoothKind)Smoothing algorithm.
radius (int)Smoothing radius.
inclusive (bool)If true, the value itself is taken into account.
edge (Maths.SmoothEdge)Treatment of values beyond the ends of the sequence.
data (double[])Data to smooth.
Smoothed data.

SmootherStep

#
public static double SmootherStep(double x, double edge0, double edge1)
Performs standard smootherstep blending on a value. If the value is less than edge0, zero is returned. If the value exceeds edge1, one is returned. In between the value is blended using a fifth order hermite polynomial.
x (double)Value to smooth.
edge0 (double)Lower edge.
edge1 (double)Upper edge.
Smoothed value.

SmootherStep

#
public static double SmootherStep(double x)
Performs standard smootherstep blending on a value between zero and one.
x (double)Value to smooth.
Smoothed value.

SmootherStepDerivative

#
public static double SmootherStepDerivative(double x, double edge0, double edge1)
Differentiate standard smootherstep blending on a value.
x (double)Value to smooth.
edge0 (double)Lower edge.
edge1 (double)Upper edge.
Smoothed value.

SmootherStepDerivative

#
public static double SmootherStepDerivative(double x)
Differentiate standard smootherstep blending on a value between zero and one.
x (double)Value to smooth.
Smoothed value.

SmoothestStep

#
public static double SmoothestStep(double x, double edge0, double edge1)
Performs standard smootheststep blending on a value. If the value is less than edge0, zero is returned. If the value exceeds edge1, one is returned. In between the value is blended using a seventh order hermite polynomial.
x (double)Value to smooth.
edge0 (double)Lower edge.
edge1 (double)Upper edge.
Smoothed value.

SmoothestStep

#
public static double SmoothestStep(double x)
Performs standard smootheststep blending on a value between zero and one.
x (double)Value to smooth.
Smoothed value.

SmoothestStepDerivative

#
public static double SmoothestStepDerivative(double x, double edge0, double edge1)
Differentiate standard smootheststep blending on a value.
x (double)Value to smooth.
edge0 (double)Lower edge.
edge1 (double)Upper edge.
Smoothed value.

SmoothestStepDerivative

#
public static double SmoothestStepDerivative(double x)
Differentiate standard smootheststep blending on a value between zero and one.
x (double)Value to smooth.
Smoothed value.

SmoothMax

#
public static double SmoothMax(double a, double b, SmoothLimit function = SmoothLimit.Polynomial, double k = 1)
Compute the smooth maximum of two numbers. When applied to continuous crossing functions, the smooth maximum yields a result identical to Max(a, b), except when a and b are nearly equal. Near crossing points this deviation from Max(a,b) becomes so large as to smooth out the kinks that would occur in the regular Max() function.
a (double)First value.
b (double)Second value.
function (Maths.SmoothLimit = SmoothLimit.Polynomial)Smoothing function to use.
k (double = 1)Width of the blend zone (in the same units as a and b).
The smooth maximum of a and b.

SmoothMin

#
public static double SmoothMin(double a, double b, SmoothLimit function = SmoothLimit.Polynomial, double k = 1)
Compute the smooth minimum of two numbers. When applied to continuous crossing functions, the smooth minimum yields a result identical to Min(a, b), except when a and b are nearly equal. Near crossing points this deviation from Min(a,b) becomes so large as to smooth out the kinks that would occur in the regular Min() function.
a (double)First value.
b (double)Second value.
function (Maths.SmoothLimit = SmoothLimit.Polynomial)Smoothing function to use.
k (double = 1)Blending argument. The 'k' parameter has a different meaning depending on the smoothing function.
The smooth minimum of a and b.

SmoothStep

#
public static double SmoothStep(double x, double edge0, double edge1)
Performs standard smoothstep blending on a value. If the value is less than edge0, zero is returned. If the value exceeds edge1, one is returned. In between the value is blended using a hermite polynomial.
x (double)Value to smooth.
edge0 (double)Lower edge.
edge1 (double)Upper edge.
Smoothed value.

SmoothStep

#
public static double SmoothStep(double x)
Performs standard smoothstep blending on a value between zero and one.
x (double)Value to smooth.
Smoothed value.

SmoothStepDerivative

#
public static double SmoothStepDerivative(double x, double edge0, double edge1)
Differentiate standard smoothstep blending on a value.
x (double)Value to smooth.
edge0 (double)Lower edge.
edge1 (double)Upper edge.
Smoothed value.

SmoothStepDerivative

#
public static double SmoothStepDerivative(double x)
Differentiate standard smoothstep blending on a value between zero and one.
x (double)Value to smooth.
Smoothed value.

SmoothStepInverse

#
public static double SmoothStepInverse(double x)
Inverse of the cubic smoothstep function.
x (double)Value to (un)smooth.
(Un)smoothed value.

Sort

#
public static bool Sort(ref decimal a, ref decimal b, ref decimal c)
Sort three values in place.
a (ref decimal)First value.
b (ref decimal)Second value.
c (ref decimal)Third value.
True if a swap was made.

Sort

#
public static bool Sort(ref decimal a, ref decimal b)
Sort two values in place.
a (ref decimal)First value.
b (ref decimal)Second value.
True if a swap was made.

Sort

#
public static bool Sort(ref double a, ref double b, ref double c)
Sort three values in place.
a (ref double)First value.
b (ref double)Second value.
c (ref double)Third value.
True if a swap was made.

Sort

#
public static bool Sort(ref double a, ref double b)
Sort two values in place.
a (ref double)First value.
b (ref double)Second value.
True if a swap was made.

Sort

#
public static bool Sort(ref float a, ref float b, ref float c)
Sort three values in place.
a (ref float)First value.
b (ref float)Second value.
c (ref float)Third value.
True if a swap was made.

Sort

#
public static bool Sort(ref float a, ref float b)
Sort two values in place.
a (ref float)First value.
b (ref float)Second value.
True if a swap was made.

Sort

#
public static bool Sort(ref int a, ref int b, ref int c)
Sort three values in place.
a (ref int)First value.
b (ref int)Second value.
c (ref int)Third value.
True if a swap was made.

Sort

#
public static bool Sort(ref int a, ref int b)
Sort two values in place.
a (ref int)First value.
b (ref int)Second value.
True if a swap was made.

SortAngular

#
public static Maths.IndexMap SortAngular(Point2d[] points, double zeroAngle, Point2d origin)
Sort an array of points counter-clockwise.
points (Point2d[])Points to sort.
zeroAngle (double)Zero angle.
origin (Point2d)Sort origin.
Sorted indices.

SortAngular

#
public static Maths.IndexMap SortAngular(Point2d[] points, double zeroAngle)
Sort an array of points counter-clockwise.
points (Point2d[])Points to sort.
zeroAngle (double)Zero angle.
Sorted indices.

SortAngular

#
public static Maths.IndexMap SortAngular(Point2d[] points)
Sort an array of points counter-clockwise.
points (Point2d[])Points to sort.
Sorted indices.

SortTopological

#
public static Maths.IndexMap SortTopological(int[][] dependencies)
Perform a topological sorting on an array of dependendies.
dependencies (int[][])An array of indexed dependencies. Empty or null array are allowed, indicating the element has no dependencies.
An index map which can be used to synchronously sort.

SplitMeshByPlane

#
public static (Mesh Above, Mesh Below, Polyline[] Sections) SplitMeshByPlane(Mesh inputMesh, Plane plane, double tolerance, CancellationToken ct)
Split a mesh by an arbitrary plane. Returns the parts above and the parts below the plane as two separate meshes (each potentially comprising several disjoint pieces; call SplitDisjointPieces to enumerate them), plus the cut polylines on the plane itself. Unlike Mesh.Split(Plane) in RhinoCommon this overload accepts a cancellation token and bails out cleanly on a long-running split. Quad faces that lie entirely above or entirely below the plane are preserved as quads in the output. Only quads that the plane actually crosses are triangulated (along the A-C diagonal) and split per triangle. The input mesh is never mutated. Vertices within tolerance of the plane are treated as lying on the plane (rather than strictly above or below). A face with an on-plane vertex and no strict-opposite-side vertex is assigned in full to whichever side it touches; this gives clean splits on meshes whose vertices land exactly on the plane (the default sphere mesh, for example, has a row of vertices at the equator). See also MySplitMeshAtWaterLevels(Mesh, double[], (double waterLevel, HashSet<int> wetFaces)[], CancellationToken, bool), which solves a related but more specialised problem (multiple horizontal-plane cuts with per-vertex water levels and terrain-flavoured output bookkeeping). The two share the same per-triangle split arithmetic; they are not yet refactored onto a common core because the terrain method is sensitive to small numerical changes in its output.
inputMesh (Mesh)
plane (Plane)
tolerance (double)
ct (CancellationToken)

Sqrt

#
public static Complex Sqrt(Complex x)
Square root.
x (Complex)

Sqrt

#
public static double Sqrt(BigInteger x)
Square root.
x (BigInteger)

Sqrt

#
public static double Sqrt(double x)
Square root.
x (double)

Sqrt

#
public static double Sqrt(int x)
Square root.
x (int)

Statistics

#
public static void Statistics(double[] numbers, out double mean, out double deviation)
Compute a set of common statistics for a collection of numbers.
numbers (double[])Numbers to investigate.
mean (out double)Mean (or average) of numbers.
deviation (out double)Standard deviation of numbers.

Statistics

#
public static void Statistics(double[] numbers, out double mean, out double mode, out double median, out double deviation)
Compute a set of common statistics for a collection of numbers.
numbers (double[])Numbers to investigate.
mean (out double)Mean (or average) of numbers.
mode (out double)Mode of numbers. Note that this is particularly sensitive to floating point noise. Round your values first if you really care.
median (out double)Median of numbers.
deviation (out double)Standard deviation of numbers.

Sum<T>

#
public static double Sum<T>(IEnumerable<T> collection, Func<T, double> method)
Sum up all elements in a collection.
collection (IEnumerable<T>)Collection of elements.
method (Func<T, double>)Element to double conversion.
Sum total.

Sum<T>

#
public static float Sum<T>(IEnumerable<T> collection, Func<T, float> method)
Sum up all elements in a collection.
collection (IEnumerable<T>)Collection of elements.
method (Func<T, float>)Element to float conversion.
Sum total.

Sum<T>

#
public static int Sum<T>(IEnumerable<T> collection, Func<T, int> method)
Sum up all elements in a collection.
collection (IEnumerable<T>)Collection of elements.
method (Func<T, int>)Element to integer conversion.
Sum total.

Swap<T>

#
public static void Swap<T>(ref T a, ref T b, ref T c)
Swap three values in place. B becomes A, C becomes B, and A becomes C.
a (ref T)First value.
b (ref T)Second value.
c (ref T)Third value.

Swap<T>

#
public static void Swap<T>(ref T a, ref T b)
Swap two values in place.
a (ref T)First value.
b (ref T)Second value.

Tan

#
public static Complex Tan(Complex value)
Compute the tangent of a complex value.
value (Complex)Complex value.
Tangent of angle.

Tan

#
public static double Tan(double angle)
Compute the tangent of an angle in radians.
angle (double)Angle in radians.
Tangent of angle.

Tanh

#
public static Complex Tanh(Complex value)
Compute the hyperbolic tangent of a complex value.
value (Complex)Complex value.
Hyperbolic tangent of angle.

Tanh

#
public static double Tanh(double angle)
Compute the hyperbolic tangent of an angle in radians.
angle (double)Angle in radians.
Hyperbolic tangent of angle.

ToNextPowerOfTen

#
public static int ToNextPowerOfTen(int integer)
Convert an integer to the next power of ten. If the integer is already a power of ten, the same number will be returned.
integer (int)Integer to convert.
Power of ten.

ToNextPowerOfTwo

#
public static int ToNextPowerOfTwo(int integer)
Convert an integer to the next power of two. If the integer is already a power of two, the same number will be returned.
integer (int)Integer to convert.
Power of two.

Truncate

#
public static Complex Truncate(Complex value)
Default Grasshopper truncate method.
value (Complex)Value to round.
Rounded value.

Truncate

#
public static decimal Truncate(decimal value)
Default Grasshopper truncate method.
value (decimal)Value to round.
Rounded value.

Truncate

#
public static double Truncate(double value)
Default Grasshopper truncate method.
value (double)Value to round.
Rounded value.

Truncate

#
public static float Truncate(float value)
Default Grasshopper truncate method.
value (float)Value to round.
Rounded value.

Truncate

#
public static Point3d Truncate(Point3d value)
Default Grasshopper truncate method.
value (Point3d)Value to round.
Rounded value.

Truncate

#
public static Vector3d Truncate(Vector3d value)
Default Grasshopper truncate method.
value (Vector3d)Value to round.
Rounded value.

VertexAverage

#
public static Point2d VertexAverage(Point2d[] points)
Compute the average of a set of points.
points (Point2d[])

VertexAverage

#
public static Point3d VertexAverage(Point3d[] points)
Compute the average of a set of points.
points (Point3d[])

Wrap

#
public static BigInteger Wrap(BigInteger value, BigInteger min, BigInteger max)
Wrap a value between two limits.
value (BigInteger)Value to clip.
min (BigInteger)Inclusive lower limit.
max (BigInteger)Exclusive upper limit.

Wrap

#
public static Complex Wrap(Complex value, Complex min, Complex max)
Wrap a value between two limits.
value (Complex)Value to clip.
min (Complex)Lower limit.
max (Complex)Upper limit.

Wrap

#
public static decimal Wrap(decimal value, decimal min, decimal max)
Wrap a value between two limits.
value (decimal)Value to clip.
min (decimal)Lower limit.
max (decimal)Upper limit.

Wrap

#
public static double Wrap(double value, double min, double max)
Wrap a value between two limits.
value (double)Value to clip.
min (double)Lower limit.
max (double)Upper limit.

Wrap

#
public static float Wrap(float value, float min, float max)
Wrap a value between two limits.
value (float)Value to clip.
min (float)Lower limit.
max (float)Upper limit.

Wrap

#
public static int Wrap(int value, int min, int max)
Wrap a value between two limits.
value (int)Value to clip.
min (int)Inclusive lower limit.
max (int)Exclusive upper limit.

Wrap

#
public static Point3d Wrap(Point3d value, Point3d min, Point3d max)
Wrap a value between two limits.
value (Point3d)Value to clip.
min (Point3d)Lower limit.
max (Point3d)Upper limit.

Wrap

#
public static Vector3d Wrap(Vector3d value, Vector3d min, Vector3d max)
Wrap a value between two limits.
value (Vector3d)Value to clip.
min (Vector3d)Lower limit.
max (Vector3d)Upper limit.