Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Classes/Vector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ function Vector:__div(other)
return Vector(self.X / other.X, self.Y / other.Y, self.Z / other.Z)
end

function Vector:__len()
return math.sqrt(self.X^2 + self.Y^2 + self.Z^2)
end

function Vector:__pow(other)
return Vector(self.Y * other.Z - self.Z * other.Y, self.Z * other.X - self.X * other.Z, self.X * other.Y - self.Y * other.X)
end
Expand Down
6 changes: 5 additions & 1 deletion Classes/Vector2D.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ function Vector2D:__div(other)
return Vector2D(self.X / other.X, self.Y / other.Y)
end

function Vector2D:__len()
return math.sqrt(self.X^2 + self.Y^2)
end

function Vector2D:__unm()
return Vector2D(-self.X, -self.Y)
end
Expand All @@ -77,4 +81,4 @@ end

function Vector2D:__tostring()
return "Vector2D(X = " .. self.X .. ", Y = " .. self.Y .. ")"
end
end