Class: Emf::Model::Geometry::Matrix
- Inherits:
-
Object
- Object
- Emf::Model::Geometry::Matrix
- Defined in:
- lib/emf/model/geometry/matrix.rb
Constant Summary collapse
- IDENTITY =
{ m11: 1.0, m12: 0.0, m21: 0.0, m22: 1.0, dx: 0.0, dy: 0.0 }.freeze
Instance Attribute Summary collapse
-
#dx ⇒ Object
readonly
Returns the value of attribute dx.
-
#dy ⇒ Object
readonly
Returns the value of attribute dy.
-
#m11 ⇒ Object
readonly
Returns the value of attribute m11.
-
#m12 ⇒ Object
readonly
Returns the value of attribute m12.
-
#m21 ⇒ Object
readonly
Returns the value of attribute m21.
-
#m22 ⇒ Object
readonly
Returns the value of attribute m22.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
- #identity? ⇒ Boolean
-
#initialize(m11:, m12:, m21:, m22:, dx:, dy:) ⇒ Matrix
constructor
A new instance of Matrix.
- #to_wire ⇒ Object
Constructor Details
#initialize(m11:, m12:, m21:, m22:, dx:, dy:) ⇒ Matrix
Returns a new instance of Matrix.
11 12 13 14 15 16 17 18 |
# File 'lib/emf/model/geometry/matrix.rb', line 11 def initialize(m11:, m12:, m21:, m22:, dx:, dy:) @m11 = m11.to_f @m12 = m12.to_f @m21 = m21.to_f @m22 = m22.to_f @dx = dx.to_f @dy = dy.to_f end |
Instance Attribute Details
#dx ⇒ Object (readonly)
Returns the value of attribute dx.
20 21 22 |
# File 'lib/emf/model/geometry/matrix.rb', line 20 def dx @dx end |
#dy ⇒ Object (readonly)
Returns the value of attribute dy.
20 21 22 |
# File 'lib/emf/model/geometry/matrix.rb', line 20 def dy @dy end |
#m11 ⇒ Object (readonly)
Returns the value of attribute m11.
20 21 22 |
# File 'lib/emf/model/geometry/matrix.rb', line 20 def m11 @m11 end |
#m12 ⇒ Object (readonly)
Returns the value of attribute m12.
20 21 22 |
# File 'lib/emf/model/geometry/matrix.rb', line 20 def m12 @m12 end |
#m21 ⇒ Object (readonly)
Returns the value of attribute m21.
20 21 22 |
# File 'lib/emf/model/geometry/matrix.rb', line 20 def m21 @m21 end |
#m22 ⇒ Object (readonly)
Returns the value of attribute m22.
20 21 22 |
# File 'lib/emf/model/geometry/matrix.rb', line 20 def m22 @m22 end |
Class Method Details
.from_wire(wire) ⇒ Object
22 23 24 |
# File 'lib/emf/model/geometry/matrix.rb', line 22 def self.from_wire(wire) new(m11: wire.m11, m12: wire.m12, m21: wire.m21, m22: wire.m22, dx: wire.dx, dy: wire.dy) end |
.identity ⇒ Object
30 31 32 |
# File 'lib/emf/model/geometry/matrix.rb', line 30 def self.identity new(**IDENTITY) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
38 39 40 41 42 43 |
# File 'lib/emf/model/geometry/matrix.rb', line 38 def ==(other) other.is_a?(self.class) && m11 == other.m11 && m12 == other.m12 && m21 == other.m21 && m22 == other.m22 && dx == other.dx && dy == other.dy end |
#hash ⇒ Object
46 47 48 |
# File 'lib/emf/model/geometry/matrix.rb', line 46 def hash [self.class, m11, m12, m21, m22, dx, dy].hash end |
#identity? ⇒ Boolean
34 35 36 |
# File 'lib/emf/model/geometry/matrix.rb', line 34 def identity? m11 == 1.0 && m12 == 0.0 && m21 == 0.0 && m22 == 1.0 && dx == 0.0 && dy == 0.0 end |