I'm confused about the two functions, do they return the same thing?
2 Answers
\$\begingroup\$
\$\endgroup\$
2
length()
takes in one vector and returns the magnitude of that.
distance()
takes in two and returns the distance between those. Basically, distance(a, b)
is the same as length(a - b)
-
\$\begingroup\$ Will it be different in some cases? \$\endgroup\$ Commented Aug 20, 2018 at 9:48
-
1\$\begingroup\$ @OtakuFitness No, both are mathematically equivalent. The former is probably implemented as the latter. \$\endgroup\$– LukeGCommented Aug 20, 2018 at 10:25
\$\begingroup\$
\$\endgroup\$
Distance is the length between two vectors. Length is the magnitude of one vector.