Skip to content

Commit

Permalink
Merge 92d78e4 into e3de8da
Browse files Browse the repository at this point in the history
  • Loading branch information
spydon committed May 25, 2023
2 parents e3de8da + 92d78e4 commit 5b2fbd3
Show file tree
Hide file tree
Showing 10 changed files with 466 additions and 549 deletions.
24 changes: 12 additions & 12 deletions lib/src/vector_math/matrix2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class Matrix2 {

/// Sets the entire matrix to the column values.
void setColumns(Vector2 arg0, Vector2 arg1) {
final arg0Storage = arg0._v2storage;
final arg1Storage = arg1._v2storage;
final arg0Storage = arg0.storage;
final arg1Storage = arg1.storage;
_m2storage[0] = arg0Storage[0];
_m2storage[1] = arg0Storage[1];
_m2storage[2] = arg1Storage[0];
Expand All @@ -107,8 +107,8 @@ class Matrix2 {

/// Set this to the outer product of [u] and [v].
void setOuter(Vector2 u, Vector2 v) {
final uStorage = u._v2storage;
final vStorage = v._v2storage;
final uStorage = u.storage;
final vStorage = v.storage;
_m2storage[0] = uStorage[0] * vStorage[0];
_m2storage[1] = uStorage[0] * vStorage[1];
_m2storage[2] = uStorage[1] * vStorage[0];
Expand All @@ -123,7 +123,7 @@ class Matrix2 {

/// Sets the diagonal of the matrix to be [arg].
void setDiagonal(Vector2 arg) {
final argStorage = arg._v2storage;
final argStorage = arg.storage;
_m2storage[0] = argStorage[0];
_m2storage[3] = argStorage[1];
}
Expand Down Expand Up @@ -169,23 +169,23 @@ class Matrix2 {

/// Sets [row] of the matrix to values in [arg]
void setRow(int row, Vector2 arg) {
final argStorage = arg._v2storage;
final argStorage = arg.storage;
_m2storage[index(row, 0)] = argStorage[0];
_m2storage[index(row, 1)] = argStorage[1];
}

/// Gets the [row] of the matrix
Vector2 getRow(int row) {
final r = Vector2.zero();
final rStorage = r._v2storage;
final rStorage = r.storage;
rStorage[0] = _m2storage[index(row, 0)];
rStorage[1] = _m2storage[index(row, 1)];
return r;
}

/// Assigns the [column] of the matrix [arg]
void setColumn(int column, Vector2 arg) {
final argStorage = arg._v2storage;
final argStorage = arg.storage;
final entry = column * 2;
_m2storage[entry + 1] = argStorage[1];
_m2storage[entry + 0] = argStorage[0];
Expand All @@ -195,7 +195,7 @@ class Matrix2 {
Vector2 getColumn(int column) {
final r = Vector2.zero();
final entry = column * 2;
final rStorage = r._v2storage;
final rStorage = r.storage;
rStorage[1] = _m2storage[entry + 1];
rStorage[0] = _m2storage[entry + 0];
return r;
Expand Down Expand Up @@ -279,13 +279,13 @@ class Matrix2 {

/// Returns the dot product of row [i] and [v].
double dotRow(int i, Vector2 v) {
final vStorage = v._v2storage;
final vStorage = v.storage;
return _m2storage[i] * vStorage[0] + _m2storage[2 + i] * vStorage[1];
}

/// Returns the dot product of column [j] and [v].
double dotColumn(int j, Vector2 v) {
final vStorage = v._v2storage;
final vStorage = v.storage;
return _m2storage[j * 2] * vStorage[0] +
_m2storage[(j * 2) + 1] * vStorage[1];
}
Expand Down Expand Up @@ -468,7 +468,7 @@ class Matrix2 {
/// Transform [arg] of type [Vector2] using the transformation defined by
/// this.
Vector2 transform(Vector2 arg) {
final argStorage = arg._v2storage;
final argStorage = arg.storage;
final x = (_m2storage[0] * argStorage[0]) + (_m2storage[2] * argStorage[1]);
final y = (_m2storage[1] * argStorage[0]) + (_m2storage[3] * argStorage[1]);
argStorage[0] = x;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/vector_math/matrix3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ class Matrix3 {
final m01 = _m3storage[3].abs();
final m10 = _m3storage[1].abs();
final m11 = _m3storage[4].abs();
final argStorage = arg._v2storage;
final argStorage = arg.storage;
final x = argStorage[0];
final y = argStorage[1];
argStorage[0] = x * m00 + y * m01;
Expand All @@ -643,7 +643,7 @@ class Matrix3 {

/// Transforms [arg] with this.
Vector2 transform2(Vector2 arg) {
final argStorage = arg._v2storage;
final argStorage = arg.storage;
final x_ = (_m3storage[0] * argStorage[0]) +
(_m3storage[3] * argStorage[1]) +
_m3storage[6];
Expand Down
Loading

0 comments on commit 5b2fbd3

Please sign in to comment.