MCPcopy Create free account
hub / github.com/fogleman/primitive / Valid

Method Valid

primitive/triangle.go:72–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70}
71
72func (t *Triangle) Valid() bool {
73 const minDegrees = 15
74 var a1, a2, a3 float64
75 {
76 x1 := float64(t.X2 - t.X1)
77 y1 := float64(t.Y2 - t.Y1)
78 x2 := float64(t.X3 - t.X1)
79 y2 := float64(t.Y3 - t.Y1)
80 d1 := math.Sqrt(x1*x1 + y1*y1)
81 d2 := math.Sqrt(x2*x2 + y2*y2)
82 x1 /= d1
83 y1 /= d1
84 x2 /= d2
85 y2 /= d2
86 a1 = degrees(math.Acos(x1*x2 + y1*y2))
87 }
88 {
89 x1 := float64(t.X1 - t.X2)
90 y1 := float64(t.Y1 - t.Y2)
91 x2 := float64(t.X3 - t.X2)
92 y2 := float64(t.Y3 - t.Y2)
93 d1 := math.Sqrt(x1*x1 + y1*y1)
94 d2 := math.Sqrt(x2*x2 + y2*y2)
95 x1 /= d1
96 y1 /= d1
97 x2 /= d2
98 y2 /= d2
99 a2 = degrees(math.Acos(x1*x2 + y1*y2))
100 }
101 a3 = 180 - a1 - a2
102 return a1 > minDegrees && a2 > minDegrees && a3 > minDegrees
103}
104
105func (t *Triangle) Rasterize() []Scanline {
106 buf := t.Worker.Lines[:0]

Callers 1

MutateMethod · 0.95

Calls 1

degreesFunction · 0.85

Tested by

no test coverage detected