-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic functions for change of basis in 3D #939
Merged
Merged
Changes from 3 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
22a14f2
Add basic functions for change of basis in 3D
Kexanone 0884e85
Update CfgFunctions.hpp
Kexanone ab4efd8
Replace tabs with spaces in fnc_matrixProduct3D
Kexanone c2cf66c
Replace for loops with apply
Kexanone efe1e00
Standardize comment indentation
Kexanone cf63434
Fix comment grammar
Kexanone 89e47f8
delete semicolon to indicate function return value
commy2 41bc3ea
delete semicolon to indicate function return value
commy2 8a9d880
delete semicolon to indicate function return value
commy2 e998ed6
delete atypical empty line
commy2 f11acdb
delete atypical empty line
commy2 99185c1
Optimize _fnc_vectorEquals and implement _fnc_matrixEquals
Kexanone c29d3b4
Add unit tests
Kexanone b0456e5
include position
commy2 a5995d1
include position
commy2 df3d6a6
include position
commy2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_matrixProduct3D | ||
|
||
Description: | ||
Returns the resulting matrix from the matrix-matrix product. | ||
|
||
Only accepts a 3x3 matrices. | ||
|
||
Parameters: | ||
_matrixA - first 3x3 matrix. <ARRAY> | ||
_matrixB - second 3x3 matrix. <ARRAY> | ||
|
||
Returns: | ||
_returnMatrix - 3x3 matrix returned after matrix multiplication <ARRAY> | ||
|
||
Examples: | ||
(begin example) | ||
// point reflection at origin [0,0,0] for every vector in matrix B | ||
[[[-1,0,0],[0,-1,0],[0,0,-1]], [[1,2,3], [3,1,2], [2,3,1]]] call CBA_fnc_matrixProduct3D; | ||
(end) | ||
|
||
Author: | ||
Kex | ||
---------------------------------------------------------------------------- */ | ||
|
||
#include "script_component.hpp" | ||
|
||
params [["_matrixA", [], [[]], 3], ["_matrixB", [], [[]], 3]]; | ||
|
||
_matrixB = [_matrixB] call CBA_fnc_matrixTranspose; | ||
|
||
private _returnMatrix = []; | ||
for "_i" from 0 to (count _matrixA -1) do | ||
{ | ||
private _returnRow = []; | ||
private _rowA = _matrixA select _i; | ||
for "_j" from 0 to (count _matrixB -1) do | ||
{ | ||
_returnRow pushBack (_rowA vectorDotProduct ( _matrixB select _j)); | ||
}; | ||
_returnMatrix pushBack _returnRow; | ||
}; | ||
_returnMatrix; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_matrixTranspose | ||
|
||
Description: | ||
Returns the transposed matrix. | ||
|
||
Accepts any mxn matrix. | ||
|
||
Parameters: | ||
_matrix - mxn matrix to transpose. <ARRAY> | ||
|
||
Returns: | ||
_returnMatrix - nxm matrix <ARRAY> | ||
|
||
Examples: | ||
(begin example) | ||
// returns the transposed matrix [[1,3,2], [2,1,3], [3,2,1]] | ||
[[[1,2,3], [3,1,2], [2,3,1]]] call CBA_fnc_matrixTranspose; | ||
(end) | ||
|
||
Author: | ||
Kyle Kotowick, Kex | ||
---------------------------------------------------------------------------- */ | ||
|
||
#include "script_component.hpp" | ||
|
||
params [["_matrix", [], [[]]]]; | ||
|
||
private _m = count _matrix; | ||
private _n = count (_matrix select 0); | ||
|
||
private _returnMatrix = []; | ||
|
||
for "_j" from 0 to (_n - 1) do | ||
{ | ||
private _returnRow = []; | ||
for "_i" from 0 to (_m - 1) do | ||
{ | ||
_returnRow pushBack ((_matrix select _i) select _j); | ||
}; | ||
_returnMatrix pushBack _returnRow; | ||
}; | ||
|
||
_returnMatrix; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_vectMap3D | ||
|
||
Description: | ||
Returns the resulting vector of the product matrix-vector product. | ||
|
||
Only accepts a 3x3 matrices and 3D vector. | ||
|
||
Parameters: | ||
_matrix - 3x3 matrix, which serves as a map. <ARRAY> | ||
_vector - 3D vector that is mapped. <ARRAY> | ||
|
||
Returns: | ||
_returnVector - 3D vector returned after matrix multiplication <ARRAY> | ||
|
||
Examples: | ||
(begin example) | ||
// point reflection at origin [0,0,0] | ||
[[[-1,0,0],[0,-1,0],[0,0,-1]], [1,2,3]] call CBA_fnc_vectMap3D; | ||
(end) | ||
|
||
Author: | ||
Kex | ||
---------------------------------------------------------------------------- */ | ||
|
||
#include "script_component.hpp" | ||
|
||
params[["_matrix", [], [[]], 3], ["_vector", [], [[]], 3]]; | ||
_matrix apply {_x vectorDotProduct _vector}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
apply
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, the same goes for
CBA_fnc_matrixProduct3D
.