Files

65 lines
1.0 KiB
Go
Raw Permalink Normal View History

2016-08-26 09:08:30 -07:00
package main
import (
"fmt"
"s.mcquay.me/dm/rect"
)
func main() {
r := rect.Rectangle{
P1: rect.Point{1, 1},
P2: rect.Point{1, 2},
P3: rect.Point{2, 1},
P4: rect.Point{2, 2},
}
2016-08-27 22:28:15 -07:00
2016-08-26 09:08:30 -07:00
fmt.Println(r.IsRect())
2016-08-27 22:28:15 -07:00
2016-08-26 09:08:30 -07:00
r1 := rect.Rectangle{
2016-08-27 22:28:15 -07:00
P1: rect.Point{1, 1},
P2: rect.Point{1, 2},
P3: rect.Point{2, 1},
P4: rect.Point{2, 2},
}
r2 := rect.Rectangle{
P1: rect.Point{2, 2},
P2: rect.Point{2, 3},
P3: rect.Point{3, 2},
P4: rect.Point{3, 3},
}
fmt.Println(rect.Intersection(r1, r2))
r3 := rect.Rectangle{
2016-08-26 09:08:30 -07:00
P1: rect.Point{0, 0},
2016-08-27 22:28:15 -07:00
P2: rect.Point{0, 3},
P3: rect.Point{3, 0},
P4: rect.Point{3, 3},
2016-08-26 09:08:30 -07:00
}
2016-08-27 22:28:15 -07:00
r4 := rect.Rectangle{
P1: rect.Point{2, 2},
P2: rect.Point{2, 3},
P3: rect.Point{3, 2},
P4: rect.Point{3, 3},
}
fmt.Println(rect.Adjacency(r3, r4))
r5 := rect.Rectangle{
2016-08-26 09:08:30 -07:00
P1: rect.Point{0, 0},
2016-08-27 22:28:15 -07:00
P2: rect.Point{0, 3},
P3: rect.Point{3, 0},
P4: rect.Point{3, 3},
}
r6 := rect.Rectangle{
P1: rect.Point{1, 1},
P2: rect.Point{1, 2},
P3: rect.Point{2, 1},
P4: rect.Point{2, 2},
2016-08-26 09:08:30 -07:00
}
2016-08-27 22:28:15 -07:00
fmt.Println(rect.Containment(r5, r6))
2016-08-26 09:08:30 -07:00
}