/*
* 矩阵变换,非切变类NonShear
** 编制人: $ource
* 修改版次及创建时间:0版完成版(2024年8月26日)
* 修改内容及时间:无
* 待完善问题:无
* 内容说明:非切变是平移矩阵*缩放矩阵的产物,实现了“组合矩阵*非切变矩阵”、“平移矩阵*非切变矩阵”、“旋转矩阵*非切变矩阵”、“非切变矩阵*非切变矩阵”、“非切变矩阵*组合矩阵”、“非切变矩阵*平移矩阵”、“非切变矩阵*旋转矩阵”的运算符重载。非切变矩阵格式如下。
1 m01 m02
0 m11 0
0 0 m22
*/
pub type NonShear=Matrix<f64,f64,f64,Zero,Zero,f64>;
impl NonShear{
pub fn new(dx:f64,dy:f64,xx:f64,yy:f64)->NonShear{
NonShear{
m01:dx , m02:dy,
m11:xx , m12:Zero{},
m21:Zero{}, m22:yy
}
}
}
impl Mul<NonShear> for M2D{//“组合矩阵*非切变矩阵”
type Output = M2D;
fn mul(self, tm:NonShear) ->M2D{
M2D{
m01:self.m01 * tm.m11 + tm.m01, m02:self.m02 * tm.m22 + tm.m02,
m11:self.m11 * tm.m11 , m12:self.m12 * tm.m22,
m21:self.m21 * tm.m11 , m22:self.m22 * tm.m22
}
}
}
impl Mul<NonShear> for Move{//“平移矩阵*非切变矩阵”
type Output =NonShear;
fn mul(self, tm:NonShear) ->NonShear{
NonShear::new(self.m01 * tm.m11 + tm.m01, self.m02 * tm.m22 + tm.m02,
tm.m11
, tm.m22
)
}
}
impl Mul<NonShear> for Rotate{//“旋转矩阵*非切变矩阵”
type Output = M2D;
fn mul(self, tm:NonShear) ->M2D{
M2D{
m01:tm.m01 , m02:tm.m02,
m11:self.m11 * tm.m11, m12:self.m12 * tm.m22,
m21:self.m21 * tm.m11, m22:self.m22 * tm.m22
}
}
}
impl Mul<NonShear> for NonShear{//“非切变矩阵*非切变矩阵”
type Output = NonShear;
fn mul(self, tm:NonShear) ->NonShear{
NonShear::new(self.m01 * tm.m11 + tm.m01, self.m02 * tm.m22 + tm.m02,
self.m11 * tm.m11
, self.m22 * tm.m22
)
}
}
impl Mul<M2D> for NonShear{//“非切变矩阵*组合矩阵”
type Output = M2D;
fn mul(self, tm:M2D) ->M2D{
M2D{
m01:self.m01 * tm.m11 + self.m02 * tm.m21 + tm.m01, m02:self.m01 * tm.m12 + self.m02 * tm.m22 + tm.m02,
m11:self.m11 * tm.m11 , m12:self.m11 * tm.m12,
m21:self.m22 * tm.m21 , m22:self.m22 * tm.m22
}
}
}
impl Mul<Move> for NonShear{//“非切变矩阵*平移矩阵”
type Output = NonShear;
fn mul(self, tm:Move) ->NonShear{
NonShear::new(self.m01 + tm.m01, self.m01 + tm.m02,
self.m11
, self.m22
)
}
}
impl Mul<Rotate> for NonShear{//“非切变矩阵*旋转矩阵”
type Output = M2D;
fn mul(self, tm:Rotate) ->M2D{
M2D{
m01:self.m01 * tm.m11 + self.m02 * tm.m21, m02:self.m01 * tm.m12 + self.m02 * tm.m22,
m11:self.m11 * tm.m11 , m12:self.m11 * tm.m12,
m21:self.m22 * tm.m21 , m22:self.m22 * tm.m22
}
}
}
08-18
08-21
08-26
645
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)