Class: Surface
Instance Attribute Summary collapse
-
#normal ⇒ Object
Returns the value of attribute normal.
-
#p ⇒ Object
Returns the value of attribute p.
-
#tol ⇒ Object
Returns the value of attribute tol.
Instance Method Summary collapse
- #above?(p, tol = @tol) ⇒ Boolean
- #below?(p, tol = @tol) ⇒ Boolean
- #dist(p) ⇒ Object
- #include?(p, tol = @tol) ⇒ Boolean
-
#initialize(v, p, tol = 0) ⇒ Surface
constructor
A new instance of Surface.
- #move!(v) ⇒ Object
- #rotate!(d, o, a) ⇒ Object
Constructor Details
Instance Attribute Details
#normal ⇒ Object
Returns the value of attribute normal.
3 4 5 |
# File 'lib/lib/surface/surface.rb', line 3 def normal @normal end |
#p ⇒ Object
Returns the value of attribute p.
3 4 5 |
# File 'lib/lib/surface/surface.rb', line 3 def p @p end |
#tol ⇒ Object
Returns the value of attribute tol.
2 3 4 |
# File 'lib/lib/surface/surface.rb', line 2 def tol @tol end |
Instance Method Details
#above?(p, tol = @tol) ⇒ Boolean
11 12 13 |
# File 'lib/lib/surface/surface.rb', line 11 def above? p, tol = @tol dist(p) + tol < 0 end |
#below?(p, tol = @tol) ⇒ Boolean
14 15 16 |
# File 'lib/lib/surface/surface.rb', line 14 def below? p, tol = @tol dist(p) - tol > 0 end |
#dist(p) ⇒ Object
20 21 22 23 |
# File 'lib/lib/surface/surface.rb', line 20 def dist p p = p.pos if p.is_a? Atom (p.to_v- @p).to_a * @normal / @normal.magnitude end |
#include?(p, tol = @tol) ⇒ Boolean
17 18 19 |
# File 'lib/lib/surface/surface.rb', line 17 def include? p, tol = @tol dist(p).abs <= tol end |
#move!(v) ⇒ Object
27 28 29 |
# File 'lib/lib/surface/surface.rb', line 27 def move! v @p += v.to_v end |
#rotate!(d, o, a) ⇒ Object
24 25 26 |
# File 'lib/lib/surface/surface.rb', line 24 def rotate! d,o,a @normal = @normal.rotate!(d.to_v,o.to_v,a) end |