1
\$\begingroup\$

I'm confused about the two functions, do they return the same thing?

\$\endgroup\$
2
\$\begingroup\$

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)

\$\endgroup\$
2
  • \$\begingroup\$ Will it be different in some cases? \$\endgroup\$ Aug 20 '18 at 9:48
  • 1
    \$\begingroup\$ @OtakuFitness No, both are mathematically equivalent. The former is probably implemented as the latter. \$\endgroup\$
    – LukeG
    Aug 20 '18 at 10:25
0
\$\begingroup\$

Distance is the length between two vectors. Length is the magnitude of one vector.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.