Main Index : Reference :

vector()


Description

Creates a three-dimensional vector out of either one or three variables.

Definition

[vector] vector([float,int] x,[float,int] y,[float,int] z)
[vector] vector([float,int] a)

Parameters

x, y, z and a are numerical values.

Return Value

vector() returns a three-dimensional vector. The vector is filled with the three passed parameters, one for each element of the vector. If only one parameter is passed, all three elements are filled with it. The parameters are automatically cast to floats.

Example

// Outputs "v1 = [1.0000,2.0000,3.0000]
//          v2 = [4.7000,4.7000,4.7000]".

var v1 = vector(1.0,2.0,3.0);
var v2 = vector(4.7);

println("v1 = ",v1);
println("v2 = ",v2);


// The elements of a vector are accessed with x, y and z.
//
// Outputs "x: 1.0000  y: 2.0000  z: 3.0000".

var v1 = vector(1.0,2.0,3.0);

var a = v1.x;
var b = v1.y;
var c = v1.z;

println("x: ",a,"  y: ",b,"  z: ",c);

See Also

vlen(), vnorm(), vcross(), [vector]