3D Lingo Dictionary > O-S > randomVector

 

randomVector

Syntax

randomVector()

Description

3D command; returns a unit vector describing a randomly chosen point on the surface of a unit sphere. This method differs from vector( random(10)/10.0, random(10)/10.0, random(10)/10.0), in that the resulting vector is guaranteed to be a unit vector.

Examples

These statements create and display two randomly defined unit vectors in the Message window:

vec = randomVector()
put vec
-- vector(-0.1155, 0.9833, -0.1408)
vec2 = randomVector()
put vec2
-- vector(0.0042, 0.8767, 0.4810)

See also

getNormalized, generateNormals(), normalize