| | |
| | | return num1 |
| | | } |
| | | |
| | | //Point 坐标点 |
| | | type Point struct { |
| | | X float64 `json:"x"` |
| | | Y float64 `json:"y"` |
| | | } |
| | | |
| | | //Rect 检测目标 |
| | | type Rect struct { |
| | | X float64 |
| | | Y float64 |
| | | Width float64 |
| | | Height float64 |
| | | } |
| | | |
| | | //Pointfloat 坐标点 |
| | | type Pointfloat struct { |
| | | X float64 `json:"x"` |
| | | Y float64 `json:"y"` |
| | | } |
| | | |
| | | //PintIsInPolygon 判断点是否在多边形内部 |
| | | //point为要判断的坐标点 |
| | | //polygon是多边形各点数组 |
| | | func pintIsInPolygon(point structure.Pointfloat, polygon []structure.Point, widthScale float64, heightScale float64) bool { |
| | | func pintIsInPolygon(point structure.Pointfloat, polygon []Point, widthScale float64, heightScale float64) bool { |
| | | var nCross int = 0 |
| | | for i := 0; i < len(polygon); i++ { |
| | | |
| | |
| | | } |
| | | |
| | | //ComputePolygonArea 计算任意多边形面积 |
| | | func computePolygonArea(polygon []structure.Point) float64 { |
| | | func computePolygonArea(polygon []Point) float64 { |
| | | pointNum := len(polygon) |
| | | var s float64 = 0 |
| | | if pointNum < 3 { |
| | |
| | | } |
| | | |
| | | //PgsInterPercent calculate percent of two polygon intersection 计算两个多边形的重叠占比 |
| | | func PgsInterPercent(pgpts []structure.Point, box structure.Rect, widthScale float64, heightScale float64) (percent float64) { |
| | | func PgsInterPercent(pgpts []Point, box structure.Rect, widthScale float64, heightScale float64) (percent float64) { |
| | | |
| | | areapts, areaBox := getLocation(box, 10) |
| | | var count = 0 |