From e99ac56daa9ecf5446670c8ae31198268d6cfbef Mon Sep 17 00:00:00 2001 From: Ben Cragg Date: Wed, 3 Apr 2019 11:52:42 +0100 Subject: [PATCH] wip line tests --- geometry.go | 6 ++++++ geometry_test.go | 24 ++++++++++++------------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/geometry.go b/geometry.go index 9872b74..41d2b4c 100644 --- a/geometry.go +++ b/geometry.go @@ -402,6 +402,12 @@ func (l Line) Moved(delta Vec) Line { func (l Line) Rotated(around Vec, angle float64) Line { // Move the line so we can use `Vec.Rotated` lineShifted := l.Moved(around.Scaled(-1)) + + fmt.Println(around.Scaled(-1)) + fmt.Println(lineShifted) + fmt.Println(lineShifted.A.Rotated(angle)) + fmt.Println(lineShifted.B.Rotated(angle)) + lineRotated := Line{ A: lineShifted.A.Rotated(angle), B: lineShifted.B.Rotated(angle), diff --git a/geometry_test.go b/geometry_test.go index 86f3a45..2a08e5c 100644 --- a/geometry_test.go +++ b/geometry_test.go @@ -1216,24 +1216,24 @@ func TestLine_Rotated(t *testing.T) { args args want pixel.Line }{ - { - name: "Rotating around line center", - fields: fields{A: pixel.V(1, 1), B: pixel.V(3, 3)}, - args: args{around: pixel.V(2, 2), angle: 2 * math.Pi}, - want: pixel.L(pixel.V(1, 1), pixel.V(3, 3)), - }, + // { + // name: "Rotating around line center", + // fields: fields{A: pixel.V(1, 1), B: pixel.V(3, 3)}, + // args: args{around: pixel.V(2, 2), angle: 2 * math.Pi}, + // want: pixel.L(pixel.V(1, 1), pixel.V(3, 3)), + // }, { name: "Rotating around x-y origin", fields: fields{A: pixel.V(1, 1), B: pixel.V(3, 3)}, args: args{around: pixel.V(0, 0), angle: 2 * math.Pi}, want: pixel.L(pixel.V(-1, -1), pixel.V(-3, -3)), }, - { - name: "Rotating around line end", - fields: fields{A: pixel.V(1, 1), B: pixel.V(3, 3)}, - args: args{around: pixel.V(1, 1), angle: 2 * math.Pi}, - want: pixel.L(pixel.V(1, 1), pixel.V(-2, -2)), - }, + // { + // name: "Rotating around line end", + // fields: fields{A: pixel.V(1, 1), B: pixel.V(3, 3)}, + // args: args{around: pixel.V(1, 1), angle: 2 * math.Pi}, + // want: pixel.L(pixel.V(1, 1), pixel.V(-2, -2)), + // }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {