Class: RGeo::Geographic::SphericalMath::ArcXYZ

Inherits:
Object
  • Object
show all
Defined in:
lib/rgeo/geographic/spherical_math.rb

Overview

Represents a finite arc on the sphere.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_, end_) ⇒ ArcXYZ

:nodoc:


172
173
174
175
176
# File 'lib/rgeo/geographic/spherical_math.rb', line 172

def initialize(start_, end_)
  @s = start_
  @e = end_
  @axis = false
end

Instance Attribute Details

#eObject (readonly)

Returns the value of attribute e


180
181
182
# File 'lib/rgeo/geographic/spherical_math.rb', line 180

def e
  @e
end

#sObject (readonly)

Returns the value of attribute s


179
180
181
# File 'lib/rgeo/geographic/spherical_math.rb', line 179

def s
  @s
end

Instance Method Details

#axisObject


200
201
202
203
204
205
# File 'lib/rgeo/geographic/spherical_math.rb', line 200

def axis
  if @axis == false
    @axis = @s % @e
  end
  @axis
end

#contains_point?(obj_) ⇒ Boolean

Returns:

  • (Boolean)

208
209
210
211
212
213
# File 'lib/rgeo/geographic/spherical_math.rb', line 208

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

Returns:

  • (Boolean)

194
195
196
197
# File 'lib/rgeo/geographic/spherical_math.rb', line 194

def degenerate?
  axis_ = axis
  axis_.x == 0 && axis_.y == 0 && axis_.z == 0
end

#eql?(rhs_) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)

188
189
190
# File 'lib/rgeo/geographic/spherical_math.rb', line 188

def eql?(rhs_)
  rhs_.kind_of?(ArcXYZ) && @s == rhs_.s && @e == rhs_.e
end

#intersects_arc?(obj_) ⇒ Boolean

Returns:

  • (Boolean)

216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/rgeo/geographic/spherical_math.rb', line 216

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

#lengthObject


231
232
233
# File 'lib/rgeo/geographic/spherical_math.rb', line 231

def length
  @s.dist_to_point(@e)
end

#to_sObject


183
184
185
# File 'lib/rgeo/geographic/spherical_math.rb', line 183

def to_s
  "#{@s} - #{@e}"
end