Skip to content

Instantly share code, notes, and snippets.

@ase34
ase34 / gist:11375298
Last active February 6, 2017 20:11
bukkit plane/line intersection
/*
* See the whitepaper at https://docs.google.com/file/d/0B9Sf4F-ig8lPUlhOdHZ2ZGtzdnM
*/
public static double determinant(double[][] matrix) {
return matrix[0][0] * matrix[1][1] * matrix[2][2] + matrix[0][1] * matrix[1][2] * matrix[2][0] + matrix[0][2] * matrix[1][0] * matrix[2][1] - matrix[0][2] * matrix[1][1] * matrix[2][0] - matrix[0][1] * matrix[1][0] * matrix[2][2] - matrix[0][0] * matrix[1][2] * matrix[2][1];
}
public static Vector getIntersection(Vector linePoint, Vector lineDirection, Vector planeOrigin, Vector planeXDirection, Vector planeYDirection) {
double[][] coefficients = {
{lineDirection.getX(), -planeXDirection.getX(), -planeYDirection.getX()},