File: Math.html

package info (click to toggle)
three.js 111%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,184 kB
  • sloc: javascript: 133,174; makefile: 24; sh: 1
file content (109 lines) | stat: -rw-r--r-- 4,470 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<base href="../../../" />
		<script src="list.js"></script>
		<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 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 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] — A区间最大值。<br /><br />

		x从范围[[page:Float a1], [page:Float a2]] 到范围[[page:Float b1], [page:Float b2]]的线性映射。
		</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 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比最大值还大会返回0.<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>

		<h2>Source</h2>

		<p>
			[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
		</p>
	</body>
</html>