Fixed a silly notion with Vector, airthmitic functions won't set Vector's data unless its setting arithmitic now. (vector+other won't set vector but will return a new vector, while

vector+=other WILL set vector's data)
This commit is contained in:
2019-02-20 11:12:14 -06:00
parent a6e175d9e0
commit cad7b5c263

View File

@@ -14,6 +14,15 @@ class IMICFPS
end end
def +(other) def +(other)
Vector.new(
@x + other.x,
@y + other.y
@z + other.z
@weight + other.weight
)
end
def +=(other)
@x += other.x @x += other.x
@y += other.y @y += other.y
@z += other.z @z += other.z
@@ -21,6 +30,15 @@ class IMICFPS
end end
def -(other) def -(other)
Vector.new(
@x - other.x,
@y - other.y
@z - other.z
@weight - other.weight
)
end
def -=(other)
@x -= other.x @x -= other.x
@y -= other.y @y -= other.y
@z -= other.z @z -= other.z
@@ -28,6 +46,15 @@ class IMICFPS
end end
def *(other) def *(other)
Vector.new(
@x * other.x,
@y * other.y
@z * other.z
@weight * other.weight
)
end
def *=(other)
@x *= other.x @x *= other.x
@y *= other.y @y *= other.y
@z *= other.z @z *= other.z
@@ -35,6 +62,15 @@ class IMICFPS
end end
def /(other) def /(other)
Vector.new(
@x / other.x,
@y / other.y
@z / other.z
@weight / other.weight
)
end
def /=(other)
@x /= other.x @x /= other.x
@y /= other.y @y /= other.y
@z /= other.z @z /= other.z