2024-01-22 10:23:47 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-05-19 21:11:58 +03:00
|
|
|
"surdeus.su/core/gg"
|
2024-01-22 10:23:47 +03:00
|
|
|
"fmt"
|
|
|
|
"encoding/json"
|
|
|
|
)
|
2024-05-19 21:11:58 +03:00
|
|
|
|
2024-01-22 10:23:47 +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 {
|
2024-01-22 10:23:47 +03:00
|
|
|
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)
|
|
|
|
}
|