40 lines
571 B
Go
40 lines
571 B
Go
package main
|
|
|
|
import (
|
|
"surdeus.su/core/gg"
|
|
"fmt"
|
|
"encoding/json"
|
|
)
|
|
|
|
type Float = gg.Float
|
|
|
|
func EdgesFromVals(vals ...Float) gg.Edges {
|
|
ret := gg.Edges{}
|
|
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)
|
|
}
|