Difference between revisions of "HPL3/SOMA/Scripting/cVector4f"
Jump to navigation
Jump to search
(Created page with "{{ScriptingStub}} Have some helpful descriptions to add to this class? Edit this page and add your insight to the Wiki! ==Constructors== {| class="wikitable" ! Constructor...") |
|||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | + | A four dimensional vector unit which stores its elements as floats. | |
| − | |||
| − | |||
==Constructors== | ==Constructors== | ||
| Line 8: | Line 6: | ||
! Constructor !! Description | ! Constructor !! Description | ||
|- | |- | ||
| − | | <syntaxhighlight lang="c++" inline>cVector4f(float, float, float, float)</syntaxhighlight> || Creates a cVector4f with | + | | <syntaxhighlight lang="c++" inline>cVector4f(float, float, float, float)</syntaxhighlight> || Creates a <code>cVector4f</code> with the given element data. |
|} | |} | ||
| Line 41: | Line 39: | ||
|} | |} | ||
| − | + | ==Remarks== | |
A normalized vector is a vector whose length is equal to one, otherwise known as a unit vector. To convert a vector into a unit vector, get the normalization factor by calling the ''Normalize'' function, then divide each of the vector's x, y, z, and w coordinates by that factor. | A normalized vector is a vector whose length is equal to one, otherwise known as a unit vector. To convert a vector into a unit vector, get the normalization factor by calling the ''Normalize'' function, then divide each of the vector's x, y, z, and w coordinates by that factor. | ||
| Line 51: | Line 49: | ||
vBaseVector.z / fNormFactor, | vBaseVector.z / fNormFactor, | ||
vBaseVector.w / fNormFactor);</syntaxhighlight> | vBaseVector.w / fNormFactor);</syntaxhighlight> | ||
| + | |||
| + | {{ReferencesSection}} | ||
{{HPL3SOMAScriptingCategories}} | {{HPL3SOMAScriptingCategories}} | ||
__FORCETOC__ | __FORCETOC__ | ||
Latest revision as of 15:23, 6 August 2020
A four dimensional vector unit which stores its elements as floats.
Constructors
| Constructor | Description |
|---|---|
cVector4f(float, float, float, float) |
Creates a cVector4f with the given element data.
|
Fields
| Field Name | Type | Description |
|---|---|---|
| w | float |
The x value of the vector. |
| x | float |
The y value of the vector. |
| y | float |
The z value of the vector. |
| z | float |
The w value of the vector. |
Functions
| Return Type | Function Name | Parameters | Description |
|---|---|---|---|
float |
GetElement | uint64 alIdx |
Gets the value at the given index. (Indices 0, 1, 2, and 3 are equal to x, y, z, and w respectively.) |
float |
Length | Returns the length of this vector. | |
float |
Normalize | Returns the normalization factor for this vector. (See Remarks.) | |
void |
SetElement | uint64 alIdx,float |
Sets the value at the given index to the given value. (Indices 0, 1, 2, and 3 are equal to x, y, z, and w respectively.) |
float |
SqrLength | Returns the length-squared of this vector. |
Remarks
A normalized vector is a vector whose length is equal to one, otherwise known as a unit vector. To convert a vector into a unit vector, get the normalization factor by calling the Normalize function, then divide each of the vector's x, y, z, and w coordinates by that factor.
cVector4f vBaseVector(2.0, 5.0, 3.0, 4.0);
float fNormFactor = vBaseVector.Normalize();
cVector3f vNormalizedVector(vBaseVector.x / fNormFactor,
vBaseVector.y / fNormFactor,
vBaseVector.z / fNormFactor,
vBaseVector.w / fNormFactor);