module StraightSkeleton::Node
Attributes
neighbours[R]
normals[R]
original[R]
point[R]
travel[R]
Public Instance Methods
active?()
click to toggle source
# File lib/nswtopo/geometry/straight_skeleton/node.rb, line 5 def active? @nodes.include? self end
index()
click to toggle source
# File lib/nswtopo/geometry/straight_skeleton/node.rb, line 29 def index @index ||= @nodes.index self end
next()
click to toggle source
# File lib/nswtopo/geometry/straight_skeleton/node.rb, line 25 def next @neighbours[1] end
prev()
click to toggle source
# File lib/nswtopo/geometry/straight_skeleton/node.rb, line 21 def prev @neighbours[0] end
project(travel)
click to toggle source
########################################### solve for vector p:
n0.(p - @point) = travel - @travel n1.(p - @point) = travel - @travel
###########################################
# File lib/nswtopo/geometry/straight_skeleton/node.rb, line 39 def project(travel) det = normals.inject(&:cross) if normals.all? case when det && det.nonzero? x = normals.map { |normal| travel - @travel + normal.dot(point) } [normals[1][1] * x[0] - normals[0][1] * x[1], normals[0][0] * x[1] - normals[1][0] * x[0]] / det when normals[0] then normals[0].times(travel - @travel).plus(point) when normals[1] then normals[1].times(travel - @travel).plus(point) end end
reflex?()
click to toggle source
# File lib/nswtopo/geometry/straight_skeleton/node.rb, line 13 def reflex? normals.inject(&:cross) * @nodes.direction <= 0 end
splits?()
click to toggle source
# File lib/nswtopo/geometry/straight_skeleton/node.rb, line 17 def splits? terminal? || reflex? end
terminal?()
click to toggle source
# File lib/nswtopo/geometry/straight_skeleton/node.rb, line 9 def terminal? @neighbours.one? end