Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- At=Struct.new(:al, :bl, :a, :b) do
- def initialize
- super
- self.b ||= self.a
- end
- def +(other)
- At.new(
- self.al + other.al,
- self.bl + other.bl,
- self.a + other.a,
- self.b + other.b
- )
- end
- def -(other)
- At.new(
- self.al + other.al,
- self.bl + other.bl,
- self.a - other.a,
- self.b - other.b
- )
- end
- def *(other)
- At.new(
- self.a * other.al + other.a * self.al,
- self.b * other.bl + other.b * self.bl,
- self.a * other.a,
- self.b * other.b
- )
- end
- def /(other)
- At.new(
- ((self.a * other.bl + other.b * self.al) / (other.b**2)).round(2).inspect,
- ((self.b * other.al + other.a * self.bl) / (other.a**2)).round(2),
- (self.a / other.b).round(2),
- (self.b / other.a).round(2)
- )
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement