[gs-longan](../README.md) / Tolerance

# Class: Tolerance

单精度容差工具类

提供全局容差数值以及用于比较数值/数组的辅助方法。

## Table of contents

### Constructors

- [constructor](Tolerance.md#constructor)

### Properties

- [resabs](Tolerance.md#resabs)
- [resnor](Tolerance.md#resnor)

### Methods

- [isValueInInterval](Tolerance.md#isvalueininterval)
- [sameValue](Tolerance.md#samevalue)
- [sameValueFloatArray](Tolerance.md#samevaluefloatarray)

## Constructors

### constructor

• **new Tolerance**(): [`Tolerance`](Tolerance.md)

#### Returns

[`Tolerance`](Tolerance.md)

## Properties

### resabs

▪ `Static` **resabs**: `number` = `1.0e-3`

绝对容差

___

### resnor

▪ `Static` **resnor**: `number` = `1.0e-7`

法线相关容差

## Methods

### isValueInInterval

▸ **isValueInInterval**(`v`, `a`, `b`): `boolean`

判断值 v 是否在区间 [a,b]（含边界）内，考虑容差

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `v` | `number` | 待判断值 |
| `a` | `number` | 区间一端 |
| `b` | `number` | 区间另一端 |

#### Returns

`boolean`

___

### sameValue

▸ **sameValue**(`a`, `b`): `boolean`

判断两个数是否在绝对容差范围内相等

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `a` | `number` | 数值 a |
| `b` | `number` | 数值 b |

#### Returns

`boolean`

___

### sameValueFloatArray

▸ **sameValueFloatArray**(`a`, `b`): `boolean`

比较两个 Float32Array 是否逐元素相等（基于绝对容差）

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `a` | `Float32Array` | 数组 a |
| `b` | `Float32Array` | 数组 b |

#### Returns

`boolean`
