Class: PoissonDiskSampling::Sampler
- Inherits:
-
Object
- Object
- PoissonDiskSampling::Sampler
- Defined in:
- lib/poisson_disk_sampling/sampler.rb
Overview
Generates X randomly distributed points within given 2D space using possion disk sampling
Instance Attribute Summary collapse
-
#num_attempts ⇒ Object
readonly
Returns the value of attribute num_attempts.
-
#sample_area ⇒ Object
readonly
Returns the value of attribute sample_area.
-
#seed ⇒ Object
readonly
Returns the value of attribute seed.
Instance Method Summary collapse
- #generate_points(num_of_points, radius, intial_start_point = nil) ⇒ Object
-
#initialize(sample_area:, num_attempts: 20, seed: rand) ⇒ Sampler
constructor
A new instance of Sampler.
Constructor Details
#initialize(sample_area:, num_attempts: 20, seed: rand) ⇒ Sampler
Returns a new instance of Sampler.
12 13 14 15 16 |
# File 'lib/poisson_disk_sampling/sampler.rb', line 12 def initialize(sample_area:, num_attempts: 20, seed: rand) @sample_area = sample_area @num_attempts = num_attempts @seed = seed end |
Instance Attribute Details
#num_attempts ⇒ Object (readonly)
Returns the value of attribute num_attempts.
10 11 12 |
# File 'lib/poisson_disk_sampling/sampler.rb', line 10 def num_attempts @num_attempts end |
#sample_area ⇒ Object (readonly)
Returns the value of attribute sample_area.
10 11 12 |
# File 'lib/poisson_disk_sampling/sampler.rb', line 10 def sample_area @sample_area end |
#seed ⇒ Object (readonly)
Returns the value of attribute seed.
10 11 12 |
# File 'lib/poisson_disk_sampling/sampler.rb', line 10 def seed @seed end |
Instance Method Details
#generate_points(num_of_points, radius, intial_start_point = nil) ⇒ Object
18 19 20 21 22 |
# File 'lib/poisson_disk_sampling/sampler.rb', line 18 def generate_points(num_of_points, radius, intial_start_point = nil) raise ArgumentError, "invalid start argument #{intial_start_point}" if !intial_start_point.nil? && !intial_start_point.is_a?(Array) && intial_start_point.length != 1 retreive_points_until_active_list_empty_or_num_points_reached(intial_start_point || generate_and_assign_initial_point, num_of_points, radius) end |