MCPcopy
hub / github.com/tdewolff/canvas / TestPoint

Function TestPoint

util_test.go:136–158  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

134}
135
136func TestPoint(t *testing.T) {
137 p := Point{3, 4}
138 test.T(t, p.Mul(2.0), Point{6, 8})
139 test.T(t, p.Div(3.0), Point{1, 4.0 / 3.0})
140 test.T(t, p.Rot90CW(), Point{4, -3})
141 test.T(t, p.Rot90CCW(), Point{-4, 3})
142 test.T(t, p.Rot(90*math.Pi/180.0, Point{}), p.Rot90CCW())
143 test.T(t, p.Rot(90*math.Pi/180.0, p), p)
144 test.Float(t, p.Dot(Point{3, 0}), 9.0)
145 test.Float(t, p.PerpDot(Point{3, 0}), p.Rot90CCW().Dot(Point{3, 0}))
146 test.Float(t, p.Length(), 5.0)
147 test.Float(t, p.Slope(), 4.0/3.0)
148 test.Float(t, p.Angle()*180.0/math.Pi, 53.1301023542)
149 test.Float(t, p.AngleBetween(p.Rot90CCW())*180.0/math.Pi, 90.0)
150 test.Float(t, Point{0, 0}.AngleBetween(p)*180.0/math.Pi, 0.0)
151 test.Float(t, p.AngleBetween(Point{0, 0})*180.0/math.Pi, 0.0)
152 test.Float(t, p.AngleBetween(p)*180.0/math.Pi, 0.0)
153 test.T(t, p.Norm(3.0), Point{1.8, 2.4})
154 test.T(t, p.Norm(0.0), Point{0.0, 0.0})
155 test.T(t, Point{}.Norm(1.0), Point{0.0, 0.0})
156 test.T(t, Point{}.Interpolate(p, 0.5), Point{1.5, 2.0})
157 test.String(t, p.String(), "(3,4)")
158}
159
160func TestRect(t *testing.T) {
161 r := Rect{0, 0, 5, 5}

Callers

nothing calls this directly

Calls 15

MulMethod · 0.95
DivMethod · 0.95
Rot90CWMethod · 0.95
Rot90CCWMethod · 0.95
RotMethod · 0.95
DotMethod · 0.95
PerpDotMethod · 0.95
LengthMethod · 0.95
SlopeMethod · 0.95
AngleMethod · 0.95
AngleBetweenMethod · 0.95
NormMethod · 0.95

Tested by

no test coverage detected