Added normalized and magnitude to Vector

This commit is contained in:
2019-02-20 17:15:26 -06:00
parent 22bb98cb64
commit 8b65973f6f

View File

@@ -65,6 +65,17 @@ class IMICFPS
) )
end end
# returns magnitude of Vector, ignoring #weight
def magnitude
Math.sqrt((@x * @x) + (@y * @y) + (@z * @z))
end
def normalized
mag = magnitude
p mag
self / Vector.new(mag, mag, mag)
end
def to_a def to_a
[@x, @y, @z, @weight] [@x, @y, @z, @weight]
end end