diff --git a/README b/README index f8250b7..4e16675 100644 --- a/README +++ b/README @@ -41,12 +41,14 @@ Already implemented algorithms Coming up -========= +========= - * Does polygon contain given point? + * Is polygon convex? * Do polygons intersect? + * Does polygon contain given point? + * Rectangular bounds of polygon * Area of polygon diff --git a/TODO b/TODO new file mode 100644 index 0000000..38a2614 --- /dev/null +++ b/TODO @@ -0,0 +1,35 @@ +== Auxiliary features +* Methods requests tagging + +If algorithm requires some state or property of object, it should be tagged. +Requirements should be checked before each method call (of course, info should +be cached due to computational complexity of algorithms). +Example: + +class Polygon + + def convex? + ... + end + + def self_intersecting? + ... + end + + must_be :convex + must_not_be :self_intersecting + def contains_point?(point) + ... # code, which assumes, that polygon is convex and not self_intersecting + end + +== Algorithms + +* Polygon convexity +* Polygons intersection +* Polygon contains given point? +* Rectangular bounds of polygon +* Area of polygon +* Does circle contain given point? +* Do circles intersect? +* Area of circle +* Making a ruby gem \ No newline at end of file diff --git a/lib/vector.rb b/lib/vector.rb index f35382a..a15c93f 100644 --- a/lib/vector.rb +++ b/lib/vector.rb @@ -32,7 +32,7 @@ def +(vector) end def -(vector) - self + vector * -1 + self + (-1) * vector end def *(scalar) @@ -43,7 +43,7 @@ def coerce(scalar) if scalar.is_a?(Numeric) [self, scalar] else - raise ArgumentError, "Cannot coerce #{scalar.inspect}" + raise ArgumentError, "Vector: cannot coerce #{scalar.inspect}" end end end