Category:LSL Vector
From Second Life Wiki
(Redirected from Vector)
| LSL Portal | | | Functions | | | Events | | | Types | | | Operators | | | Constants | | | Flow Control | | | Script Library | | | Tutorials |
Vector
A vector is a data type that contains a set of three float values. Each element can be accessed individually by appending .x, .y, or .z to the variable name.
Vectors can be used to hold the following:
- Position: x, y and z are in metres.
- Velocity: x, y and z represent speeds.
- Colour: Red is x, Green is y and Blue is z.
Vectors support the following operations:
- Addition, Operator "+"
- Subtraction, Operator "-"
- Multiplication (Dot Product), Operator "*"
- Cross Product, Operator "%"
A vector can be multiplied or divided by a Quaternion to rotate it.
Example
vector test=<1.0, 2.0, 3.0>; llOwnerSay((string)test.z); // Outputs 3.0
Useful Snippets
integer IsVector(string s) { list split = llParseString2List(s, [" "], ["<", ">", ","]); if(llGetListLength(split) != 7)//we must check the list length, or the next test won't work properly. return 0; return !((string)((vector)s) == (string)((vector)((string)llListInsertList(split, ["-"], 5)))); //it works by trying to flip the sign on the Z element of the vector, //if it works or breaks the vector then the values won't match. //if the vector was already broken then the sign flip will have no affect and the values will match //we cast back to string so we can catch negative zero which allows for support of ZERO_VECTOR }//Strife Onizuka
Articles in category "LSL Vector"
There are 4 articles in this category.

