You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
6.8 KiB
150 lines
6.8 KiB
2 years ago
|
<!DOCTYPE html>
|
||
|
<html lang="zh">
|
||
|
<head>
|
||
|
<meta charset="utf-8" />
|
||
|
<base href="../../../" />
|
||
|
<script src="page.js"></script>
|
||
|
<link type="text/css" rel="stylesheet" href="page.css" />
|
||
|
</head>
|
||
|
<body>
|
||
|
<h1>数学函数([name])</h1>
|
||
|
|
||
|
<p class="desc">具有多个数学实用函数的对象。</p>
|
||
|
|
||
|
<h2>函数(Functions)</h2>
|
||
|
|
||
|
<h3>[method:Float clamp]( [param:Float value], [param:Float min], [param:Float max] )</h3>
|
||
|
<p>
|
||
|
[page:Float value] — 需要clamp处理的值。<br />
|
||
|
[page:Float min] — 最小值。<br />
|
||
|
[page:Float max] — 最大值。<br /><br />
|
||
|
|
||
|
限制数值[page:Float value]处于最小值[page:Float min]和最大值[page:Float max]之间。
|
||
|
</p>
|
||
|
|
||
|
<h3>[method:Float degToRad]( [param:Float degrees] )</h3>
|
||
|
<p>将度转化为弧度。</p>
|
||
|
|
||
|
<h3>[method:Integer euclideanModulo]( [param:Integer n], [param:Integer m] )</h3>
|
||
|
<p>
|
||
|
[page:Integer n], [page:Integer m] - 整型<br /><br />
|
||
|
计算 [page:Integer m] % [page:Integer n] 的欧几里得模:
|
||
|
<code>( ( n % m ) + m ) % m</code>
|
||
|
</p>
|
||
|
|
||
|
<h3>[method:UUID generateUUID]( )</h3>
|
||
|
<p>
|
||
|
创建一个全局唯一标识符 [link:https://en.wikipedia.org/wiki/Universally_unique_identifier UUID]。
|
||
|
</p>
|
||
|
|
||
|
<h3>[method:Boolean isPowerOfTwo]( [param:Number n] )</h3>
|
||
|
<p>如果 [page:Number n] 是2的幂,返回true。</p>
|
||
|
|
||
|
<h3>[method:Float inverseLerp]( [param:Float x], [param:Float y], [param:Float value] )</h3>
|
||
|
<p>
|
||
|
[page:Float x] - 起始点<br />
|
||
|
[page:Float y] - 终点<br />
|
||
|
[page:Float value] - 介于起始点和终点的值<br><br />
|
||
|
|
||
|
返回参数 value 在起点 x 与终点 y 的闭区间 [0,1] 中的百分比。
|
||
|
</p>
|
||
|
|
||
|
<h3>[method:Float lerp]( [param:Float x], [param:Float y], [param:Float t] )</h3>
|
||
|
<p>
|
||
|
[page:Float x] - 起始点。 <br />
|
||
|
[page:Float y] - 终点。 <br />
|
||
|
[page:Float t] - 闭区间 [0,1] 内的插值因子。<br><br />
|
||
|
|
||
|
返回给定区间的线性插值[link:https://en.wikipedia.org/wiki/Linear_interpolation linearly interpolated]结果 - [page:Float t] = 0 将会返回 [page:Float x]
|
||
|
如果 [page:Float t] = 1 将会返回 [page:Float y].
|
||
|
</p>
|
||
|
|
||
|
<h3>[method:Float damp]( [param:Float x], [param:Float y], [param:Float lambda], [param:Float dt] )</h3>
|
||
|
<p>
|
||
|
[page:Float x] - 当前点<br />
|
||
|
[page:Float y] - 目标点<br />
|
||
|
[page:Float lambda] - 较高的参数 lambda 值会使运动更加突然,而较低的值会使运动更加平缓。<br />
|
||
|
[page:Float dt] - 以秒为单位的增量时间<br><br />
|
||
|
|
||
|
使用 [page:Float dt] 以类似弹簧的方式从 [page:Float x] 向 [page:Float y] 平滑地插入一个数字,以保持与帧速率无关的运动。有关详细信息,请参阅 [link:http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/ Frame rate independent damping using lerp].
|
||
|
</p>
|
||
|
|
||
|
<h3>[method:Float mapLinear]( [param:Float x], [param:Float a1], [param:Float a2], [param:Float b1], [param:Float b2] )</h3>
|
||
|
<p>
|
||
|
[page:Float x] — 用于映射的值。<br />
|
||
|
[page:Float a1] — A区间最小值。<br />
|
||
|
[page:Float a2] — A区间最大值。<br />
|
||
|
[page:Float b1] — B区间最小值。<br />
|
||
|
[page:Float b2] — B区间最大值。<br /><br />
|
||
|
|
||
|
x从范围[[page:Float a1], [page:Float a2]] 到范围[[page:Float b1], [page:Float b2]]的线性映射。
|
||
|
</p>
|
||
|
|
||
|
<h3>[method:Float pingpong]( [param:Float x], [param:Float length] )</h3>
|
||
|
<p>
|
||
|
[page:Float x] — pingpong 的值<br />
|
||
|
[page:Float length] — 函数将 pingpong 传递到的正值。默认值为 1。<br /><br />
|
||
|
|
||
|
返回一个介于 0 和 [param:Float length] 之间的值。</p>
|
||
|
|
||
|
<h3>[method:Integer ceilPowerOfTwo]( [param:Number n] )</h3>
|
||
|
<p>返回大于等于 [page:Number n] 的2的最小次幂。</p>
|
||
|
|
||
|
<h3>[method:Integer floorPowerOfTwo]( [param:Number n] )</h3>
|
||
|
<p>返回小于等于 [page:Number n] 的2的最大幂。</p>
|
||
|
|
||
|
<h3>[method:Float radToDeg]( [param:Float radians] )</h3>
|
||
|
<p>将弧度转换为角度。</p>
|
||
|
|
||
|
<h3>[method:Float randFloat]( [param:Float low], [param:Float high] )</h3>
|
||
|
<p>在区间 [[page:Float low], [page:Float high]] 内随机一个浮点数。</p>
|
||
|
|
||
|
<h3>[method:Float randFloatSpread]( [param:Float range] )</h3>
|
||
|
<p>在区间 [- [page:Float range] / 2, [page:Float range] / 2] 内随机一个浮点数。</p>
|
||
|
|
||
|
<h3>[method:Integer randInt]( [param:Integer low], [param:Integer high] )</h3>
|
||
|
<p>在区间 [[page:Float low], [page:Float high]] 内随机一个整数。</p>
|
||
|
|
||
|
<h3>[method:Float seededRandom]( [param:Integer seed] )</h3>
|
||
|
<p>在区间 [0, 1] 中生成确定性的伪随机浮点数。 整数种子是可选的。</p>
|
||
|
|
||
|
<h3>[method:Float smoothstep]( [param:Float x], [param:Float min], [param:Float max] )</h3>
|
||
|
<p>
|
||
|
[page:Float x] - 根据其在最小值和最大值之间的位置来计算的值。 <br />
|
||
|
[page:Float min] - 任何x比最小值还小会返回0.<br />
|
||
|
[page:Float max] - 任何x比最大值还大会返回1.<br /><br />
|
||
|
|
||
|
返回0-1之间的值,该值表示x在最小值和最大值之间移动的百分比,但是当x接近最小值和最大值时,变化程度会平滑或减慢。<br/><br/>
|
||
|
|
||
|
查看更多详情请移步到 [link:http://en.wikipedia.org/wiki/Smoothstep Smoothstep] 。
|
||
|
</p>
|
||
|
|
||
|
<h3>[method:Float smootherstep]( [param:Float x], [param:Float min], [param:Float max] )</h3>
|
||
|
<p>
|
||
|
[page:Float x] - 根据其在最小值和最大值之间的位置来计算的值。 <br />
|
||
|
[page:Float min] - 任何x比最小值还小会返回0.<br />
|
||
|
[page:Float max] - 任何x比最大值还大会返回0.<br /><br />
|
||
|
|
||
|
返回一个0-1之间的值。它和smoothstep相同,但变动更平缓。[link:https://en.wikipedia.org/wiki/Smoothstep#Variations variation on smoothstep] 在x=0和x=1处有0阶和二阶导数。
|
||
|
</p>
|
||
|
|
||
|
<h3>[method:undefined setQuaternionFromProperEuler]( [param:Quaternion q], [param:Float a], [param:Float b], [param:Float c], [param:String order] )</h3>
|
||
|
<p>
|
||
|
[page:Quaternion q] - 将被设置的的四元数。<br />
|
||
|
[page:Float a] - 应用于第一个轴的旋转,以弧度为单位。<br />
|
||
|
[page:Float b] - 应用于第二个轴的旋转,以弧度为单位。<br />
|
||
|
[page:Float c] - 应用于第三个轴的旋转,以弧度为单位。<br />
|
||
|
[page:String order] - 指定轴旋转顺序的字符串:'XYX', 'XZX', 'YXY', 'YZY', 'ZXZ', 或 'ZYZ'<br /><br />
|
||
|
|
||
|
根据 [page:Float a]、[page:Float b]、[page:Float c]、[page:String order] 组成的欧拉角 [link:http://en.wikipedia.org/wiki/Euler_angles intrinsic Proper Euler Angles] 来设置四元数 [page:Quaternion q]。<br />
|
||
|
按照 [page:String order] 指定的轴旋转顺序:先旋转角度 [page:Float a],再旋转角度 [page:Float b],最后旋转角度 [page:Float c]。角度以弧度为单位。
|
||
|
</p>
|
||
|
|
||
|
<h2>Source</h2>
|
||
|
|
||
|
<p>
|
||
|
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
|
||
|
</p>
|
||
|
</body>
|
||
|
</html>
|