mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
Added normalized and magnitude to Vector
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user