Garry's Mod Wiki

Revision Difference

Vector:Distance#529303

<function name="Distance" parent="Vector" type="classfunc"> <description> Returns the euclidean distance between the vector and the other vector. ⤶ <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> ⤶ <note>This function is slower than <page>Vector:DistToSqr</page>. 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> <code>print( Vector( 0, 0, 0 ):Distance( Vector( 2, 3, 4 ) ) )</code> <output>⤶ ```⤶ 5.3851647377014⤶ ```⤶ </output>⤶ </example>