2023-05-28 19:14:02 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/surdeus/gox/src/gx"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
lines := []gx.Line{
|
|
|
|
gx.LineSegment{
|
|
|
|
gx.Point{0, 1},
|
|
|
|
gx.Point{1, 2},
|
|
|
|
}.Line(),
|
|
|
|
gx.LineSegment{
|
|
|
|
gx.Point{0, 5},
|
|
|
|
gx.Point{1, 2},
|
|
|
|
}.Line(),
|
|
|
|
gx.LineSegment{
|
|
|
|
gx.Point{-1, -1},
|
|
|
|
gx.Point{1, 50},
|
|
|
|
}.Line(),
|
|
|
|
}
|
|
|
|
|
2023-05-28 19:45:58 +03:00
|
|
|
for _, l := range lines { fmt.Println(l) }
|
2023-05-28 20:02:07 +03:00
|
|
|
|
|
|
|
l1 := gx.LineSegment{
|
|
|
|
gx.Point{0, 0},
|
|
|
|
gx.Point{1, 1},
|
|
|
|
}.Line()
|
|
|
|
|
|
|
|
l2 := gx.LineSegment{
|
|
|
|
gx.Point{0, 1},
|
2023-05-28 21:07:05 +03:00
|
|
|
gx.Point{1, 0},
|
2023-05-28 20:02:07 +03:00
|
|
|
}.Line()
|
2023-05-28 21:07:05 +03:00
|
|
|
fmt.Println(l1.Crosses(l2))
|
2023-05-28 21:22:52 +03:00
|
|
|
fmt.Println(l1.ContainsPoint(gx.Point{1, 4}))
|
2023-05-30 13:12:11 +03:00
|
|
|
|
|
|
|
t := gx.Triangle{
|
2023-05-28 19:14:02 +03:00
|
|
|
gx.Point{0, 0},
|
|
|
|
gx.Point{0, 100},
|
|
|
|
gx.Point{100, 0},
|
|
|
|
}
|
|
|
|
|
|
|
|
points := []gx.Point{
|
|
|
|
gx.Point{},
|
2023-05-30 13:12:11 +03:00
|
|
|
gx.Point{100, 0},
|
|
|
|
gx.Point{0, 100},
|
2023-05-28 19:14:02 +03:00
|
|
|
gx.Point{.1, .1},
|
|
|
|
gx.Point{-1, -1},
|
|
|
|
gx.Point{1, 1},
|
|
|
|
gx.Point{101, 1},
|
|
|
|
gx.Point{100, 1},
|
|
|
|
gx.Point{50, 1},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, p := range points {
|
2023-05-30 13:12:11 +03:00
|
|
|
fmt.Println(t, p, t.ContainsPoint(p))
|
|
|
|
}
|
2023-05-28 19:14:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|