Method: PerfectShape::AffineTransform#initialize
- Defined in:
- lib/perfect_shape/affine_transform.rb
#initialize(xxp_element = nil, xyp_element = nil, yxp_element = nil, yyp_element = nil, xt_element = nil, yt_element = nil, xxp: nil, xyp: nil, yxp: nil, yyp: nil, xt: nil, yt: nil, m11: nil, m12: nil, m21: nil, m22: nil, m13: nil, m23: nil) ⇒ AffineTransform
Creates a new AffineTransform with the following Matrix:
- xxp xyp xt
- yxp yyp yt
-
The Matrix is used to transform (x,y) point coordinates as follows:
- xxp xyp xt
- x
-
[ xxp * x + xyp * y + xt ]
- yxp yyp yt
- y
-
[ yxp * x + yyp * y + yt ]
xxp is the x coordinate x product (m11) xyp is the x coordinate y product (m12) yxp is the y coordinate x product (m21) yyp is the y coordinate y product (m22) xt is the x coordinate translation (m13) yt is the y coordinate translation (m23)
The constructor accepts either the (x,y)-operation related argument/kwarg names or traditional Matrix element kwarg names
Example with (x,y)-operation kwarg names:
AffineTransform.new(xxp: 2, xyp: 3, yxp: 4, yyp: 5, xt: 6, yt: 7)
Example with traditional Matrix element kwarg names:
AffineTransform.new(m11: 2, m12: 3, m21: 4, m22: 5, m13: 6, m23: 7)
Example with standard arguments:
AffineTransform.new(2, 3, 4, 5, 6, 7)
If no arguments are supplied, it constructs an identity matrix (i.e. like calling ‘::new(xxp: 1, xyp: 0, yxp: 0, yyp: 1, xt: 0, yt: 0)`)
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/perfect_shape/affine_transform.rb', line 74 def initialize(xxp_element = nil, xyp_element = nil, yxp_element = nil, yyp_element = nil, xt_element = nil, yt_element = nil, xxp: nil, xyp: nil, yxp: nil, yyp: nil, xt: nil, yt: nil, m11: nil, m12: nil, m21: nil, m22: nil, m13: nil, m23: nil) self.xxp = xxp_element || xxp || m11 || 1 self.xyp = xyp_element || xyp || m12 || 0 self.yxp = yxp_element || yxp || m21 || 0 self.yyp = yyp_element || yyp || m22 || 1 self.xt = xt_element || xt || m13 || 0 self.yt = yt_element || yt || m23 || 0 end |