vector and Vector(float, float,float)
Note: Mediawiki doesn't allow both this to exist as lowercase (data type) and uppercase (function) variants so both are on this page at once.
vector Data Type
A vector is a structure of three floats, useful for defining positions and orientation vectors. To access the components of the vector, you can use the dot operator to get the x, y, and z components of the vector. The default value of a vector is [ 0.0, 0.0, 0.0 ] (or x = 0.0, y = 0.0, z = 0.0).
You define a vector by using the Vector command (see below for full details):
You can alter individual parts of the vector later using the Dot Operator with x, y and z as parameters:
If you have a function declaration needing a default vector value you can use it in this way:
Example
vector v2 = Vector(1.0f, 2.0f, 3.0f);
PrintFloat(v2.x);
float fDistanceToTarget = sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
Vector(float, float, float)
Creates a vector (position) from three points.
Parameters
- fX
- x point of a triangle. (Default: 0.0f)
- fY
- y point of a triangle. (Default: 0.0f)
- fZ
- z point of a triangle. (Default: 0.0f)
Description
Returns a vector with the specified point values of fX, fY, and fZ.
Remarks
A common use for this command is when creating a new location based on an objects location.
You can get an objects position vector by using GetPosition, or a position vector from a location using GetPositionFromLocation.
You can change the values of a set vector by using the dot operator.
Version
1.61
See Also
functions: |
author: Charles Feduke, editor: Lilac Soul