lib/lotu/helpers/vector2d.rb in lotu-0.1.18 vs lib/lotu/helpers/vector2d.rb in lotu-0.1.19
- old
+ new
@@ -127,14 +127,23 @@
def facing_to?(vector)
dot(vector) > 0
end
+ def rotate radians
+ new_x = @x * Math.cos(radians) - @y * Math.sin(radians)
+ new_y = @y * Math.cos(radians) + @x * Math.sin(radians)
+ #self.x = new_x
+ #self.y = new_y
+ #self
+ Vector2d.new( new_x, new_y )
+ end
+
def to_s
# TODO tratar de reducir la cantidad de vectores creados, al
# menos cuando no se está moviendo
#format('%d %.2f, %.2f', object_id, @x, @y)
- format('%.2f, %.2f', @x, @y)
+ format('<%.2f, %.2f>', @x, @y)
end
end
end