Skip to content

Commit

Permalink
Added useful methods for dealing with matrices/vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
fkeglevich committed Jan 21, 2019
1 parent 4469f63 commit a569cff
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/src/main/java/com/fkeglevich/rawdumper/util/MathUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ public static double[] multiply3x3MatrixToVector3(double[] m, double[] v)
v[0]*m[6] + v[1]*m[7] + v[2]*m[8]};
}

public static double[] scalarMultiply(double[] m, double s)
{
double[] result = m.clone();
for (int i = 0; i < result.length; i++)
result[i] *= s;

return result;
}

public static double[] sum(double[] m, double[] m2)
{
double[] result = m.clone();
for (int i = 0; i < result.length; i++)
result[i] += m2[i];

return result;
}

@NonNull
public static float[] multiply3x3Matrices(@NonNull float[] a, @NonNull float[] b)
{
Expand Down

0 comments on commit a569cff

Please sign in to comment.