lib/straightedge/toolkit/rose.rb in straightedge-0.1.1 vs lib/straightedge/toolkit/rose.rb in straightedge-0.1.2
- old
+ new
@@ -5,16 +5,22 @@
def initialize(directions:{})
@directions = directions
end
- def project(point)
+ def orbit(point)
@directions.values.collect do |delta|
Ruler.translate(point, delta)
end
end
+ def orbits(points, depth: 1)
+ return if depth.zero?
+ obs = points.map(&method(:orbit)).flatten(1)
+ (obs + orbits(obs, depth: depth-1)).uniq
+ end
+
class << self
def simple
return @simple_rose unless @simple_rose.nil?
@simple_rose = new directions: {
:north => [0, -1],
@@ -23,9 +29,10 @@
:west => [-1, 0]
}
end
# for hex navigation (nb coords are in cube-space)
+ # TODO use for hex oriented grids
def hexagonal
return @hex_rose unless @hex_rose.nil?
@hex_rose = new directions: {
:north => [1, -1, 0],
:northeast => [0, -1, 1],