Class: EightCorner::Point
- Inherits:
-
Object
- Object
- EightCorner::Point
- Defined in:
- lib/eight_corner/point.rb
Overview
A point on a 2D plane.
Instance Attribute Summary collapse
-
#angle_from_last ⇒ Object
Returns the value of attribute angle_from_last.
-
#angle_pct ⇒ Object
Returns the value of attribute angle_pct.
-
#bounds ⇒ Object
Returns the value of attribute bounds.
-
#created_by_potential ⇒ Object
Returns the value of attribute created_by_potential.
-
#distance_from_last ⇒ Object
Returns the value of attribute distance_from_last.
-
#distance_pct ⇒ Object
Returns the value of attribute distance_pct.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #angle_range ⇒ Object
-
#initialize(x = nil, y = nil) ⇒ Point
constructor
A new instance of Point.
- #max ⇒ Object
- #max_is ⇒ Object
-
#potential ⇒ Object
a single % value based on the data in this point used as an input for another Base#plot call TODO: what is distribution of values of this function? we want something reasonably gaussian, i think.
-
#quadrant ⇒ Object
which quadrant of the Bounds is this point in?.
- #valid? ⇒ Boolean
Constructor Details
#initialize(x = nil, y = nil) ⇒ Point
Returns a new instance of Point.
20 21 22 23 |
# File 'lib/eight_corner/point.rb', line 20 def initialize(x=nil, y=nil) @x = x @y = y end |
Instance Attribute Details
#angle_from_last ⇒ Object
Returns the value of attribute angle_from_last.
6 7 8 |
# File 'lib/eight_corner/point.rb', line 6 def angle_from_last @angle_from_last end |
#angle_pct ⇒ Object
Returns the value of attribute angle_pct.
6 7 8 |
# File 'lib/eight_corner/point.rb', line 6 def angle_pct @angle_pct end |
#bounds ⇒ Object
Returns the value of attribute bounds.
6 7 8 |
# File 'lib/eight_corner/point.rb', line 6 def bounds @bounds end |
#created_by_potential ⇒ Object
Returns the value of attribute created_by_potential.
6 7 8 |
# File 'lib/eight_corner/point.rb', line 6 def created_by_potential @created_by_potential end |
#distance_from_last ⇒ Object
Returns the value of attribute distance_from_last.
6 7 8 |
# File 'lib/eight_corner/point.rb', line 6 def distance_from_last @distance_from_last end |
#distance_pct ⇒ Object
Returns the value of attribute distance_pct.
6 7 8 |
# File 'lib/eight_corner/point.rb', line 6 def distance_pct @distance_pct end |
#x ⇒ Object
Returns the value of attribute x.
6 7 8 |
# File 'lib/eight_corner/point.rb', line 6 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
6 7 8 |
# File 'lib/eight_corner/point.rb', line 6 def y @y end |
Instance Method Details
#==(other) ⇒ Object
55 56 57 |
# File 'lib/eight_corner/point.rb', line 55 def ==(other) x == other.x && y == other.y end |
#angle_range ⇒ Object
31 32 33 |
# File 'lib/eight_corner/point.rb', line 31 def angle_range Quadrant.angle_range_for(quadrant) end |
#max ⇒ Object
47 48 49 |
# File 'lib/eight_corner/point.rb', line 47 def max [@x,@y].max end |
#max_is ⇒ Object
51 52 53 |
# File 'lib/eight_corner/point.rb', line 51 def max_is @x > @y ? :x : :y end |
#potential ⇒ Object
a single % value based on the data in this point used as an input for another Base#plot call TODO: what is distribution of values of this function? we want something reasonably gaussian, i think.
w/o created_by_potential, rearranging the initial string in a series of figures alters the first 10 figures or so, and then they eventually converge back to being identical. (The ~11th figure shows no dependence on this initial change in ordering.)
43 44 45 |
# File 'lib/eight_corner/point.rb', line 43 def potential (x/bounds.x.to_f + y/bounds.y.to_f + distance_pct.to_f + angle_pct.to_f + created_by_potential.to_f) % 1 end |
#quadrant ⇒ Object
which quadrant of the Bounds is this point in?
26 27 28 29 |
# File 'lib/eight_corner/point.rb', line 26 def quadrant raise "cannot calculate quadrant. bounds is nil" if bounds.nil? @quadrant ||= bounds.quadrant(self) end |
#valid? ⇒ Boolean
59 60 61 |
# File 'lib/eight_corner/point.rb', line 59 def valid? x >= 0 && y >= 0 && x <= bounds.x && y <= bounds.y end |