wip line tests

This commit is contained in:
Ben Cragg 2019-04-03 11:52:42 +01:00
parent aa7ef59ecd
commit e99ac56daa
2 changed files with 18 additions and 12 deletions

View File

@ -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),

View File

@ -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) {