-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.nut
30 lines (26 loc) · 1.17 KB
/
utils.nut
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
utils <- {
getShortestOrigin = function(startOrigin, endOrigin) {
return Vector(endOrigin.x - startOrigin.x,
endOrigin.y - startOrigin.y,
endOrigin.z - startOrigin.z)
},
getShortestAngle = function(startAngles, endAngles) {
local shortest_angle_x = ((((endAngles.x - startAngles.x) % 360) + 540) % 360) - 180;
local shortest_angle_y = ((((endAngles.y - startAngles.y) % 360) + 540) % 360) - 180;
local shortest_angle_z = ((((endAngles.z - startAngles.z) % 360) + 540) % 360) - 180;
return Vector(shortest_angle_x, shortest_angle_y, shortest_angle_z)
},
getTotalStep = function(start, end, cameraSpeed) {
local distance = end.origin - start.origin
local totalStep = abs(distance.Length() / cameraSpeed)
return totalStep.tofloat()
},
createAlias = function(key, action) {
SendToConsole(format("alias \"%s\" \"%s\"", key, action))
SendToConsole(format("setinfo %s \"\"", key))
dev.log("The alias \"" + key + "\" was created")
},
vecToStr = function(vec) {
return format("Vector(%f, %f, %f)", vec.x, vec.y, vec.z)
}
}