I know that it can be found on Google but I tried all that I could find and I kept getting errors/bugs.
In my circle class I have a function with this code:
# rect = rectangle.# @x & @y are the origin coordinates of the circle. x = rect.right if @x > rect.right x = rect.left if @x < rect.left y = rect.bottom if @y > rect.bottom y = rect.top if @y < rect.top return Point.new(x,y).distance(origin) < @radiusPoint-class Distance implementation:
def distance(other_point) Math.hypot(other_point.x - @x, other_point.y - @y) endIt does not always work as expected (unless I tested wrong which is possible).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.