Permalink
Browse files

Merge pull request #2 from dburt/refactoring

This is a fix for the same set of warnings on the refactoring branch
  • Loading branch information...
2 parents ab03906 + 94389dd commit 269c948ff27f5003183e8f243a7f435a021b45e7 @kristianmandrup committed Jun 2, 2011
Showing with 4 additions and 22 deletions.
  1. +4 −22 lib/geo_magic/radius/circular.rb
@@ -28,37 +28,19 @@ 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
r = Math.sqrt(rand(range))
- dlong = denormalize (range * r) * Math.cos(q)
- dlat = denormalize (range * r) * Math.sin(q)
+ dlong = denormalize range * r * Math.cos(q)
+ dlat = denormalize range * r * Math.sin(q)
GeoMagic::Point.new @center.latitude + dlat, @center.longitude + dlong
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

0 comments on commit 269c948

Please sign in to comment.