MCPcopy
hub / github.com/golang/geo / TestVectorAngle

Function TestVectorAngle

r3/vector_test.go:224–243  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

222}
223
224func TestVectorAngle(t *testing.T) {
225 tests := []struct {
226 v1, v2 Vector
227 want float64 // radians
228 }{
229 {Vector{1, 0, 0}, Vector{1, 0, 0}, 0},
230 {Vector{1, 0, 0}, Vector{0, 1, 0}, math.Pi / 2},
231 {Vector{1, 0, 0}, Vector{0, 1, 1}, math.Pi / 2},
232 {Vector{1, 0, 0}, Vector{-1, 0, 0}, math.Pi},
233 {Vector{1, 2, 3}, Vector{2, 3, -1}, 1.2055891055045298},
234 }
235 for _, test := range tests {
236 if a := test.v1.Angle(test.v2).Radians(); !float64Eq(a, test.want) {
237 t.Errorf("%v.Angle(%v) = %v, want %v", test.v1, test.v2, a, test.want)
238 }
239 if a := test.v2.Angle(test.v1).Radians(); !float64Eq(a, test.want) {
240 t.Errorf("%v.Angle(%v) = %v, want %v", test.v2, test.v1, a, test.want)
241 }
242 }
243}
244
245func TestVectorOrtho(t *testing.T) {
246 vectors := []Vector{

Callers

nothing calls this directly

Calls 3

RadiansMethod · 0.80
float64EqFunction · 0.70
AngleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…