3D Lingo Dictionary > C-D > distanceTo() |  |

distanceTo()

Syntax

    vector1.distanceTo(vector2)

Description

3D vector method; returns the distance in world units between two vectors.

Example

There are three vectors in this example. The distance from Vec1 to Vec2 is 100.0000 world units. The distance from Vec1 to Vec3 is 141.4214 world units.

    Vec1 = vector(100, 0, 0)
    Vec2 = vector(100, 100, 0)
    Vec3 = vector(100, 100, 100)
    put Vec1.distanceTo(Vec2)
    -- 100.0000
    put Vec1.distanceTo(Vec3)
    -- 141.4214

See also

`magnitude`