Skip to content

Commit f810c44

Browse files
committed
Update docs
1 parent 08275d1 commit f810c44

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ type Point[T Number] struct{
4747
// Properties
4848
func (p Point[T]) XY() (T, T)
4949

50+
// Transformations
51+
func (p Point[T]) Transform(matrix Matrix) Point[T]
52+
5053
// Mathematical operations
5154
func (p Point[T]) Add(vector Vector[T]) Point[T]
5255
func (p Point[T]) AddXY(deltaX, deltaY T) Point[T]
@@ -66,6 +69,7 @@ func (p Point[T]) AngleTo(point Point[T]) float64
6669
// Utilities
6770
func (p Point[T]) Equal(point Point[T]) bool
6871
func (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
7983
func (v Vector[T]) XY() (T, T)
8084

85+
// Transformations
86+
func (v Vector[T]) Transform(matrix Matrix) Vector[T]
87+
8188
// Mathematical operations
8289
func (v Vector[T]) Add(vector Vector[T]) Vector[T]
8390
func (v Vector[T]) AddXY(deltaX, deltaY T) Vector[T]
@@ -111,6 +118,30 @@ func (v Vector[T]) Less(value T) bool
111118
func (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]
280312
func (rp RegularPolygon[T]) MoveTo(center Point[T]) RegularPolygon[T]
281313
func (rp RegularPolygon[T]) Scale(factor float64) RegularPolygon[T]
282314
func (rp RegularPolygon[T]) ScaleXY(factorX, factorY float64) RegularPolygon[T]
315+
func (rp RegularPolygon[T]) Rotate(angle float64) RegularPolygon[T]
283316

284317
// Utilities
285318
func (rp RegularPolygon[T]) Equal(polygon RegularPolygon[T]) bool
@@ -300,7 +333,8 @@ func S[T Number](w, h T) Size[T]
300333
func C[T Number](center Point[T], radius T) Circle[T]
301334
func R[T Number](center Point[T], size Size[T]) Rectangle[T]
302335
func 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

matrix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ func (m Matrix) Scale(factorX, factorY float64) Matrix {
6767
}
6868

6969
// Equal checks for equal values.
70-
func (m Matrix) Equal(other Matrix) bool {
71-
return Equal(m.A, other.A) && Equal(m.B, other.B) && Equal(m.C, other.C) && Equal(m.D, other.D) && Equal(m.E, other.E) && Equal(m.F, other.F)
70+
func (m Matrix) Equal(matrix Matrix) bool {
71+
return Equal(m.A, matrix.A) && Equal(m.B, matrix.B) && Equal(m.C, matrix.C) && Equal(m.D, matrix.D) && Equal(m.E, matrix.E) && Equal(m.F, matrix.F)
7272
}
7373

7474
// IsZero checks if values are zero.

0 commit comments

Comments
 (0)