...
This commit is contained in:
parent
e3ab4596e1
commit
4f755e6766
4 changed files with 40 additions and 4 deletions
|
@ -186,7 +186,8 @@ func (d *Debug) Draw(
|
|||
keyStrs = append(keyStrs, k.String())
|
||||
}
|
||||
|
||||
if rectMove.Vertices().Contained(rect).Len() > 0 {
|
||||
if rectMove.Vertices().Contained(rect).Len() > 0 ||
|
||||
rect.Vertices().Contained(rectMove).Len() > 0 {
|
||||
keyStrs = append(keyStrs, "THIS IS SHIT")
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package gx
|
|||
|
||||
import (
|
||||
"math"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// The type represents mathematical equation of line and line itself.
|
||||
|
@ -25,7 +26,8 @@ type LineSegment [2]Point
|
|||
type LineSegments []LineSegment
|
||||
|
||||
type Edge = LineSegment
|
||||
type Edges []Vertex
|
||||
type Edges = LineSegments
|
||||
|
||||
|
||||
|
||||
// Check if two LinerPointContainers do cross and return the
|
||||
|
@ -120,3 +122,20 @@ func (ls LineSegment) Len() Float {
|
|||
return math.Sqrt(ls.LenSqr())
|
||||
}
|
||||
|
||||
func (what LineSegments) Cross(with LineSegments) ([][2]int, Points) {
|
||||
indexes := [][2]int{}
|
||||
points := Points{}
|
||||
for i := range what {
|
||||
for j := range with {
|
||||
p, cross := LinersCross(what[i], with[j])
|
||||
if cross {
|
||||
fmt.Println("in")
|
||||
points = append(points, p)
|
||||
indexes = append(indexes, [2]int{i, j})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return indexes, points
|
||||
}
|
||||
|
||||
|
|
16
src/gx/polygon.go
Normal file
16
src/gx/polygon.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
package gx
|
||||
|
||||
// The type represents polygons.
|
||||
// Fuck. The package gets too big.
|
||||
// Should split it somehow.
|
||||
type Polygon []Point
|
||||
|
||||
func (p Polygon) Edges() Edges {
|
||||
ret := Edges{}
|
||||
/*for i := range p {
|
||||
ret = append(ret, Edge{})
|
||||
}*/
|
||||
|
||||
return ret
|
||||
}
|
||||
|
|
@ -38,13 +38,13 @@ func (r Rectangle) Vertices() Points {
|
|||
return Points{p1, p2, p3, p4}
|
||||
}
|
||||
|
||||
func (r Rectangle) Edges() LineSegments {
|
||||
func (r Rectangle) Edges() Edges {
|
||||
vs := r.Vertices()
|
||||
return LineSegments{
|
||||
LineSegment{vs[0], vs[1]},
|
||||
LineSegment{vs[1], vs[2]},
|
||||
LineSegment{vs[2], vs[3]},
|
||||
LineSegment{vs[4], vs[0]},
|
||||
LineSegment{vs[3], vs[0]},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue