Class: RGeo::Geographic::SphericalMath::ArcXYZ
- Inherits:
-
Object
- Object
- RGeo::Geographic::SphericalMath::ArcXYZ
- Defined in:
- lib/rgeo/geographic/spherical_math.rb
Overview
Represents a finite arc on the sphere.
Instance Attribute Summary collapse
-
#e ⇒ Object
readonly
Returns the value of attribute e.
-
#s ⇒ Object
readonly
Returns the value of attribute s.
Instance Method Summary collapse
- #axis ⇒ Object
- #contains_point?(obj_) ⇒ Boolean
- #degenerate? ⇒ Boolean
- #eql?(rhs_) ⇒ Boolean (also: #==)
-
#initialize(start_, end_) ⇒ ArcXYZ
constructor
:nodoc:.
- #intersects_arc?(obj_) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(start_, end_) ⇒ ArcXYZ
:nodoc:
140 141 142 143 144 |
# File 'lib/rgeo/geographic/spherical_math.rb', line 140 def initialize(start_, end_) @s = start_ @e = end_ @axis = false end |
Instance Attribute Details
#e ⇒ Object (readonly)
Returns the value of attribute e.
148 149 150 |
# File 'lib/rgeo/geographic/spherical_math.rb', line 148 def e @e end |
#s ⇒ Object (readonly)
Returns the value of attribute s.
147 148 149 |
# File 'lib/rgeo/geographic/spherical_math.rb', line 147 def s @s end |
Instance Method Details
#axis ⇒ Object
168 169 170 171 172 173 |
# File 'lib/rgeo/geographic/spherical_math.rb', line 168 def axis if @axis == false @axis = @s % @e end @axis end |
#contains_point?(obj_) ⇒ Boolean
176 177 178 179 180 181 |
# File 'lib/rgeo/geographic/spherical_math.rb', line 176 def contains_point?(obj_) axis_ = axis saxis_ = ArcXYZ.new(@s, obj_).axis eaxis_ = ArcXYZ.new(obj_, @e).axis !saxis_ || !eaxis_ || obj_ * axis_ == 0.0 && saxis_ * axis_ > 0 && eaxis_ * axis_ > 0 end |
#degenerate? ⇒ Boolean
162 163 164 165 |
# File 'lib/rgeo/geographic/spherical_math.rb', line 162 def degenerate? axis_ = axis axis_.x == 0 && axis_.y == 0 && axis_.z == 0 end |
#eql?(rhs_) ⇒ Boolean Also known as: ==
156 157 158 |
# File 'lib/rgeo/geographic/spherical_math.rb', line 156 def eql?(rhs_) rhs_.kind_of?(ArcXYZ) && @s == rhs_.s && @e == rhs_.e end |
#intersects_arc?(obj_) ⇒ Boolean
184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/rgeo/geographic/spherical_math.rb', line 184 def intersects_arc?(obj_) my_axis_ = axis dot1_ = my_axis_ * obj_.s dot2_ = my_axis_ * obj_.e if dot1_ >= 0.0 && dot2_ <= 0.0 || dot1_ <= 0.0 && dot2_ >= 0.0 ob_axis_ = obj_.axis dot1_ = ob_axis_ * @s dot2_ = ob_axis_ * @e dot1_ >= 0.0 && dot2_ <= 0.0 || dot1_ <= 0.0 && dot2_ >= 0.0 else false end end |
#to_s ⇒ Object
151 152 153 |
# File 'lib/rgeo/geographic/spherical_math.rb', line 151 def to_s "#{@s} - #{@e}" end |