- Joined
- Sep 6, 2020
- Messages
- 60
- Reaction score
- 39
Vectors
---
Vectors were introduced in 5.3. They may be diffiult to understand at first, but they can be extremely useful!
Before jumping into it, if you're familiar with real life vector maths, yep, these are exactly like that.
---
What is a vector?
A vector has 3 components: X, Y and Z. You can see vectors as a line from point A to B (basically, a vector is direction and magnitude combined). A will be (0,0,0) in this example. If our vector is <3,3,3> the vector is a straight line from (0,0,0) to (3,3,3). To easily visualize this, set a vector and left-click while holding it.
---
Actions
We're going to go over all vector-related actions individually here.
- Add Vector to Location
We can use vectors to move locations with this action. It will calculate the sum of each component.
Guess what will happen if we add the vector <3,5,2> to the location (6,-3,4). The result will be (6+3, -3+5, 2+4), or (9,2,6).
- Add Vectors
Similar to above action, except with vectors. Example:
<3,6,4> + <1,3,-2> + <5,2,7> = <3+1+5, 6+3+2, 4-2+7> = <9,11,5>.
- Align Vector
Sets all components to 0, except for the highest absolute one, also favors the last components. Examples:
AlignVector(<1,2,3>) = <0,0,3>
AlignVector(<-5,4,-3>) = <-5,0,0>
AlignVector(<-5,6,-3>) = <0,6,0>
AlignVector(<1,1,1>) = <0,0,1>
- Get Vector Component
Gets one of a vector's components (X, Y or Z). Example:
GetVectorComp(<1,2,3>, Z) returns 3.
- Get Vector Length
Gets the magnitude (or length) of a vector. Basically the distance from point A to B. Example:
Our vector is <3,0,0>. We can see this as a line from (0,0,0) to (3,0,0). The distance between these points will be the result of this action, which is 3.
(Advanced) Get Vector Length also has a tag to change the result of the action. Setting it to Length Squared will partially use the formula for calculating a vector's magnitude. It will not use root (√) on the expression. Example:
GetVectorLength(<1,0,1>, Length) = 1.414 (DiamondFire has a decimal limit of 3 per number)
GetVectorLength(<1,0,1>, Length Squared) = 2
- Multiply Vector
Multiplies each of a vector's components by a scalar. Example:
<2,5,3> * 3 = <2*3, 5*3, 3*3> = <6,15,9>.
- Set to Vector
Sets a vector to the components provided (X, Y and Z), OR use a direction text. Direction Example:
SetVector('north') = <0,0,-1>
- Set to Vector Between Locations
Remember the line example? Here we're setting one. It will set to the vector that has a line that perfectly fits from point one to point two. If we have location one (0,1,0) and location two (2,3,4) the vector would be <2,2,4>.
- Shift Location on Vector
Shifts a location based on the direction of a vector. Example:
ShiftLocOnVector((0,0,0), <1,0,0>, 3) = (3,0,0)
- Subtract Vectors
Subtracts each of a vector's components. Example:
<8,6,3> - <1,4,2> = <8-1, 6-4, 3-2> = <7,2,1>.
Advanced Actions
These are actions that are more advanced linear algebra, and I don't think these will be used much in DiamondFire, and as such, is not worth the space. This is why I'm going to link you to people that are much better at explaining.
- Reflect Vector
https://en.wikipedia.org/wiki/Reflection_(mathematics)
- Rotate Vector Around Axis
https://en.wikipedia.org/wiki/Rotation_matrix
- Rotate Vector Around Vector
https://en.wikipedia.org/wiki/Rotation_matrix
- Set to Cross Product
https://en.wikipedia.org/wiki/Cross_product
- Set to Dot Product
https://en.wikipedia.org/wiki/Dot_product
---
Phew, that was a lot of information. Still have questions left? Simply reply to this thread!
---
Vectors were introduced in 5.3. They may be diffiult to understand at first, but they can be extremely useful!
Before jumping into it, if you're familiar with real life vector maths, yep, these are exactly like that.
---
What is a vector?
A vector has 3 components: X, Y and Z. You can see vectors as a line from point A to B (basically, a vector is direction and magnitude combined). A will be (0,0,0) in this example. If our vector is <3,3,3> the vector is a straight line from (0,0,0) to (3,3,3). To easily visualize this, set a vector and left-click while holding it.
---
Actions
We're going to go over all vector-related actions individually here.
- Add Vector to Location
We can use vectors to move locations with this action. It will calculate the sum of each component.
Guess what will happen if we add the vector <3,5,2> to the location (6,-3,4). The result will be (6+3, -3+5, 2+4), or (9,2,6).
- Add Vectors
Similar to above action, except with vectors. Example:
<3,6,4> + <1,3,-2> + <5,2,7> = <3+1+5, 6+3+2, 4-2+7> = <9,11,5>.
- Align Vector
Sets all components to 0, except for the highest absolute one, also favors the last components. Examples:
AlignVector(<1,2,3>) = <0,0,3>
AlignVector(<-5,4,-3>) = <-5,0,0>
AlignVector(<-5,6,-3>) = <0,6,0>
AlignVector(<1,1,1>) = <0,0,1>
- Get Vector Component
Gets one of a vector's components (X, Y or Z). Example:
GetVectorComp(<1,2,3>, Z) returns 3.
- Get Vector Length
Gets the magnitude (or length) of a vector. Basically the distance from point A to B. Example:
Our vector is <3,0,0>. We can see this as a line from (0,0,0) to (3,0,0). The distance between these points will be the result of this action, which is 3.
(Advanced) Get Vector Length also has a tag to change the result of the action. Setting it to Length Squared will partially use the formula for calculating a vector's magnitude. It will not use root (√) on the expression. Example:
GetVectorLength(<1,0,1>, Length) = 1.414 (DiamondFire has a decimal limit of 3 per number)
GetVectorLength(<1,0,1>, Length Squared) = 2
- Multiply Vector
Multiplies each of a vector's components by a scalar. Example:
<2,5,3> * 3 = <2*3, 5*3, 3*3> = <6,15,9>.
- Set to Vector
Sets a vector to the components provided (X, Y and Z), OR use a direction text. Direction Example:
SetVector('north') = <0,0,-1>
- Set to Vector Between Locations
Remember the line example? Here we're setting one. It will set to the vector that has a line that perfectly fits from point one to point two. If we have location one (0,1,0) and location two (2,3,4) the vector would be <2,2,4>.
- Shift Location on Vector
Shifts a location based on the direction of a vector. Example:
ShiftLocOnVector((0,0,0), <1,0,0>, 3) = (3,0,0)
- Subtract Vectors
Subtracts each of a vector's components. Example:
<8,6,3> - <1,4,2> = <8-1, 6-4, 3-2> = <7,2,1>.
Advanced Actions
These are actions that are more advanced linear algebra, and I don't think these will be used much in DiamondFire, and as such, is not worth the space. This is why I'm going to link you to people that are much better at explaining.
- Reflect Vector
https://en.wikipedia.org/wiki/Reflection_(mathematics)
- Rotate Vector Around Axis
https://en.wikipedia.org/wiki/Rotation_matrix
- Rotate Vector Around Vector
https://en.wikipedia.org/wiki/Rotation_matrix
- Set to Cross Product
https://en.wikipedia.org/wiki/Cross_product
- Set to Dot Product
https://en.wikipedia.org/wiki/Dot_product
---
Phew, that was a lot of information. Still have questions left? Simply reply to this thread!