Garry's Mod Wiki

Revision Difference

Vector:Distance#529301

<function name="Distance" parent="Vector" type="classfunc"> <description> Returns the euclidean distance between the vector and the other vector. ⤶ <warning>This is a relatively expensive process since it uses the square root. It is recommended that you use <page>Vector:DistToSqr</page> whenever possible. (Benchmarking shows <page>Vector:DistToSqr</page> was at most 153 nanoseconds faster.)</warning>⤶ ⤶ <note><page>Vector:DistToSqr</page> has a minute performance increase over this function. However, please see the notes for <page>Vector:DistToSqr</page> before using it as squared distances are not the same as euclidean distances.</note>⤶ </description> <realm>Shared</realm> <args> <arg name="otherVector" type="Vector">The vector to get the distance to.</arg> </args> <rets> <ret name="" type="number">Distance between the vectors.</ret> </rets> </function> <example> <description>Gets the distance from A to B.</description> <code>print(Vector(0, 0, 0):Distance(Vector(2, 3, 4)))</code> <output>5.3851647377014</output> </example>