mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
vector/internal/math: Remove Vector
This commit is contained in:
parent
17e16e5759
commit
17dc972b7a
@ -24,8 +24,3 @@ type Point struct {
|
|||||||
X float32
|
X float32
|
||||||
Y float32
|
Y float32
|
||||||
}
|
}
|
||||||
|
|
||||||
type Vector struct {
|
|
||||||
X float32
|
|
||||||
Y float32
|
|
||||||
}
|
|
||||||
|
@ -18,12 +18,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func cross(v0, v1 Vector) float32 {
|
func cross(v0x, v0y, v1x, v1y float32) float32 {
|
||||||
return v0.X*v1.Y - v0.Y*v1.X
|
return v0x*v1y - v0y*v1x
|
||||||
}
|
}
|
||||||
|
|
||||||
func triangleCross(pt0, pt1, pt2 Point) float32 {
|
func triangleCross(pt0, pt1, pt2 Point) float32 {
|
||||||
return cross(Vector{pt1.X - pt0.X, pt1.Y - pt0.Y}, Vector{pt2.X - pt1.X, pt2.Y - pt1.Y})
|
return cross(pt1.X-pt0.X, pt1.Y-pt0.Y, pt2.X-pt1.X, pt2.Y-pt1.Y)
|
||||||
}
|
}
|
||||||
|
|
||||||
func adjacentIndices(indices []uint16, idx int) (uint16, uint16, uint16) {
|
func adjacentIndices(indices []uint16, idx int) (uint16, uint16, uint16) {
|
||||||
@ -43,9 +43,9 @@ func InTriangle(pt, pt0, pt1, pt2 Point) bool {
|
|||||||
if pt.Y >= pt0.Y && pt.Y >= pt1.Y && pt.Y >= pt2.Y {
|
if pt.Y >= pt0.Y && pt.Y >= pt1.Y && pt.Y >= pt2.Y {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
c0 := cross(Vector{pt.X - pt0.X, pt.Y - pt0.Y}, Vector{pt1.X - pt0.X, pt1.Y - pt0.Y})
|
c0 := cross(pt.X-pt0.X, pt.Y-pt0.Y, pt1.X-pt0.X, pt1.Y-pt0.Y)
|
||||||
c1 := cross(Vector{pt.X - pt1.X, pt.Y - pt1.Y}, Vector{pt2.X - pt1.X, pt2.Y - pt1.Y})
|
c1 := cross(pt.X-pt1.X, pt.Y-pt1.Y, pt2.X-pt1.X, pt2.Y-pt1.Y)
|
||||||
c2 := cross(Vector{pt.X - pt2.X, pt.Y - pt2.Y}, Vector{pt0.X - pt2.X, pt0.Y - pt2.Y})
|
c2 := cross(pt.X-pt2.X, pt.Y-pt2.Y, pt0.X-pt2.X, pt0.Y-pt2.Y)
|
||||||
return (c0 <= 0 && c1 <= 0 && c2 <= 0) || (c0 >= 0 && c1 >= 0 && c2 >= 0)
|
return (c0 <= 0 && c1 <= 0 && c2 <= 0) || (c0 >= 0 && c1 >= 0 && c2 >= 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user