Skip to content

Instantly share code, notes, and snippets.

@benwilson512
Created June 13, 2012 02:25
Show Gist options
  • Save benwilson512/2921439 to your computer and use it in GitHub Desktop.
Save benwilson512/2921439 to your computer and use it in GitHub Desktop.
accoustics
class Device
attr_accessor :measurements
def initialize
@measurements = []
end
end
class Measurement
attr_accessor :frequency, :points, :magnitudes
def initialize
@points = []
@magnitudes = []
end
end
class Point
attr_accessor :x, :y, :z
def initialize(x, y, z)
@x = x
@y = y
@z = z
end
def to_magnitude
Magnitude.new @x.magnitude, @y.magnitude, @z.magnitude
end
end
class Magnitude
attr_accessor :x, :y, :z
def initialize(x, y, z)
@x = x
@y = y
@z = z
end
end
device1 = Device.new
device1_frequencies = (70...120)
device1_xs = device1_frequencies.map {|f| Complex(rand(f), rand(f)) }
device1_ys = device1_frequencies.map {|f| Complex(rand(f), rand(f)) }
device1_zs = device1_frequencies.map {|f| Complex(rand(f), rand(f)) }
point1 = Point.new(Complex(1,2), Complex(3,5), Complex(11,21))
device1_frequencies.each_with_index do |frequency, index|
measurement = Measurement.new
point = Point.new device1_xs[index], device1_ys[index], device1_zs[index]
measurement.points << point
device1.easurements << measurement
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment