Vector3::divide: Difference between revisions
(Created page with "This function is used to divide a Vector3 by another Vector3. ==Syntax== <pre> vector.divide(Vector3 otherVec); </pre> ===Required Arguments=== *'''otherVec:''' Vector3: The...") |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
This function is used to divide a Vector3 by another Vector3. | This function is used to divide a Vector3 by another Vector3 or scalar. | ||
==Syntax== | ==Syntax== | ||
<pre> | <pre> | ||
vector.divide(Vector3 otherVec); | vector.divide(Vector3 otherVec); | ||
vector.divide(number scalar); | |||
</pre> | </pre> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''otherVec:''' Vector3: The vector to divide the callee by. | *'''otherVec:''' Vector3: The vector or scalar to divide the callee by. | ||
==Example== | == Returns == | ||
* {{RageType|Vector3}} The quotient. | |||
==Example #1== | |||
{{ServersideCode| | {{ServersideCode| | ||
<pre> | <pre> | ||
| Line 15: | Line 19: | ||
const quotient = vec1.divide(vec2); // quotient = {x: 5, y: 2, z: 2} | const quotient = vec1.divide(vec2); // quotient = {x: 5, y: 2, z: 2} | ||
</pre> | |||
}} | |||
==Example #2== | |||
{{ServersideCode| | |||
<pre> | |||
const vec1 = new mp.Vector3(50, 40, 30); | |||
const scalar = 10; | |||
const quotient = vec1.divide(scalar); // quotient = {x: 5, y: 4, z: 3} | |||
</pre> | </pre> | ||
}} | }} | ||
Latest revision as of 06:16, 31 May 2019
This function is used to divide a Vector3 by another Vector3 or scalar.
Syntax
vector.divide(Vector3 otherVec); vector.divide(number scalar);
Required Arguments
- otherVec: Vector3: The vector or scalar to divide the callee by.
Returns
- Vector3 The quotient.
Example #1
Server-Side
const vec1 = new mp.Vector3(50, 10, 30);
const vec2 = new mp.Vector3(10, 20, 15);
const quotient = vec1.divide(vec2); // quotient = {x: 5, y: 2, z: 2}
Example #2
Server-Side
const vec1 = new mp.Vector3(50, 40, 30);
const scalar = 10;
const quotient = vec1.divide(scalar); // quotient = {x: 5, y: 4, z: 3}
See Also
- Functions
- Properties
- Vector3::x
- Vector3::y
- Vector3::z