box2d library
Exports
Functions
void Matrix3_solve33ToOut(Matrix3 a, Vector3 b, Vector3 out) #
Solve A * x = b, where b is a column vector. This is more efficient than computing the inverse in one-shot cases. out: the result
void Matrix3_solve33ToOut(Matrix3 a, Vector3 b, Vector3 out) { a.getColumn(1).crossInto(a.getColumn(2), out); double det = a.getColumn(0).dot(out); if (det != 0.0){ det = 1.0 / det; } a.getColumn(1).crossInto(a.getColumn(2), out); final double x = det * b.dot(out); b.crossInto(a.getColumn(2), out); final double y = det * a.getColumn(0).dot(out); a.getColumn(1).crossInto(b, out); double z = det * a.getColumn(0).dot(out); out.x = x; out.y = y; out.z = z; }
void Matrix3_solve22ToOut(Matrix3 a, Vector2 b, Vector2 out) #
Solve A * x = b, where b is a column vector. This is more efficient than computing the inverse in one-shot cases.
void Matrix3_solve22ToOut(Matrix3 a, Vector2 b, Vector2 out) { final double a11 = a.entry(0,0); final double a12 = a.entry(0,1); final double a21 = a.entry(1,0); final double a22 = a.entry(1,1); double det = a11 * a22 - a12 * a21; if (det != 0.0){ det = 1.0 / det; } out.x = det * (a22 * b.x - a12 * b.y); out.y = det * (a11 * b.y - a21 * b.x); }
void Matrix2_solveToOut(Matrix2 a, Vector2 b, Vector2 out) #
void Matrix2_solveToOut(Matrix2 a, Vector2 b, Vector2 out) { final double a11 = a.entry(0,0); final double a12 = a.entry(0,1); final double a21 = a.entry(1,0); final double a22 = a.entry(1,1); double det = a11 * a22 - a12 * a21; if (det != 0.0){ det = 1.0 / det; } final double tempy = det * (a11 * b.y - a21 * b.x) ; out.x = det * (a22 * b.x - a12 * b.y); out.y = tempy; }
void Vector2_maxToOut(Vector2 a, Vector2 b, Vector2 out) #
Take the maximum of each coordinate from the two given vectors and store the result in the given out vector.
void Vector2_maxToOut(Vector2 a, Vector2 b, Vector2 out) { out.x = Math.max(a.x, b.x); out.y = Math.max(a.y, b.y); }
void Vector2_minToOut(Vector2 a, Vector2 b, Vector2 out) #
Take the minimum of each coordinate from the two given vectors and store the result in the given out vector.
void Vector2_minToOut(Vector2 a, Vector2 b, Vector2 out) { out.x = Math.min(a.x, b.x); out.y = Math.min(a.y, b.y); }
void Vector2_crossVectorAndNumToOut(Vector2 a, double s, Vector2 out) #
The following functions previously were implementend as methods in the Vector and Matrix classes.
Since we use the vector_math library these methods are not available anymore.
Has the effect of swapping the x and y coordinates of the vector, multiplying both by the given number, and then flipping the sign of the new y coordinate. Returns the result through the out parameter.
void Vector2_crossVectorAndNumToOut(Vector2 a, double s, Vector2 out) { double tempy = -s * a.x; out.x = s * a.y; out.y = tempy; }