@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
21 lines (19 loc) • 765 B
JavaScript
import { v3_dot } from "./v3_dot.js";
/**
* Orthogonal distance of a point to a plane, the distance is positive when the point lies above the plane and negative when the point is below
* @param {number} x Reference point, x coordinate
* @param {number} y Reference point, y coordinate
* @param {number} z Reference point, z coordinate
* @param {number} normal_x
* @param {number} normal_y
* @param {number} normal_z
* @param {number} plane_offset
* @returns {number}
*/
export function v3_distance_above_plane(
x, y, z,
normal_x, normal_y, normal_z, plane_offset
) {
// this is the same as v4_dot(v4(x,y,z,1.0), v4(plane.normal, plane.constant));
return v3_dot(normal_x, normal_y, normal_z, x, y, z) + plane_offset;
}