Skip to content

Commit 33ca115

Browse files
committedJul 20, 2014
Remove vector assertions
These were initially added to get tracebacks for invalid vector errors, but it didn't work and tracebacks have since been properly fixed in the core.
1 parent f0db6c4 commit 33ca115

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed
 

Diff for: ‎builtin/common/vector.lua

-21
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11

22
vector = {}
33

4-
local function assert_vector(v)
5-
assert(type(v) == "table" and v.x and v.y and v.z, "Invalid vector")
6-
end
7-
84
function vector.new(a, b, c)
95
if type(a) == "table" then
106
assert(a.x and a.y and a.z, "Invalid vector passed to vector.new()")
@@ -17,20 +13,16 @@ function vector.new(a, b, c)
1713
end
1814

1915
function vector.equals(a, b)
20-
assert_vector(a)
21-
assert_vector(b)
2216
return a.x == b.x and
2317
a.y == b.y and
2418
a.z == b.z
2519
end
2620

2721
function vector.length(v)
28-
assert_vector(v)
2922
return math.hypot(v.x, math.hypot(v.y, v.z))
3023
end
3124

3225
function vector.normalize(v)
33-
assert_vector(v)
3426
local len = vector.length(v)
3527
if len == 0 then
3628
return {x=0, y=0, z=0}
@@ -40,7 +32,6 @@ function vector.normalize(v)
4032
end
4133

4234
function vector.round(v)
43-
assert_vector(v)
4435
return {
4536
x = math.floor(v.x + 0.5),
4637
y = math.floor(v.y + 0.5),
@@ -49,17 +40,13 @@ function vector.round(v)
4940
end
5041

5142
function vector.distance(a, b)
52-
assert_vector(a)
53-
assert_vector(b)
5443
local x = a.x - b.x
5544
local y = a.y - b.y
5645
local z = a.z - b.z
5746
return math.hypot(x, math.hypot(y, z))
5847
end
5948

6049
function vector.direction(pos1, pos2)
61-
assert_vector(pos1)
62-
assert_vector(pos2)
6350
local x_raw = pos2.x - pos1.x
6451
local y_raw = pos2.y - pos1.y
6552
local z_raw = pos2.z - pos1.z
@@ -89,9 +76,7 @@ end
8976

9077

9178
function vector.add(a, b)
92-
assert_vector(a)
9379
if type(b) == "table" then
94-
assert_vector(b)
9580
return {x = a.x + b.x,
9681
y = a.y + b.y,
9782
z = a.z + b.z}
@@ -103,9 +88,7 @@ function vector.add(a, b)
10388
end
10489

10590
function vector.subtract(a, b)
106-
assert_vector(a)
10791
if type(b) == "table" then
108-
assert_vector(b)
10992
return {x = a.x - b.x,
11093
y = a.y - b.y,
11194
z = a.z - b.z}
@@ -117,9 +100,7 @@ function vector.subtract(a, b)
117100
end
118101

119102
function vector.multiply(a, b)
120-
assert_vector(a)
121103
if type(b) == "table" then
122-
assert_vector(b)
123104
return {x = a.x * b.x,
124105
y = a.y * b.y,
125106
z = a.z * b.z}
@@ -131,9 +112,7 @@ function vector.multiply(a, b)
131112
end
132113

133114
function vector.divide(a, b)
134-
assert_vector(a)
135115
if type(b) == "table" then
136-
assert_vector(b)
137116
return {x = a.x / b.x,
138117
y = a.y / b.y,
139118
z = a.z / b.z}

0 commit comments

Comments
 (0)
Please sign in to comment.