Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactor CircularRadius#random_points_within

  • Loading branch information...
commit 94389dd29c385f5c47bf52d94dcdeef11601d878 1 parent ef7f084
@dburt dburt authored
Showing with 2 additions and 20 deletions.
  1. +2 −20 lib/geo_magic/radius/circular.rb
View
22 lib/geo_magic/radius/circular.rb
@@ -28,7 +28,7 @@ def to_s
# Factory
def random_point_within
- max_radius_rad = dist.distance
+ max_radius_rad = distance.distance
range = normalize max_radius_rad
q = rand(range) * PI_2
@@ -40,25 +40,7 @@ def random_point_within
end
def random_points_within number
- conversion = GeoMagic::Distance.radians_ratio(distance.unit)
-
- max_radius_rad = distance.distance
- range = normalize max_radius_rad
-
- max_radius_rad = distance.distance
- range = normalize max_radius_rad
-
- number.times.inject([]) do |res, n|
- q = rand(range) * PI_2
- r = Math.sqrt(rand(range))
-
- dlong = denormalize range * r * Math.cos(q)
- dlat = denormalize range * r * Math.sin(q)
-
- point = GeoMagic::Point.new @center.latitude + dlat, @center.longitude + dlong
- res << point
- res
- end
+ Array.new(number) { random_point_within }
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.