@@ -47,6 +47,9 @@ type Point[T Number] struct{
4747// Properties
4848func (p Point [T ]) XY () (T , T )
4949
50+ // Transformations
51+ func (p Point[T]) Transform(matrix Matrix) Point[T]
52+
5053// Mathematical operations
5154func (p Point[T]) Add(vector Vector[T]) Point[T]
5255func (p Point[T]) AddXY(deltaX, deltaY T) Point[T]
@@ -66,6 +69,7 @@ func (p Point[T]) AngleTo(point Point[T]) float64
6669// Utilities
6770func (p Point[T]) Equal(point Point[T]) bool
6871func (p Point[T]) IsZero() bool
72+ func (p Point[T]) String() string
6973```
7074
7175### Vector
@@ -78,6 +82,9 @@ type Vector[T Number] struct {
7882// Properties
7983func (v Vector [T ]) XY () (T , T )
8084
85+ // Transformations
86+ func (v Vector[T]) Transform(matrix Matrix) Vector[T]
87+
8188// Mathematical operations
8289func (v Vector[T]) Add(vector Vector[T]) Vector[T]
8390func (v Vector[T]) AddXY(deltaX, deltaY T) Vector[T]
@@ -111,6 +118,30 @@ func (v Vector[T]) Less(value T) bool
111118func (v Vector[T]) String() string
112119```
113120
121+ ### Matrix
122+
123+ ```go
124+ type Matrix struct {
125+ A, B, C float64 // scale X, shear Y, translate X
126+ D, E, F float64 // shear X, scale Y, translate Y
127+ // [0 0 1] implicit third row
128+ }
129+
130+ // Operations
131+ func (m Matrix ) Multiply (n Matrix ) Matrix
132+ func (m Matrix) Inverse() Matrix
133+ func (m Matrix) Determinant() float64
134+
135+ // Transform builders
136+ func (m Matrix) Translate(deltaX, deltaY float64) Matrix
137+ func (m Matrix) Rotate(angle float64) Matrix
138+ func (m Matrix) Scale(factorX, factorY float64) Matrix
139+
140+ // Utilities
141+ func (m Matrix) Equal(matrix Matrix) bool
142+ func (m Matrix) IsZero() bool
143+ ```
144+
114145### Size
115146
116147```go
@@ -270,6 +301,7 @@ type RegularPolygon[T Number] struct {
270301 Center Point[T]
271302 Size Size[T]
272303 N int
304+ Angle float64
273305}
274306
275307// Properties
@@ -280,6 +312,7 @@ func (rp RegularPolygon[T]) Translate(vector Vector[T]) RegularPolygon[T]
280312func (rp RegularPolygon[T]) MoveTo(center Point[T]) RegularPolygon[T]
281313func (rp RegularPolygon[T]) Scale(factor float64) RegularPolygon[T]
282314func (rp RegularPolygon[T]) ScaleXY(factorX, factorY float64) RegularPolygon[T]
315+ func (rp RegularPolygon[T]) Rotate(angle float64) RegularPolygon[T]
283316
284317// Utilities
285318func (rp RegularPolygon[T]) Equal(polygon RegularPolygon[T]) bool
@@ -300,7 +333,8 @@ func S[T Number](w, h T) Size[T]
300333func C[T Number](center Point[T], radius T) Circle[T]
301334func R[T Number](center Point[T], size Size[T]) Rectangle[T]
302335func L[T Number](start, end Point[T]) Line[T]
303- func RP[T Number](center Point[T], size Size[T], n int) RegularPolygon[T]
336+ func RP[T Number](center Point[T], size Size[T], n int, angle float64) RegularPolygon[T]
337+ func M(a, b, c, d, e, f float64) Matrix
304338```
305339
306340
0 commit comments