代码拉取完成,页面将自动刷新
/**
* @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)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。