Calc Class

A collection of useful numerical functions and constants.
Public Class Calc
This language is not supported or no code example is available.
public static class Calc
This language is not supported or no code example is available.
public ref class Calc 
This language is not supported or no code example is available.
public class Calc
This language is not supported or no code example is available.
Methods
 
Name Description
Public method Static AccelTime(double, double, double, bool) Calculates the time to go from 0 to v with accelration acc then v to 0 using acc if tozero=true.
Public method Static AlignBox(List<Point2d>) Calculates the align angle of a set of points using the minimum bounding box metric
Public method Static AlignBox(Poly2d)
Public method Static AlignHeight(List<Point2d>, double)
Public method Static AlignHull(List<Point2d>) Calculates the align angle of a set of points using the longest edge of the convex hull as metric
Public method Static AlignHull(Poly2d)
Public method Static AlignMER(List<Point2d>)
Public method Static AlignMER(Poly2d) Rotate with -angle to align
Public method Static AlignMER(Region2d) Rotate with -angle to align
Public method Static AlignedBox(List<Point2d>) Calculates the minimum bounding rectangle of a set of points
Public method Static AlmostZero(double)
Public method Static AngleEquals(double, double, double) Checks if two angles are equal with a small tolerance.
Public method Static AngularDifferance(double, double, Direction) Returns the included angle between two given angles and a direction.
Public method Static Biarc(Point2d, Vector2d, Point2d, Vector2d, out Arc2d, out Arc2d) Calculates a biarc from pt1 to pt2.
Public method Static Biarc(Point3d, Vector3d, Point3d, Vector3d, out Arc3d, out Arc3d)
Public method Static Bias(double, double)
Public method Static BiasOriginal(double, double)
Public method Static BinomCoefficient(long, long) Calculates the binomial coefficient (nCk) (N items, choose k)
Public method Static Bisect(Point2d, Point2d, Point2d) Computes the bisector. In this case, computes the point between two 'leg' points that will split them with equal angles with respect to a tip.
Public method Static Bisection(List<Double>, double, double, double, int, out double) Helper for solvePoly
Public method Static BosseSeg(Arc3d, int, double)
Public method Static Brent(double, double, Func<DoubleDouble>, out double, double, double) Computes a Brent-style root bracketing. Returns true on success, or false on failure. Failure can only happen if the function value at xmin and xmax has the same sign, and the function values at xmin/xmax is not within zero tolerance.
Public method Static CalcFit(Extents2d, int, Extents2d)
Public method Static Clamp(double, double, double) Clamps a value between vmin and vmax.
Public method Static Clamp(int, int, int) Clamps a value between vmin and vmax.
Public method Static ClipLine(ref double, ref double, ref double, ref double, double, double, double, double)
Public method Static CreateSpiral(double, double, double, double, int)
Public method Static CubeRoot(double)
Public method Static CubicRoot(double) Computes the cubic root (third root) of a number.
Public method Static DifferentialAngle(double, double)
Public method Static Equals(double, double) Checks if two numbers are closer to each other than Epsilon.
Public method Static Equals(double, double, double) Tests if two real numbers are equal within a given tolerance.
Public method Static Erf(double) erf(x) is the "error function" encountered in integrating the normal distribution (which is a normalized form of the Gaussian function).
Public method Static EvalPoly(List<Double>, double) Evaluates a polynom.
Public method Static FindMax(NumericFunctionDelegate, object, double, int, double, double, out double)
Public method Static FindMin(NumericFunctionDelegate, object, double, int, double, double, out double) Numerically finds the minimum of a function.
Public method Static FindZerosOfFunction(NumericFunctionDelegate, double[], object, long, double, double, double, double) Numerically searches for zeroes of a given functions.
Public method Static Flatten(double, double, double, FlattenEvalCallback)
Public method Static Gain(double, double)
Public method Static GainOriginal(double, double)
Public method Static GaussSolve(double[,]) Solve a system of n equations in n unknowns using Gaussian Elimination Solve an equation in matrix form Ax = b The 2D array a is the matrix A with an additional column b. This is often written (A:b) A0,0 A1,0 A2,0 .... An-1,0 b0 A0,1 A1,1 A2,1 .... An-1,1 b1 A0,2 A1,2 A2,2 .... An-1,2 b2 : : : : : : : : : : A0,n-1 A1,n-1 A2,n-1 .... An-1,n-1 bn-1 Returns an array of solutions, or null if if the system of equations is singular. Sample for solving center for a circle through three points: double[] sm=new double[2,3]; //two rows, three coefficients sm[0, 0] = 2 * p0.y - 2 * p1.y; sm[0, 1] = 2 * p0.x - 2 * p1.x; sm[0, 2] = -(p1.x * p1.x + p1.y * p1.y - p0.x * p0.x - p0.y * p0.y); sm[1, 0] = 2 * p0.y - 2 * p2.y; sm[1, 1] = 2 * p0.x - 2 * p2.x; sm[1, 2] = -(p2.x * p2.x + p2.y * p2.y - p0.x * p0.x - p0.y * p0.y); double[] center=Calc.GaussSolve(sm);
Public method Static GetBarycentricWeights(Point2d, Point2d, Point2d, Point2d, out double, out double, out double) Computes the barycentric weights of a point to the triangle A-B-C and put it in the weights u-v-w. If the triangle is degenerate, this function returns false and u,v,w is set to 1/3 (centroid). otherwise true is returned.
Public method Static GetCentralPoint(Region2d, out double) Calculates a point inside the region with the furthest distance to any contour.
Public method Static GetConicType(double, double, double, double, double, double) Calculates to type of conic from the equation Ax^2+Bxy+Cy^2+Dx+Ey+F=0.
Public method Static GetDerivative(List<Double>) Gets the derivative of a polynom ex ax^5+bx^4+cx^3+dx^2+ex+f
Public method Static GetStandoffDist(double, double, double, double)
Public method Static GetX(Point2d, Point2d, double) Calculates the X-coordinate of a line defined by a,b at y.
Public method Static GetY(Point2d, Point2d, double) Calculates the Y-coordinate of a line defined by a,b at x.
Public method Static GreaterEqual(double, double, double)
Public method Static Hypot(double, double) Computes the length of the hypotenuse of a right triangle given the length of the catheti.
Public method Static InsertionSort<T>(IList<T>, Comparison<T>)
Public method Static IntegrateSimpson(IntegrationFunction, double, double, int, double) Returns the integral of the function func from a to b. Integration is performed by Simpson’s rule.
Public method Static Interpolate(double, double, double)
Public method Static InterpolateAngle(double, double, double) Interpolates shortest way between v0 and v1 par:0-1
Public method Static IsAngleBetween(double, double, double, Direction) Checks if an angle lies between two other angles, in the given direction.
Public method Static IsEven(int) Checks if an integer is even.
Public method Static IsFinite(double)
Public method Static IsNotFinite(double)
Public method Static IsZero(double, double) Checks if a number is closer to zero than Epsilon.
Public method Static LeastSquareFit(List<Point2d>)
Public method Static LessEqual(double, double, double)
Public method Static LowerBound<T>(List<T>, T) Returns the lower bound of lst seaching for a. lst must be sorted.
Public method Static Map(double, double, double, double, double) Maps 'value' in range inMin-inMax to the range outMin-outMax.
Public method Static Max(params double[]) Returns the maximum number of an arbitrary number of doubles.
Public method Static Min(params double[]) Returns the minimum number of an arbitrary number of doubles.
Public method Static Mod(int, int) Special modulus that works with negative numbers in a way that's suitable for circular arrays. For example Mod(-1,10) will return 9.
Public method Static MultiNewton(MultiFunction, double[], double)
Public method Static NormalizeAngle(double) Computes the normalized angle (between 0 and 2*PI) of a given angle. Both positive and negative angles handled correctly.
Public method Static NormalizeAngleSide(double) Normalizes an angle betwee -PI and PI
Public method Static PointsOnSphere(Point3d, double, int)
Public method Static PointsVector(Point3d, Vector3d, int, Random)
Public method Static ProjectedSignedAngle(Vector3d, Vector3d, Vector3d)
Public method Static Rand(Random, double) Non uniform random variable R[x] = sqrt(x)^fac
Public method Static RandomPoly(int, int, Extents2d)
Public method Static RandomShuffle<T>(List<T>, Random) Random shuffle of a list
Public method Static RemapParam(double, double, double) Remaps a parameter (0-1) to a new range min-max
Public method Static RotatingCalipers(List<Point2d>)
Public method Static Round(double)
Public method Static SolveCubic(double, double, double, double, List<Double>) Solves the cubic equation c3*x^3 + c2*x^2 + c1 * x+ c0 = 0 for x.
Public method Static SolvePoly(List<Double>, double, double, double, List<Double>) General polynomial solver.
Public method Static SolveQuadric(double, double, double, List<Double>, double) Solves the quadric equation c2*x^2 + c1 * x+ c0 = 0 for x.
Public method Static SolveQuartic(double, double, double, double, double, List<Double>) Solves the cubic equation c4*x^4 + c3*x^3 + c2*x^2 + c1 * x+ c0 = 0 for x.
Public method Static StandardDeviation(List<Double>)
Public method Static Swap(ref double, ref double)
Public method Static Swap<T>(IList<T>, int, int)
Public method Static Swap<T>(ref T, ref T) Generic swap method
Public method Static ToDegrees(double)
Public method Static ToRadians(double)
Public method Static TransformAngle(double, Matrix2d)
Public method Static TriangleArea(Point2d, Point2d, Point2d) Computes a triangles area.
Public method Static TriangleArea(double, double, double) Computes a triangles area given length of its sides using herons formula
Public method Static Unique(List<Double>, double)
Public method Static Unique<T>(List<T>)
Public method Static Variance(List<Double>)
Top
Fields
 
Name Description
Public field DegToRad Constant that multiplied with a angle in degrees gives an angle in radians.
Public field E The natural constant E (approximately 2.7182...)
Public field Epsilon The fuzz tolerance used in many genamo functions.
Public field HalfPI Shortcut for PI*0.5
Public field OneAndAHalfPI Shortcut for PI*1.5
Public field PI The matematical constant PI (approximately 3.1415....)
Public field QuarterPI Shortcut for PI*0.25
Public field RadToDeg Constant that multiplied with an angle in radians gives an angle in degrees.
Public field SquaredEpsilon Epsilon^2 (see epsilon for details). Useful in many squared calculations.
Public field TwoPI Shortcut for two times PI
Public field ZeroClamp Value used when very small changes are needed
Top

.NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

In this article

Definition