2
\$\begingroup\$

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

\$\endgroup\$

2 Answers 2

3
\$\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\$ Commented Aug 20, 2018 at 9:48
  • 1
    \$\begingroup\$ @OtakuFitness No, both are mathematically equivalent. The former is probably implemented as the latter. \$\endgroup\$
    – LukeG
    Commented Aug 20, 2018 at 10:25
0
\$\begingroup\$

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

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .