2 Star 0 Fork 0

hero/momo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
matrix.go 811 Bytes
一键复制 编辑 原始数据 按行查看 历史
hero 提交于 2024-08-01 15:51 . upd:captcha移动到rbac模块下
/**
* @Author Awen
* @Date 2024/06/01
* @Email wengaolng@gmail.com
**/
package canvas
import "math"
// Matrix .
type Matrix struct {
XX, YX, XY, YY, X0, Y0 float64
}
// Translate is the matrix calculation of translate
func (a Matrix) Translate(x, y float64) Matrix {
return Matrix{
1, 0,
0, 1,
x, y,
}.Multiply(a)
}
// Multiply is the matrix calculation of multiply
func (a Matrix) Multiply(b Matrix) Matrix {
return Matrix{
a.XX*b.XX + a.YX*b.XY,
a.XX*b.YX + a.YX*b.YY,
a.XY*b.XX + a.YY*b.XY,
a.XY*b.YX + a.YY*b.YY,
a.X0*b.XX + a.Y0*b.XY + b.X0,
a.X0*b.YX + a.Y0*b.YY + b.Y0,
}
}
// Rotate is the matrix calculation of rotation
func (a Matrix) Rotate(angle float64) Matrix {
c := math.Cos(angle)
s := math.Sin(angle)
return Matrix{
c, s,
-s, c,
0, 0,
}.Multiply(a)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/linqwen/momo.git
git@gitee.com:linqwen/momo.git
linqwen
momo
momo
v1.7.4

搜索帮助