Geometry and images: API index¶
Find an operation by its purpose. Entries link to the complete signature and contract.
HMath.Geometry¶
| API | Purpose |
|---|---|
| Point2 | Cartesian two-dimensional point, also used for vectors. |
| P2 | Declaration and type contract below. |
| Point3 | Cartesian right-handed three-dimensional point/vector. |
| P3 | Declaration and type contract below. |
| PointND | A point of dimension 1..16. |
| PointND | Declaration and type contract below. |
| point2 | Given x,y, construct Point2 after bounded finite-coordinate validation. |
| point3 | Given x,y,z, construct Point3 after bounded finite-coordinate validation. |
| pointND | Construct a checked ND point from 1..16 bounded finite coordinates. |
| Line | Parametric line origin+t*direction; direction must be nonzero. |
| Line | Declaration and type contract below. |
| Ray | Parametric ray origin+t*direction, t>=0. |
| Ray | Declaration and type contract below. |
| Segment | Closed segment with two endpoints; zero length is valid. |
| Segment | Declaration and type contract below. |
| Plane | Plane normal dot x = offset, with a nonzero normal. |
| Plane | Declaration and type contract below. |
| Triangle | Closed triangle; zero-area triangles are rejected by triangle operations. |
| Triangle | Declaration and type contract below. |
| Rectangle | Axis-aligned rectangle with ordered corners. |
| Rectangle | Declaration and type contract below. |
| Circle | Circle with nonnegative radius. |
| Circle | Declaration and type contract below. |
| Ellipse | Rotated ellipse: positive semiaxes, counterclockwise angle in radians. |
| Ellipse | Declaration and type contract below. |
| Polygon | Simple polygon; vertices are implicitly closed and no duplicate endpoint is needed. |
| Polygon | Declaration and type contract below. |
| Sphere | Closed sphere, including a zero radius. |
| Sphere | Declaration and type contract below. |
| AABB | Ordered, closed axis-aligned bounds in 1..16 dimensions. |
| AABB | Declaration and type contract below. |
| OBB | Oriented three-dimensional box: center, three orthonormal axes, half-extents. |
| OBB | Declaration and type contract below. |
| Capsule | Capsule around the closed axis segment. |
| Capsule | Declaration and type contract below. |
| Cylinder | Finite cylinder with endpoint centers and radius; endpoints must differ. |
| Cylinder | Declaration and type contract below. |
| Cone | Finite cone with apex, base center, and radius; axis must be nonzero. |
| Cone | Declaration and type contract below. |
| Frustum | Convex frustum represented by six inward half-spaces n dot x >= offset. |
| Frustum | Declaration and type contract below. |
| Orientation | Sign of an exact predicate on the input Double values. |
| Clockwise | Declaration and type contract below. |
| Collinear | Declaration and type contract below. |
| Counterclockwise | Declaration and type contract below. |
| Location | Point position with boundary reported separately. |
| Outside | Declaration and type contract below. |
| Boundary | Declaration and type contract below. |
| Inside | Declaration and type contract below. |
HMath.Geometry.Collision¶
| API | Purpose |
|---|---|
| gjk | Convex intersection by Gilbert-Johnson-Keerthi support/simplex iterations. |
| Penetration | Normal moves the second shape away from the first by penetrationDepth. |
| Penetration | Declaration and type contract below. |
| penetrationDepth | Estimated overlap depth along penetrationNormal, in coordinate units. |
| penetrationNormal | Separating direction of the returned EPA penetration estimate. |
| penetrationError | Remaining absolute support gap at the stopping iteration. |
| penetrationIterations | Completed expanding-polytope iterations. |
| epa | Expanding polytope penetration estimate. |
| separatingAxis | Separating-axis collision and minimum overlap for convex polygons. |
HMath.Geometry.Internal¶
| API | Purpose |
|---|---|
| Point2 | Cartesian two-dimensional point, also used for vectors. |
| P2 | Declaration and type contract below. |
| Point3 | Cartesian right-handed three-dimensional point/vector. |
| P3 | Declaration and type contract below. |
| PointND | A point of dimension 1..16. |
| PointND | Declaration and type contract below. |
| Line | Parametric line origin+t*direction; direction must be nonzero. |
| Line | Declaration and type contract below. |
| Ray | Parametric ray origin+t*direction, t>=0. |
| Ray | Declaration and type contract below. |
| Segment | Closed segment with two endpoints; zero length is valid. |
| Segment | Declaration and type contract below. |
| Plane | Plane normal dot x = offset, with a nonzero normal. |
| Plane | Declaration and type contract below. |
| Triangle | Closed triangle; zero-area triangles are rejected by triangle operations. |
| Triangle | Declaration and type contract below. |
| Rectangle | Axis-aligned rectangle with ordered corners. |
| Rectangle | Declaration and type contract below. |
| Circle | Circle with nonnegative radius. |
| Circle | Declaration and type contract below. |
| Ellipse | Rotated ellipse: positive semiaxes, counterclockwise angle in radians. |
| Ellipse | Declaration and type contract below. |
| Polygon | Simple polygon; vertices are implicitly closed and no duplicate endpoint is needed. |
| Polygon | Declaration and type contract below. |
| Sphere | Closed sphere, including a zero radius. |
| Sphere | Declaration and type contract below. |
| AABB | Ordered, closed axis-aligned bounds in 1..16 dimensions. |
| AABB | Declaration and type contract below. |
| OBB | Oriented three-dimensional box: center, three orthonormal axes, half-extents. |
| OBB | Declaration and type contract below. |
| Capsule | Capsule around the closed axis segment. |
| Capsule | Declaration and type contract below. |
| Cylinder | Finite cylinder with endpoint centers and radius; endpoints must differ. |
| Cylinder | Declaration and type contract below. |
| Cone | Finite cone with apex, base center, and radius; axis must be nonzero. |
| Cone | Declaration and type contract below. |
| Frustum | Convex frustum represented by six inward half-spaces n dot x >= offset. |
| Frustum | Declaration and type contract below. |
| Orientation | Sign of an exact predicate on the input Double values. |
| Clockwise | Declaration and type contract below. |
| Collinear | Declaration and type contract below. |
| Counterclockwise | Declaration and type contract below. |
| Location | Point position with boundary reported separately. |
| Outside | Declaration and type contract below. |
| Boundary | Declaration and type contract below. |
| Inside | Declaration and type contract below. |
| finite | Test whether a Double is neither NaN nor infinite. |
| require | Given predicate then diagnostic text, return Right () if satisfied or Left (DomainError text). |
| coord | Accept a finite geometry coordinate only when its absolute value is <=1e50, bounding downstream Double products. |
| coords2 | Extract [x,y] from a Point2 without validation. |
| coords3 | Extract [x,y,z] from a Point3 without validation. |
| coordsND | Extract ordered coordinate list from a PointND without validation. |
| check2 | Validate both Point2 coordinates as finite with absolute magnitude <=1e50; invalid data returns DomainError. |
| check3 | Validate all Point3 coordinates as finite with absolute magnitude <=1e50; invalid data returns DomainError. |
| checkND | Require 1..16 coordinates, all finite and bounded by 1e50 in magnitude. |
| checkPair | Validate both ND points and require equal dimensions. |
| checked | Return the supplied list if every Double is finite, otherwise Left NonFiniteResult. |
| point2 | Given x,y, construct Point2 after bounded finite-coordinate validation. |
| point3 | Given x,y,z, construct Point3 after bounded finite-coordinate validation. |
| pointND | Construct a checked ND point from 1..16 bounded finite coordinates. |
| dot | Unchecked sum of pairwise list products using zipWith; unequal lists truncate to the shorter length. |
| norm | Return scaled Euclidean list norm to reduce intermediate overflow; empty/all-zero list yields zero. |
| sub | Unchecked coordinatewise left-minus-right list subtraction, truncating to the shorter list on mismatch. |
| plus | Unchecked coordinatewise list addition, truncating to the shorter list on mismatch. |
| scale | Given Double scalar then coordinate list, return all coordinates multiplied by it without validation. |
| cross | Return right-handed cross product of two Point3 vectors. |
| add2 | Add Point2 coordinates componentwise without validation. |
| sub2 | Subtract right Point2 coordinates from left, without validation. |
| scale2 | Given scalar then Point2, scale both coordinates without validation. |
| cross2 | Return 2D determinant axby-aybx as Double without validation. |
| dot2 | Return 2D dot product axbx+ayby without validation. |
| norm2 | Return scaled Euclidean length of a Point2 without checked finite validation. |
| from3 | Convert a list of exactly three Doubles to Point3; all other lengths return origin P3 0 0 0. |
| edges | Pair each polygon-list element with its cyclic successor, including the last-to-first edge. |
| orientExact | Given finite points a,b,c, compute exact Rational determinant of their represented Double coordinates. |
| orient | Compare orientExact determinant with zero, returning GT for counterclockwise, EQ for collinear, LT for clockwise. |
| onSegment | Given endpoints a,b then point p, test exact collinearity and inclusive coordinate bounds. |
| checkPolygon | Validate a simple polygon with 3..256 bounded finite vertices, no adjacent duplicates, nonzero area and no nonadjacent edge intersection. |
| signedArea | Return oriented shoelace area using exact Rational intermediate arithmetic on finite Double coordinates. |
| ccw | Return polygon vertices in counterclockwise order by reversing negative signed area; zero-area input remains unchanged. |
| locateUnchecked | Given valid simple polygon vertices then finite Point2, return Boundary for an edge point, otherwise Inside/Outside by ray parity. |
| firstOr | Given fallback then list, return its first element or the fallback for empty input. |
HMath.Geometry.Polygon¶
| API | Purpose |
|---|---|
| HullAlgorithm | Four distinct planar convex-hull construction algorithms. |
| GrahamScan | Declaration and type contract below. |
| MonotoneChain | Declaration and type contract below. |
| Quickhull | Declaration and type contract below. |
| GiftWrapping | Declaration and type contract below. |
| convexHull | Convex hull with at most 4096 input points. |
| polygonArea | Unsigned simple polygon area. |
| polygonCentroid | Area-weighted centroid; works for nonconvex simple polygons. |
| shoelace | Signed shoelace area; clockwise polygons have negative area. |
| BooleanOperation | Boolean set operation on closed polygon regions; ring boundaries have zero area. |
| Union | Declaration and type contract below. |
| Intersection | Declaration and type contract below. |
| Difference | Declaration and type contract below. |
| polygonBoolean | Exact edge-arrangement Boolean. |
| clipPolygon | Sutherland-Hodgman clipping against a convex CCW/clockwise clip polygon. |
| minimumBoundingCircle | Deterministic incremental minimum enclosing circle, O(n^3), at most 256 points. |
| minimumBoundingRectangle | Minimum-area oriented enclosing rectangle. |
| minkowskiSum | Convex Minkowski sum, via pairwise sums followed by a hull. |
HMath.Geometry.Primitives¶
| API | Purpose |
|---|---|
| Metric | Minkowski p must be finite and at least one. |
| Euclidean | Declaration and type contract below. |
| Manhattan | Declaration and type contract below. |
| Chebyshev | Declaration and type contract below. |
| Minkowski | Declaration and type contract below. |
| distance | Euclidean, L1, Linfinity, or scaled Lp distance. |
| cosineDistance | One minus cosine similarity; zero vectors are undefined. |
| hammingDistance | Number of unequal positions (not normalized). |
| jaccardDistance | Set Jaccard distance; two empty sets have distance zero. |
| hausdorffDistance | Symmetric Hausdorff distance on two nonempty finite clouds, at most 1024 each. |
| mahalanobisDistance | Mahalanobis distance using a checked symmetric positive-definite covariance. |
| pointLineDistance | Distance to an infinite line; a zero direction is an error. |
| pointSegmentDistance | Distance to a closed segment, including a zero-length segment. |
| pointPlaneDistance | Unsigned perpendicular plane distance. |
| orientation | Exact orientation of the represented finite Double coordinates. |
| incircle | Exact in-circle sign, orientation-independent: positive means inside. |
| polygonLocation | Simple polygon position, with boundary separate from interior. |
| triangleLocation | Triangle position using exact orientation signs. |
| sphereContains | Closed sphere containment. |
| boxContains | Closed axis-aligned box containment. |
| ellipseContains | Closed ellipse containment after rotation to its principal axes. |
| triangleBarycentric | Weights (a,b,c) summing to one; valid outside the triangle as well. |
| circumcenter | Circumcenter, obtained from exact rational perpendicular-bisector equations. |
| incenter | Incenter weighted by opposite side lengths. |
| Intersection2 | Two-dimensional intersection, with a coincident line or overlapping segment explicit. |
| NoIntersection | Declaration and type contract below. |
| IntersectionPoint | Declaration and type contract below. |
| OverlapSegment | Declaration and type contract below. |
| CoincidentLine | Declaration and type contract below. |
| segmentIntersection | Closed segment intersection with exact degeneracy predicates. |
| lineIntersection | Infinite-line intersection from origins and nonzero direction vectors. |
| linePlaneIntersection | Lineplane result: Nothing paralleldisjoint, Just Nothing coincident, Just (Just p) a unique intersection. |
| planeIntersection | Plane intersection: same nested convention as linePlaneIntersection, with the unique intersection represented by a line. |
| rayTriangle | Moller-Trumbore ray intersection; coplanar rays return Nothing because their hit set is not a unique transverse surface crossing. |
| rayBox | Slab intersection interval [entry,exit], clipped to the ray t>=0. |
| raySphere | Ray-sphere near/far nonnegative parameters; tangent gives equal roots. |
| CircleIntersection | Circle intersections: coincidence is distinct from disjointness and tangency. |
| DisjointCircles | Declaration and type contract below. |
| CoincidentCircles | Declaration and type contract below. |
| CirclePoints | Declaration and type contract below. |
| circleIntersection | Given two circles, return DisjointCircles, CoincidentCircles, or CirclePoints for their intersection. |
| triangleIntersection | Closed triangle overlap polygon, including isolated tangencies as vertices. |
| sphereSDF | Sphere signed distance (negative inside). |
| boxSDF | Axis-aligned box exact signed Euclidean distance in 1..16 dimensions. |
| obbSDF | Oriented box distance after validating its orthonormal axes. |
| capsuleSDF | Capsule distance from its closed axis minus radius. |
| cylinderSDF | Exact capped finite-cylinder signed distance. |
| coneSDF | Exact finite-cone distance by reducing to its radial/axial cross-section. |
HMath.Geometry.Spatial¶
| API | Purpose |
|---|---|
| SpatialKind | Explicit index construction algorithm; hash width must be positive finite. |
| SpatialHash | Declaration and type contract below. |
| KDTree | Declaration and type contract below. |
| BallTree | Declaration and type contract below. |
| Quadtree | Declaration and type contract below. |
| Octree | Declaration and type contract below. |
| RTree | Declaration and type contract below. |
| BVH | Declaration and type contract below. |
| PointCloud | Validated homogeneous finite cloud; a nonempty cloud defines its dimension. |
| pointCloud | Construct a nonempty cloud of at most 65536 points, with consistent dimensions. |
| cloudPoints | Original cloud observations. |
| SpatialIndex | Opaque checked spatial-search tree/hash index. |
| buildSpatialIndex | Build the named structure. |
| rangeQuery | Closed range search, sorted original IDs. |
| radiusQuery | Exact closed radius query; uses the index range query then Euclidean filtering. |
| NeighborQuery | A budgeted nearest-neighbor answer; False means unexplored leaves may improve the answer. |
| NeighborQuery | Declaration and type contract below. |
| queryNeighbors | Nearest candidate IDs paired with Euclidean distances, in increasing distance order. |
| queryLeaves | Number of visited spatial-index leaves charged to the query budget. |
| queryExhaustive | True only when unexplored nodes cannot improve the returned neighbors; False marks a budget-limited approximation. |
| nearestQuery | Given neighbor count k, positive leaf budget, index, then query point, search for nearest neighbors. |
HMath.Geometry.Transform¶
| API | Purpose |
|---|---|
| affineTransform | Construct an affine matrix [linear,translation;0,1]. |
| applyTransform | Apply an affine or projective matrix and divide by homogeneous w. |
| composeTransforms | Checked matrix composition; projective and affine matrices may be mixed. |
| inverseTransform | Gauss-Jordan inverse with partial pivoting, bounded to matrices of size 17. |
| perspective | Vertical field of view in (0,pi), positive aspect, 0<near<far. |
| orthographic | Orthographic bounds with left<right, bottom<top and 0<=near<far. |
| lookAt | World-to-camera transform from eye, target and nonparallel up direction. |
| extractFrustum | Extract six inward clipping planes from projection*view. |
| cullSphere | True means the closed sphere may be visible (conservative plane culling). |
| cullBox | True means the closed 3D AABB may be visible; corners need not be allocated. |
HMath.Geometry.Triangulation¶
| API | Purpose |
|---|---|
| IndexedTriangle | Counterclockwise indices into the caller's input point list. |
| delaunay | Incremental cavity replacement. |
| constrainedDelaunay | Insert noncrossing constrained edges by convex quadrilateral flips, then Lawson-flip every unconstrained illegal edge. |
| voronoi | Voronoi cells clipped to an ordered nonzero rectangle, one polygon ring per site (empty only if the site lies outside the clipping rectangle). |
| earClip | Ear clipping of a simple polygon. |
HMath.Image¶
| API | Purpose |
|---|---|
| Boundary | Image sampling policy: Constant fill,edge Clamp,half-sample symmetric Reflect,or periodic Wrap. |
| Constant | Declaration and type contract below. |
| Clamp | Declaration and type contract below. |
| Reflect | Declaration and type contract below. |
| Wrap | Declaration and type contract below. |
| Image | Opaque finite CPU image with row-major spatial axes and interleaved channels. |
| fromTensor | Tensor shape must be spatial dimensions followed by a channel axis. |
| toTensor | Copy an image to Tensor Double with shape spatial dimensions followed by channel count. |
| normalize | Global min/max scaling; a constant image maps to the requested lower bound. |
| gamma | Positive gamma, nonnegative inputs; computes x^gamma without clipping. |
| image | Validate all dimensions before allocating boxed immutable array storage. |
| imageShape | Return spatial dimensions only, excluding the last implicit channel axis. |
| imageChannels | Return channel count, between one and sixteen for validated images. |
| imageValues | Return flat row-major samples with channels interleaved at each spatial coordinate. |
| pixel | Given image then complete spatial coordinates, return all channel values in order. |
| channel | Given zero-based channel index then image, return a copied one-channel image of the same spatial shape. |
| combineChannels | Concatenate channels of a nonempty same-spatial-shape image list in input order. |
| mapImage | Output is validated, including arithmetic overflow inside the callback. |
| zipImage | Given binary sample function then equally shaped/channel-count images, return a new validated image. |
| brightness | Add a finite offset without implicit clipping. |
| contrast | Scale about a caller-defined pivot, without clipping. |
| gradient | Returns row derivative, column derivative, magnitude, and atan2(row,col) direction in radians. |
| laplacian | Given boundary then one-channel 2D image, apply the four-neighbor 3-by-3 Laplacian [0,1,0;1,-4,1;0,1,0]. |
| convolve | Given boundary,kernel dimensions,flat weights,then image, reverse all kernel axes and correlate. |
| correlate | Correlation uses sample(ix+kernelOffset-center). |
| gaussianBlur | Separable Gaussian, truncated at an explicitly supplied integer radius. |
| boxBlur | Given boundary,radius,then image, average a centered full-dimensional box neighborhood independently per channel. |
| medianBlur | Given boundary,radius,then image, choose the median of each centered odd-sized neighborhood independently per channel. |
| bilateralBlur | Per-channel bilateral filtering: spatial and range Gaussian weights are multiplied, normalized locally, and computed relative to the center sample. |
| sharpen | Unsharp mask x+amount*(x-Gaussian(x)); no implicit range clipping. |
| GradientOperator | Image gradient stencil selector, choosing Sobel,Prewitt,or Scharr. |
| Sobel | Declaration and type contract below. |
| Prewitt | Declaration and type contract below. |
| Scharr | Declaration and type contract below. |
| canny | Canny: Gaussian smoothing, Sobel gradient, four-direction nonmaximum suppression, and 8-connected hysteresis. low/high are absolute normalized gradient magnitudes, not quantiles. |
| Morphology | Grayscale footprint operation selector: erosion,dilation,opening,or closing. |
| Erosion | Declaration and type contract below. |
| Dilation | Declaration and type contract below. |
| Opening | Declaration and type contract below. |
| Closing | Declaration and type contract below. |
| morphology | Flat grayscale morphology with an explicit odd-rank Boolean footprint. |
| morphologicalGradient | Given boundary,footprint dimensions,Bool footprint,then image, return dilation minus erosion. |
HMath.Image.Color¶
| API | Purpose |
|---|---|
| ColorSpace | Color coordinate convention,including sRGB,linear RGB,HSV,HSL,XYZ,Lab,and YCbCr. convertColor validates each source convention's ranges. |
| SRGB | Declaration and type contract below. |
| LinearRGB | Declaration and type contract below. |
| HSV | Declaration and type contract below. |
| HSL | Declaration and type contract below. |
| XYZ | Declaration and type contract below. |
| Lab | Declaration and type contract below. |
| YCbCr | Declaration and type contract below. |
| convertColor | Explicit source/destination spaces; three interleaved channels required. |
| grayscale | Rec.709 luminance, explicitly converting the stated source to linear RGB. |
| srgbToLinear | Transfer functions extend linearly below their positive breakpoints; finite negative/out-of-gamut channels are retained. |
| linearToSrgb | Encode a finite linear-light channel with the sRGB piecewise transfer function (linear branch through 0.0031308). |
HMath.Image.Core¶
| API | Purpose |
|---|---|
| Image | Opaque finite CPU image with row-major spatial axes and interleaved channels. |
| image | Validate all dimensions before allocating boxed immutable array storage. |
| fromTensor | Tensor shape must be spatial dimensions followed by a channel axis. |
| toTensor | Copy an image to Tensor Double with shape spatial dimensions followed by channel count. |
| imageShape | Return spatial dimensions only, excluding the last implicit channel axis. |
| imageChannels | Return channel count, between one and sixteen for validated images. |
| imageValues | Return flat row-major samples with channels interleaved at each spatial coordinate. |
| pixel | Given image then complete spatial coordinates, return all channel values in order. |
| channel | Given zero-based channel index then image, return a copied one-channel image of the same spatial shape. |
| combineChannels | Concatenate channels of a nonempty same-spatial-shape image list in input order. |
| mapImage | Output is validated, including arithmetic overflow inside the callback. |
| zipImage | Given binary sample function then equally shaped/channel-count images, return a new validated image. |
| normalize | Global min/max scaling; a constant image maps to the requested lower bound. |
| brightness | Add a finite offset without implicit clipping. |
| contrast | Scale about a caller-defined pivot, without clipping. |
| gamma | Positive gamma, nonnegative inputs; computes x^gamma without clipping. |
| Boundary | Image sampling policy: Constant fill,edge Clamp,half-sample symmetric Reflect,or periodic Wrap. |
| Constant | Declaration and type contract below. |
| Clamp | Declaration and type contract below. |
| Reflect | Declaration and type contract below. |
| Wrap | Declaration and type contract below. |
| coordinates | Enumerate zero-based row-major coordinates of a dimension list. [] yields [[]]; zero/negative extents yield no coordinates. |
| sample | Reflect is half-sample symmetric (... b a | a b c | c b ...). |
| build | Checked output allocation for internal coordinate-wise reference kernels. |
| at | Unchecked image access: given image,complete spatial coordinates,then channel, return one sample. |
| spatialSize | Return number of spatial pixels (shape product), excluding channel multiplicity. |
| finite | Test whether Double is neither NaN nor infinite. |
| require | Given predicate then diagnostic, return Right () or image-prefixed Left InvalidArgument. |
| checked | Return finite Double values unchanged, or Left NonFiniteResult when any sample is non-finite. |
HMath.Image.Filter¶
| API | Purpose |
|---|---|
| convolve | Given boundary,kernel dimensions,flat weights,then image, reverse all kernel axes and correlate. |
| correlate | Correlation uses sample(ix+kernelOffset-center). |
| gaussianBlur | Separable Gaussian, truncated at an explicitly supplied integer radius. |
| boxBlur | Given boundary,radius,then image, average a centered full-dimensional box neighborhood independently per channel. |
| medianBlur | Given boundary,radius,then image, choose the median of each centered odd-sized neighborhood independently per channel. |
| bilateralBlur | Per-channel bilateral filtering: spatial and range Gaussian weights are multiplied, normalized locally, and computed relative to the center sample. |
| sharpen | Unsharp mask x+amount*(x-Gaussian(x)); no implicit range clipping. |
| GradientOperator | Image gradient stencil selector, choosing Sobel,Prewitt,or Scharr. |
| Sobel | Declaration and type contract below. |
| Prewitt | Declaration and type contract below. |
| Scharr | Declaration and type contract below. |
| gradient | Returns row derivative, column derivative, magnitude, and atan2(row,col) direction in radians. |
| laplacian | Given boundary then one-channel 2D image, apply the four-neighbor 3-by-3 Laplacian [0,1,0;1,-4,1;0,1,0]. |
| canny | Canny: Gaussian smoothing, Sobel gradient, four-direction nonmaximum suppression, and 8-connected hysteresis. low/high are absolute normalized gradient magnitudes, not quantiles. |
| Morphology | Grayscale footprint operation selector: erosion,dilation,opening,or closing. |
| Erosion | Declaration and type contract below. |
| Dilation | Declaration and type contract below. |
| Opening | Declaration and type contract below. |
| Closing | Declaration and type contract below. |
| morphology | Flat grayscale morphology with an explicit odd-rank Boolean footprint. |
| morphologicalGradient | Given boundary,footprint dimensions,Bool footprint,then image, return dilation minus erosion. |
| validateBoundary | Validate Constant boundary value as finite; Clamp,Reflect,Wrap are always valid. |
| scalar2D | Require a two-dimensional one-channel image and return (height,width). |
| windowOffsets | Given radius then image, enumerate centered neighborhood offsets. |
HMath.Image.Histogram¶
| API | Purpose |
|---|---|
| histogram | Given bin count in [2,4096] then image with every sample in [0,1], return one Int count list per channel. |
| equalizeHistogram | CDF-min equalization with quantized bin mapping. |
| clahe | 2D adaptive equalization. clipFactor>=1 is relative to uniform tile occupancy; the cap is max(ceil(tileSamplesbins),floor(factor*tileSamplesbins)). |
| threshold | Strict comparison x>level; each channel is thresholded independently. |
| otsu | Otsu between-class variance maximum. |
| adaptiveThreshold | Local mean or Gaussian threshold: x > localMean-offset. |
HMath.Image.Measure¶
| API | Purpose |
|---|---|
| TemplateMetric | Template matching score: squared difference or normalized correlation. |
| SquaredDifference | Declaration and type contract below. |
| NormalizedCorrelation | Declaration and type contract below. |
| templateMatch | Valid 2D, one-channel matching. |
| rawMoment | Raw M_pq=sum(row^pcolumn^qintensity), orders 0..8 each. |
| centralMoment | Given row exponent p,column exponent q,then scalar 2D image, compute the unnormalized intensity-weighted central moment around its centroid. |
| imageCentroid | Intensity-weighted (row,column) centroid. |
| integralImage | Padded 2D summed-area image, per channel: output shape (height+1,width+1) has a leading zero row/column. |
| rectangleSum | Given (row,column) origin,(height,width) extent,then padded integralImage output, return per-channel sum of the half-open rectangle. |
| meanSquaredError | Given two images of equal spatial shape and channels, return average squared sample difference. |
| peakSignalToNoise | PSNR in decibels. |
| structuralSimilarity | Mean local SSIM with uniform valid windows and population covariance. |
HMath.Image.Spatial¶
| API | Purpose |
|---|---|
| Interpolation | Image resampling interpolation mode, choosing nearest,bilinear,bicubic,or Lanczos kernels. |
| Nearest | Declaration and type contract below. |
| Bilinear | Declaration and type contract below. |
| Bicubic | Declaration and type contract below. |
| Lanczos | Declaration and type contract below. |
| resize | 2D resize uses pixel-center mapping (i+0.5)*old/new-0.5, independently per channel, without antialiasing. |
| warp | Forward 3x3 homogeneous transform acts on [x(column),y(row),1]. |
| translate | Translation in pixel columns/rows; output dimensions equal input. |
| rotate | Angle in radians, clockwise on row-down image coordinates; rotate about the center pixel coordinate while preserving the input canvas dimensions. |
| Connectivity | Spatial connected-component adjacency: axis neighbors or all surrounding neighbors. |
| AxisConnected | Declaration and type contract below. |
| FullyConnected | Declaration and type contract below. |
| connectedComponents | Nonzero is foreground. |
| distanceTransform | Exact brute-force Euclidean distance to the nearest zero-valued spatial sample, with strictly positive per-axis spacing. |
HMath.Quaternion¶
| API | Purpose |
|---|---|
| Quaternion | A finite scalar-first Hamilton quaternion. |
| quaternion | Finite scalar-first constructor. |
| components | Scalar, x, y, z components. |
| norm | Scaled Euclidean norm (may overflow only when the true norm is unrepresentable). |
| normalize | Normalize without forming a squared norm; zero has no normalization. |
| inverse | Multiplicative inverse; uses component scaling to avoid norm overflow. |
| conjugate | Quaternion conjugation. |
| multiply | Hamilton product. |
| add | Component sum. |
| scale | Checked real scaling. |
| rotateVector | Rotate a finite three-vector; any nonzero quaternion is normalized first. |
| axisAngle | Axis-angle conversion. |
| toAxisAngle | Principal rotation angle in [0,pi]; identity uses the x axis. |
| fromEuler | Intrinsic ZYX rotation from (roll,pitch,yaw). |
| toEuler | Intrinsic ZYX angles, choosing roll zero at gimbal lock. |
| toMatrix | Active rotation as a row-major 3x3 matrix. |
| fromMatrix | Validate SO(3) within 1e-9, then use the largest-diagonal conversion near pi. |
| nlerp | Shortest-arc normalized linear interpolation on [0,1]. |
| slerp | Shortest-arc spherical interpolation, with stable NLERP near equal rotations. |
| squad | Shoemake SQUAD through q1 to q2 using neighboring q0 and q3. |
| exponential | General quaternion exponential; sinc expansion stabilizes a tiny vector part. |
| logarithm | Principal quaternion logarithm; the negative real axis chooses positive x. |
| swingTwist | Decompose q = swing * twist around a nonzero axis. |
HMath.Rotation¶
| API | Purpose |
|---|---|
| SO3 | Normalized representative of SO(3). |
| so3 | Normalize a nonzero quaternion into SO(3). |
| rotationQuaternion | Underlying unit Hamilton quaternion. |
| identityRotation | Identity rotation. |
| composeRotation | Composition applying the right rotation first. |
| inverseRotation | Inverse of a unit rotation. |
| rotate | Apply a rotation to a finite three-vector. |
| expSO3 | Exponential of a rotation vector; vector norm is the angle in radians. |
| logSO3 | Principal logarithm as a rotation vector. |
| SE3 | Rigid transformation x -> R*x+t. |
| se3 | Construct a rigid transform from a rotation and finite translation. |
| rotationPart | Rotation component. |
| translationPart | Translation component. |
| identityTransform | Identity rigid transform. |
| compose | Compose transforms; b acts first. |
| inverse | Inverse rigid transform. |
| transformPoint | Apply a rigid transform. |
| expSE3 | SE(3) exponential. |
| logSE3 | Principal SE(3) logarithm, stable at identity and at rotations near pi. |
| toHomogeneous | Row-major homogeneous 4x4 matrix, bottom row [0,0,0,1]. |
| fromHomogeneous | Validate a homogeneous rigid matrix (bottom row tolerance 1e-12, rotation 1e-9). |
| DualQuaternion | Unit real part and Study-orthogonal dual part. |
| dualQuaternion | Construct a rigid dual quaternion. |
| dualParts | Real and dual Hamilton parts. |
| toDualQuaternion | Encode translation as 0.5(0,t)r. |
| fromDualQuaternion | Decode translation from 2dconjugate(r). |
| multiplyDual | Rigid dual-quaternion product. |
| inverseDual | Inverse rigid dual quaternion. |
| interpolateDual | Shortest-rotation screw-linear interpolation on [0,1]. |