gg/cmd/math/main.go

41 lines
571 B
Go
Raw Permalink Normal View History

package main
import (
2024-05-19 21:11:58 +03:00
"surdeus.su/core/gg"
"fmt"
"encoding/json"
)
2024-05-19 21:11:58 +03:00
type Float = gg.Float
func EdgesFromVals(vals ...Float) gg.Edges {
ret := gg.Edges{}
2024-05-19 21:11:58 +03:00
for i := 0; i < len(vals); i += 4 {
ret = append(
ret,
gg.Edge{
gg.Point{
vals[i], vals[i+1],
},
gg.Point{
vals[i+2], vals[i+3],
},
},
)
}
return ret
}
func main() {
e1 := EdgesFromVals(
0, 0, 5, 5,
)
e2 := EdgesFromVals(
0, 1, 5, 0,
0, 0, 5, 5,
)
val, ok := e1.CrossWithEdges(e2)
bts, _ := json.MarshalIndent(val, "", "\t")
fmt.Println(string(bts), ok)
}