Module: StraightSkeleton::Node
- Included in:
- InteriorNode, Vertex
- Defined in:
- lib/nswtopo/geometry/straight_skeleton/node.rb
Instance Attribute Summary collapse
-
#neighbours ⇒ Object
readonly
Returns the value of attribute neighbours.
-
#normals ⇒ Object
readonly
Returns the value of attribute normals.
-
#original ⇒ Object
readonly
Returns the value of attribute original.
-
#point ⇒ Object
readonly
Returns the value of attribute point.
-
#travel ⇒ Object
readonly
Returns the value of attribute travel.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #index ⇒ Object
- #next ⇒ Object
- #prev ⇒ Object
-
#project(travel) ⇒ Object
########################################### solve for vector p: n0.(p - @point) = travel - @travel n1.(p - @point) = travel - @travel ###########################################.
- #reflex? ⇒ Boolean
- #splits? ⇒ Boolean
- #terminal? ⇒ Boolean
Instance Attribute Details
#neighbours ⇒ Object (readonly)
Returns the value of attribute neighbours.
3 4 5 |
# File 'lib/nswtopo/geometry/straight_skeleton/node.rb', line 3 def neighbours @neighbours end |
#normals ⇒ Object (readonly)
Returns the value of attribute normals.
3 4 5 |
# File 'lib/nswtopo/geometry/straight_skeleton/node.rb', line 3 def normals @normals end |
#original ⇒ Object (readonly)
Returns the value of attribute original.
3 4 5 |
# File 'lib/nswtopo/geometry/straight_skeleton/node.rb', line 3 def original @original end |
#point ⇒ Object (readonly)
Returns the value of attribute point.
3 4 5 |
# File 'lib/nswtopo/geometry/straight_skeleton/node.rb', line 3 def point @point end |
#travel ⇒ Object (readonly)
Returns the value of attribute travel.
3 4 5 |
# File 'lib/nswtopo/geometry/straight_skeleton/node.rb', line 3 def travel @travel end |
Instance Method Details
#active? ⇒ Boolean
5 6 7 |
# File 'lib/nswtopo/geometry/straight_skeleton/node.rb', line 5 def active? @nodes.include? self end |
#index ⇒ Object
29 30 31 |
# File 'lib/nswtopo/geometry/straight_skeleton/node.rb', line 29 def index @index ||= @nodes.index self end |
#next ⇒ Object
25 26 27 |
# File 'lib/nswtopo/geometry/straight_skeleton/node.rb', line 25 def next @neighbours[1] end |
#prev ⇒ Object
21 22 23 |
# File 'lib/nswtopo/geometry/straight_skeleton/node.rb', line 21 def prev @neighbours[0] end |
#project(travel) ⇒ Object
########################################### solve for vector p:
n0.(p - @point) = travel - @travel
n1.(p - @point) = travel - @travel
###########################################
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nswtopo/geometry/straight_skeleton/node.rb', line 39 def project(travel) det = normals.inject(&:cross) if normals.all? case when det&.nonzero? x = normals.map { |normal| travel - @travel + normal.dot(point) } (normals[0].perp * x[1] - normals[1].perp * x[0]) / det when normals[0] then normals[0] * (travel - @travel) + point when normals[1] then normals[1] * (travel - @travel) + point end end |
#reflex? ⇒ Boolean
13 14 15 |
# File 'lib/nswtopo/geometry/straight_skeleton/node.rb', line 13 def reflex? normals.inject(&:cross) * @nodes.direction <= 0 end |
#splits? ⇒ Boolean
17 18 19 |
# File 'lib/nswtopo/geometry/straight_skeleton/node.rb', line 17 def splits? terminal? || reflex? end |
#terminal? ⇒ Boolean
9 10 11 |
# File 'lib/nswtopo/geometry/straight_skeleton/node.rb', line 9 def terminal? @neighbours.one? end |