gg/src/cmd/math/main.go

76 lines
1.2 KiB
Go
Raw Normal View History

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) }
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},
}.Line()
2023-06-03 12:26:31 +03:00
fmt.Println(gx.LinersCross(l1, l2))
2023-05-28 21:22:52 +03:00
fmt.Println(l1.ContainsPoint(gx.Point{1, 4}))
angle := gx.LinersAngle(l1, l2)
fmt.Println("angle:", angle, gx.RadiansToDegrees(angle))
2023-05-30 14:34:10 +03:00
t := gx.Rectangle{
Transform: gx.Transform{
S: gx.Vector{100, 200},
2023-05-30 14:34:10 +03:00
P: gx.Point{0, 200},
RA: gx.Point{0, 0},
R: 0,
2023-05-30 14:34:10 +03:00
},
2023-05-28 19:14:02 +03:00
}
points := []gx.Point{
gx.Point{},
gx.Point{100, 0},
2023-05-30 14:34:10 +03:00
gx.Point{0, 99},
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},
}
2023-05-30 14:34:10 +03:00
ts := t.Triangles()
t1 := ts[0]
t2 := ts[1]
fmt.Printf("Rectangle triangles:\n\t%v\n\t%v\n", t1, t2)
2023-05-28 19:14:02 +03:00
for _, p := range points {
2023-05-30 14:34:10 +03:00
fmt.Println(p, t.ContainsPoint(p))
}
2023-05-30 14:34:10 +03:00
2023-05-28 19:14:02 +03:00
}