File size: 7,133 Bytes
b6a38d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# point reference


## point:AddX

Returns a point with the X coordinate changed by the parameter. If the parameter is zero, the original point is returned to avoid an allocation.



Pseudocode:

~~~~ Lua
function point:AddX(x0)
	return point(self.x + x0, self.y, self.z)
~~~~

point **point:AddX**(number x0)
number x0
: value to add to the x coordinate

_returns_ point
: new point with the x coordinate increased by x0


## point:AddY

Returns a point with the Y coordinate changed by the parameter. If the parameter is zero, the original point is returned to avoid an allocation.



Pseudocode:

~~~~ Lua
function point:AddY(y0)
	return point(self.x, self.y + y0, self.z)
~~~~

point **point:AddY**(number y0)
number y0
: value to add to the y coordinate

_returns_ point
: new point with the y coordinate increased by y0


## point:AddZ

Returns a point with the Z coordinate changed by the parameter.



Pseudocode:

~~~~ Lua
function point:AddZ(z0)
	return point(self.x, self.y, self.z + z0)
~~~~

point **point:AddZ**(number z0)
number z0
: value to add to the z coordinate

_returns_ point
: new point with the z coordinate increased by z0


## point:InplaceAdd

Add to the coordinates of an existing point inplace (without creating another point).


point **point:InplaceAdd**(number x, number y[, number z])

point **point:InplaceAdd**(point other)
_returns_ point
: the point itself


## point:InplaceAddX

Add to the x coordinate of an existing point inplace (without creating another point).


point **point:InplaceAddX**(number x)
_returns_ point
: the point itself


## point:InplaceAddY

Add to the y coordinate of an existing point inplace (without creating another point).


point **point:InplaceAddY**(number y)
_returns_ point
: the point itself


## point:InplaceAddZ

Add to the z coordinate of an existing point inplace (without creating another point).


point **point:InplaceAddZ**(number z)
_returns_ point
: the point itself


## point:InplaceSet

Set the coordinates of an existing point inplace (without creating another point).


point **point:InplaceSet**(number x, number y[, number z])

point **point:InplaceSet**(point other)
_returns_ point
: the point itself


## point:InplaceSetX

Set the x coordinate of an existing point inplace (without creating another point).


point **point:InplaceSetX**(number x)
_returns_ point
: the point itself


## point:InplaceSetY

Set the y coordinate of an existing point inplace (without creating another point).


point **point:InplaceSetY**(number y)
_returns_ point
: the point itself


## point:InplaceSetZ

Set the z coordinate of an existing point inplace (without creating another point).


point **point:InplaceSetZ**(number z)
_returns_ point
: the point itself


## point:IsValidZ

Checks if the point has a valid Z coordinate.




bool **point:IsValidZ**()
_returns_ bool
: true if the point's Z coordinate is valid (i.e. different from the special value InvalidZ, denoting on-the-terrain points).


## point:Normalize

Returns a point with the same vector direction, but with vector length 4096. If z == InvalidZ, normalizes only in the 2D plane XY coordinates.


point **point:Normalize**()
_returns_ point n
: a point with length 4096 with the same direction as the original point.


## point:SetInvalidZ

Returns a new point with the Z coordinate set to the special value InvalidZ, denoting a point on the terrain surface.


point **point:SetInvalidZ**()

## point:SetLen

Returns a point with the same vector direction, but with set vector length. If z == InvalidZ, only sets the length of the XY coordinates.


point **point:SetLen**(int len)
int len
: desired vector length of the output point.

_returns_ point p
: a point with vector length set to *len* and the same direction as the original point.


## point:SetLen2D

Returns a point with the same vector direction in the XY plane, but with a set vector len. Ignores the Z coordinate of the original point. Sets the output Z to InvalidZ.


point **point:SetLen2D**(int len)
int len
: desired vector length of the output point.

_returns_ point p
: a point with vector length in the XY plane set to *len*, z == InvalidZ, and the same direction as the original point.


## point:SetTerrainZ

Returns a new point with Z set to the terrain/walkable height at these XY coordintes.


point **point:SetTerrainZ**()
_returns_ point
: a new point with Z set to the terrain/walkable height at XY


## point:SetX

Returns a point with the X coordinate set to the parameter.



Pseudocode:

~~~~ Lua
function point:SetX(x0)
	return point(x0, self.y, self.z)
~~~~

point **point:SetX**(number x0)
number x0
: new x coordinate value

_returns_ point
: new point with the x coordinate set to x0


## point:SetY

Returns a point with the Y coordinate set to the parameter. If the parameter is equal to the current coordinate value, the original point is returned to avoid an allocation.



Pseudocode:

~~~~ Lua
function point:SetY(y0)
	return point(self.x, y0, self.z)
~~~~

point **point:SetY**(number y0)
number y0
: new y coordinate value

_returns_ point
: new point with the y coordinate set to y0


## point:SetZ

Returns a point with the Z coordinate set to the parameter.



Pseudocode:

~~~~ Lua
function point:SetZ(z0)
	return point(self.x, self.y, z0)
~~~~

point **point:SetZ**(number z0)
number z0
: new z coordinate value

_returns_ point
: new point with the z coordinate set to z0


## point:x

Returns the x coordinate of the point.




number **point:x**()
_returns_ x
: the x coordinate of the point


## point:xy

Returns the x and y coordinates of the point.




number, number **point:xy**()
_returns_ x, y
: the x and y coordinates of the point


## point:xyz

Returns the coordinates of the point. Two return values are returned if the point has InvalidZ.




number, number, number **point:xyz**()
_returns_ x, y, z
: the coordinate of the point


## point:y

Returns the y coordinate of the point.




number **point:y**()
_returns_ y
: the y coordinate of the point


## point:z

Returns the z coordinate of the point.




number **point:z**()
_returns_ z
: the z coordinate of the point, or nil if it's InvalidZ


## LimitLen

Returns a point with the same vector direction, but with vector length limited to the specified length. If the point already has a vector length no greater than the parameter, returns it unmodified.


point **LimitLen**(point pt, int length)
_returns_ point
: a new point with the same vector direction as the original point 


## point

Creates a point from two or three number coordinates. If only two are supplied, Z = InvalidZ (the point is on the terrain).




point **point**(number x, number y [, number z])
x, y, z
: the coordinates of the new point

_returns_ point
: the created point





(insert footer.md.html here)
<link rel="stylesheet" type="text/css" href="Style.css" />
<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js" charset="utf-8"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>