RhinoMath
Provides constants and static methods that are additional to Math.
Fields
DefaultAngleTolerance
#Represents the default angle tolerance, used when no other values are provided.
This is one degree, expressed in radians.
Remarks: This is equivalent to openNURBS ON_DEFAULT_ANGLE_TOLERANCE.
DefaultDistanceToleranceMillimeters
#Get Rhino's default distance tolerance in millimeters.
Remarks: This is equivalent to openNURBS ON_DEFAULT_DISTANCE_TOLERANCE_MM.
Epsilon
#Gets the value of DBL_EPSILON, which is the smallest positive floating point number x such that 1 + x != 1. This is different than Double.Epsilon which is the smallest positive Double value that is greater than zero.
Remarks: This is equivalent to openNURBS ON_EPSILON.
Value used to indicate a radius of curvature is infinite.
QuarterPI
#One eigth of a rotation. 45 degrees. 0.78...
SqrtEpsilon
#Represents a default value that is used when comparing square roots.
This value is several orders of magnitude larger than ZeroTolerance.
Remarks: This is equivalent to openNURBS ON_SQRT_EPSILON.
Tau
#Ratio of circumference divided by radius. Full rotation. 360 degrees. 6.28...
UnsetIntIndex
#When signed int values are used in a context where 0 and small negative values are valid indices and there needs to be a value that indicates the index is not set.
Remarks: This is equivalent to openNURBS ON_UNSET_INT_INDEX.
UnsetSingle
#Gets the single precision floating point number that is considered 'unset' in Rhino.
Remarks: This is equivalent to openNURBS ON_UNSET_FLOAT.
UnsetValue
#Gets the Rhino standard Unset value. Use this value rather than Double.NaN when a bogus floating point value is required.
Remarks: This is equivalent to openNURBS ON_UNSET_VALUE.
ZeroTolerance
#Gets Rhino's Zero Tolerance constant, which is 2^-32. In cases when an absolute "zero" tolerance is required to compare model space coordinates, ZeroTolerance is used. The value of ZeroTolerance should be no smaller than Epsilon and should be several orders of magnitude smaller than SqrtEpsilon.
Remarks: This is equivalent to openNURBS ON_ZERO_TOLERANCE.
Methods
Limits a double to be specified within an interval of two numbers, by specifying a fixed minimum and maximum.
Restricts a int to be specified within an interval of two integers.
Advances the cyclic redundancy check value remainder given a byte array. http://en.wikipedia.org/wiki/Cyclic_redundancy_check.
Advances the cyclic redundancy check value remainder given a double. http://en.wikipedia.org/wiki/Cyclic_redundancy_check.
Advances the cyclic redundancy check value remainder given a int. http://en.wikipedia.org/wiki/Cyclic_redundancy_check.
Compare two doubles for equality within some "epsilon" range
Compare to floats for equality within some "epsilon" range
public static bool EvaluateNormal(int limitDirection, Vector3d ds, Vector3d dt, Vector3d dss, Vector3d dst, Vector3d dtt, out Vector3d n)
Expert tool to evaluate surface unit normal.
Parameters:
| limitDirection (int) | Determines which direction is used to compute the limit, where: 0 = default, 1 = from quadrant I, 2 = from quadrant II, etc. |
| ds (Vector3d) | First partial derivative. |
| dt (Vector3d) | First partial derivative. |
| dss (Vector3d) | Second partial derivative. |
| dst (Vector3d) | Second partial derivative. |
| dtt (Vector3d) | Second partial derivative. |
| n (out Vector3d) | Unit normal. |
Returns: True if successful, false otherwise.
public static bool EvaluateNormalPartials(Vector3d ds, Vector3d dt, Vector3d dss, Vector3d dst, Vector3d dtt, out Vector3d ns, out Vector3d nt)
Expert tool to evaluate partial derivatives of surface unit normal.
Parameters:
| ds (Vector3d) | First partial derivative. |
| dt (Vector3d) | First partial derivative. |
| dss (Vector3d) | Second partial derivative. |
| dst (Vector3d) | Second partial derivative. |
| dtt (Vector3d) | Second partial derivative. |
| ns (out Vector3d) | First partial derivative of unit normal. If the Jacobian is degenerate, ns is set to zero. |
| nt (out Vector3d) | First partial derivative of unit normal. If the Jacobian is degenerate, nt is set to zero. |
Returns: true if Jacobian is non-degenerate, false if Jacobian is degenerate.
public static bool EvaluateSectionalCurvature(Vector3d ds, Vector3d dt, Vector3d dss, Vector3d dst, Vector3d dtt, Vector3d planeNormal, out Vector3d k)
Expert tool to evaluate sectional curvature from surface derivatives and section plane normal.
Parameters:
| ds (Vector3d) | First partial derivative. |
| dt (Vector3d) | First partial derivative. |
| dss (Vector3d) | Second partial derivative. |
| dst (Vector3d) | Second partial derivative. |
| dtt (Vector3d) | Second partial derivative. |
| planeNormal (Vector3d) | Unit normal to section plane. |
| k (out Vector3d) | Sectional curvature. Curvature of the intersection curve of the surface and plane through the surface point where the partial derivatives were evaluated. |
Returns: True if successful. False if first partials are not linearly independent, in which case the k is set to zero.
public static double Integrate(Func<object, int, double, double, double> integrandFunction, object context, Interval limits1, Interval limits2, double relativeTolerance, double absoluteTolerance, CancellationToken cancellationToken, out double errorBound)
Parameters:
| integrandFunction (Func<object, int, double, double, double>) | |
| context (object) | |
| limits1 (Interval) | |
| limits2 (Interval) | |
| relativeTolerance (double) | |
| absoluteTolerance (double) | |
| cancellationToken (CancellationToken) | Token used to cancel the calculation. Cancellation is cooperative: it is checked each time the integrand is evaluated, and a canceled calculation returns double.NaN. |
| errorBound (out double) |
Integrate
#public static double Integrate(Func<object, int, double, double, double> integrandFunction, object context, Surface surface, double relativeTolerance, double absoluteTolerance, CancellationToken cancellationToken, out double errorBound)
Parameters:
| integrandFunction (Func<object, int, double, double, double>) | |
| context (object) | |
| surface (Surface) | |
| relativeTolerance (double) | |
| absoluteTolerance (double) | |
| cancellationToken (CancellationToken) | Token used to cancel the calculation. Cancellation is cooperative: it is checked each time the integrand is evaluated, and a canceled calculation returns double.NaN. |
| errorBound (out double) |
Integrate
#public static double Integrate(Func<object, int, double, double> integrandFunction, object context, Curve curve, double relativeTolerance, double absoluteTolerance, CancellationToken cancellationToken, out double errorBound)
Calculates the definite integral of a smooth (C-infinity) function of one variable using a Rhomberg integration technique and returns returns Integral(f(t)*|curve'(t)|*dt). The C-infinity requirement is used by the Rhomberg algorithm when estimating error bounds and convergence. If you choose to pass a C2 function, you are likely to converge while getting less accurate results and incorrect error bound estimates. Using a C0 or C1 fucntion will often return nonsense. The calculation can be canceled through the cancellation token.
Parameters:
| integrandFunction (Func<object, int, double, double>) | The integrand function is double f(ON__UINT_PTR context, int limit_direction, double t) and returns the value of the integrand at t. The limit_direction parameter will be -1, 0, or +1 and specifies which limit direction should be used in the evaluation. If limit_direction = 1, then the integrand may not be C-infinity at t and should be evaluated using the limit from above. If limit_direction = -1, then the integrand may not be C-infinity at t and should be evaluated using the limit from below. If limit_direction = 0, then the integrand is C-infinity at t and may and evaluation from above and below will return the same answer. |
| context (object) | First parameter passed into the integrand function. |
| curve (Curve) | The integration is performed over the C-infinity spans of the curve and |curve'(t)| is automatically included in the integrand. The integrand must be C-infinity on the intesection each curve span with the interval (limits[0],limits[1]). The curve may have any dimension. |
| relativeTolerance (double) | Desired relative tolerance. If I = mathematical value and N = numerical integration value, then the algorithm will terminate when |I - N| <= relative_tolerance*|I|. For example, if you want to know the answer with 5 digits of accuracy, then pass 1e-5. |
| absoluteTolerance (double) | Desired absolute tolerance. If I = mathematical value and N = numerical integration value, then the algorithm will terminate when |I - N| <= absolute_tolerance. |
| cancellationToken (CancellationToken) | Token used to cancel the calculation. Cancellation is cooperative: it is checked each time the integrand is evaluated, and a canceled calculation returns double.NaN. |
| errorBound (out double) | If error_bound is not nullptr, then the returned value is upper bound on the error in the calculation. If I = mathematical value and N = returned value, then |I - N| <= *error_bound; |
Returns: If the calulation succeeds, then the numerical integral is returned. Otherwise ON_DBL_QNAN is returned.
Integrate
#public static double Integrate(Func<object, int, double, double> integrandFunction, object context, Curve curve, double relativeTolerance, double absoluteTolerance, out double errorBound)
Calculates the definite integral of a smooth (C-infinity) function of one variable using a Rhomberg integration technique and returns returns Integral(f(t)*|curve'(t)|*dt). The C-infinity requirement is used by the Rhomberg algorithm when estimating error bounds and convergence. If you choose to pass a C2 function, you are likely to converge while getting less accurate results and incorrect error bound estimates. Using a C0 or C1 fucntion will often return nonsense.
Parameters:
| integrandFunction (Func<object, int, double, double>) | The integrand function is double f(ON__UINT_PTR context, int limit_direction, double t) and returns the value of the integrand at t. The limit_direction parameter will be -1, 0, or +1 and specifies which limit direction should be used in the evaluation. If limit_direction = 1, then the integrand may not be C-infinity at t and should be evaluated using the limit from above. If limit_direction = -1, then the integrand may not be C-infinity at t and should be evaluated using the limit from below. If limit_direction = 0, then the integrand is C-infinity at t and may and evaluation from above and below will return the same answer. |
| context (object) | First parameter passed into the integrand function. |
| curve (Curve) | The integration is performed over the C-infinity spans of the curve and |curve'(t)| is automatically included in the integrand. The integrand must be C-infinity on the intesection each curve span with the interval (limits[0],limits[1]). The curve may have any dimension. |
| relativeTolerance (double) | Desired relative tolerance. If I = mathematical value and N = numerical integration value, then the algorithm will terminate when |I - N| <= relative_tolerance*|I|. For example, if you want to know the answer with 5 digits of accuracy, then pass 1e-5. |
| absoluteTolerance (double) | Desired absolute tolerance. If I = mathematical value and N = numerical integration value, then the algorithm will terminate when |I - N| <= absolute_tolerance. |
| errorBound (out double) | If error_bound is not nullptr, then the returned value is upper bound on the error in the calculation. If I = mathematical value and N = returned value, then |I - N| <= *error_bound; |
Returns: If the calulation succeeds, then the numerical integral is returned. Otherwise ON_DBL_QNAN is returned.
public static double Integrate(Func<object, int, double, double> integrandFunction, object context, Interval limits, double relativeTolerance, double absoluteTolerance, CancellationToken cancellationToken, out double errorBound)
Calculates the definite integral of a smooth (C-infinity) function using a Rhomberg integration technique. The calculation can be canceled through the cancellation token.
Parameters:
| integrandFunction (Func<object, int, double, double>) | The integrand function is double f(object context, int limit_direction, double t) and returns the value of the integrand at t. The limit_direction parameter will be -1, 0, or +1 and specifies which limit direction should be used in the evaluation. If limit_direction = 1, then the integrand may not be C-infinity at t and should be evaluated using the limit from above. If limit_direction = -1, then the integrand may not be C-infinity at t and should be evaluated using the limit from below. If limit_direction = 0, then the integrand is C-infinity at t and may and evaluation from above and below will return the same answer. |
| context (object) | Anything you want to be passed to and used by the integrandFunction |
| limits (Interval) | Limits of integration. The integrand must be C-infinity on each interval (limits[0],limits[1]). |
| relativeTolerance (double) | Desired relative tolerance. If I = mathematical value and N = numerical integration value, then the algorithm will terminate when |I - N| <= relative_tolerance*|I|. For example, if you want to know the answer with 5 digits of accuracy, then pass 1e-5. |
| absoluteTolerance (double) | Desired absolute tolerance. If I = mathematical value and N = numerical integration value, then the algorithm will terminate when |I - N| <= absolute_tolerance. |
| cancellationToken (CancellationToken) | Token used to cancel the calculation. Cancellation is cooperative: it is checked each time the integrand is evaluated, and a canceled calculation returns double.NaN. |
| errorBound (out double) | upper bound on the error in the calculation |
Returns: If the calulation succeeds, then the numerical integral is returned. Otherwise double.NaN is returned.
Integrate
#public static double Integrate(Func<object, int, double, double> integrandFunction, object context, Interval limits, double relativeTolerance, double absoluteTolerance, out double errorBound)
Calculates the definite integral of a smooth (C-infinity) function using a Rhomberg integration technique.
Parameters:
| integrandFunction (Func<object, int, double, double>) | The integrand function is double f(object context, int limit_direction, double t) and returns the value of the integrand at t. The limit_direction parameter will be -1, 0, or +1 and specifies which limit direction should be used in the evaluation. If limit_direction = 1, then the integrand may not be C-infinity at t and should be evaluated using the limit from above. If limit_direction = -1, then the integrand may not be C-infinity at t and should be evaluated using the limit from below. If limit_direction = 0, then the integrand is C-infinity at t and may and evaluation from above and below will return the same answer. |
| context (object) | Anything you want to be passed to and used by the integrandFunction |
| limits (Interval) | Limits of integration. The integrand must be C-infinity on each interval (limits[0],limits[1]). |
| relativeTolerance (double) | Desired relative tolerance. If I = mathematical value and N = numerical integration value, then the algorithm will terminate when |I - N| <= relative_tolerance*|I|. For example, if you want to know the answer with 5 digits of accuracy, then pass 1e-5. |
| absoluteTolerance (double) | Desired absolute tolerance. If I = mathematical value and N = numerical integration value, then the algorithm will terminate when |I - N| <= absolute_tolerance. |
| errorBound (out double) | upper bound on the error in the calculation |
Returns: If the calulation succeeds, then the numerical integral is returned. Otherwise double.NaN is returned.
Portrays an int index in text.
Determines whether a double value is valid within the RhinoCommon context.
Rhino does not use Double.NaN by convention, so this test evaluates to true if:
x is not equal to RhinoMath.UnsetValue
System.Double.IsNaN(x) evaluates to false
System.Double.IsInfinity(x) evaluates to false
Determines whether a float value is valid within the RhinoCommon context.
Rhino does not use Single.NaN by convention, so this test evaluates to true if:
x is not equal to RhinoMath.UnsetValue,
System.Single.IsNaN(x) evaluates to false
System.Single.IsInfinity(x) evaluates to false
Return number of meters per one unit of a given unit system
Parameters:
| units (UnitSystem) |
Evaluates command line math expression.
Parameters:
| expression (string) |
Returns: result
Exceptions:
| ArgumentNullException | expression is null. |
| FormatException | expression cannot be parsed. |
Convert an angle from radians to degrees.
Parameters:
| radians (double) | Radians to convert (180 degrees equals pi radians). |
Convert an angle from degrees to radians.
Parameters:
| degrees (double) | Degrees to convert (180 degrees equals pi radians). |
Evaluates command line math expression.
public static double UnitScale(UnitSystem from, double fromMetersPerUnit, UnitSystem to, double toMetersPerUnit)
Computes the scale factor for changing the measurements unit systems.
Parameters:
| from (UnitSystem) | The system to convert from. |
| fromMetersPerUnit (double) | For custom units, specify the meters per unit. |
| to (UnitSystem) | The system to convert measurements into. |
| toMetersPerUnit (double) | For custom units, specify the meters per unit. |
Returns: A scale multiplier.
Computes the scale factor for changing the measurements unit systems.
Parameters:
| from (UnitSystem) | The system to convert from. |
| to (UnitSystem) | The system to convert measurements into. |
Returns: A scale multiplier.
Limits a double to be specified within an interval of two numbers by repeating the available interval cyclically.