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:



133
134
135
136
137
# File 'lib/rgeo/geographic/spherical_math.rb', line 133

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

Instance Attribute Details

#eObject (readonly)

Returns the value of attribute e.



140
141
142
# File 'lib/rgeo/geographic/spherical_math.rb', line 140

def e
  @e
end

#sObject (readonly)

Returns the value of attribute s.



139
140
141
# File 'lib/rgeo/geographic/spherical_math.rb', line 139

def s
  @s
end

Instance Method Details

#axisObject



156
157
158
159
# File 'lib/rgeo/geographic/spherical_math.rb', line 156

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

#contains_point?(obj_) ⇒ Boolean

Returns:

  • (Boolean)


161
162
163
164
165
166
# File 'lib/rgeo/geographic/spherical_math.rb', line 161

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)


151
152
153
154
# File 'lib/rgeo/geographic/spherical_math.rb', line 151

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

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

Returns:

  • (Boolean)


146
147
148
# File 'lib/rgeo/geographic/spherical_math.rb', line 146

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

#intersects_arc?(obj_) ⇒ Boolean

Returns:

  • (Boolean)


168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/rgeo/geographic/spherical_math.rb', line 168

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



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

def length
  @s.dist_to_point(@e)
end

#to_sObject



142
143
144
# File 'lib/rgeo/geographic/spherical_math.rb', line 142

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