1 /** 2 * potree.js 3 * http://potree.org 4 * 5 * Copyright 2012, Markus Sch�tz 6 * Licensed under the GPL Version 2 or later. 7 * - http://potree.org/wp/?page_id=7 8 * - http://www.gnu.org/licenses/gpl-3.0.html 9 * 10 */ 11 12 /** 13 * 14 * @param distance 15 * @param normal 16 * @class 17 */ 18 function Plane(distance, normal){ 19 this.distance = distance; 20 this.normal = normal; 21 } 22 23 /** 24 * calculate distance from plane to point. 25 * distance is negative if the point is behind the plane. 26 */ 27 Plane.prototype.distanceTo = function distanceTo(point){ 28 var A = this.normal[0]; 29 var B = this.normal[1]; 30 var C = this.normal[2]; 31 32 // distance to point assuming that the plane lies at the origin 33 var d = -(A*point[0] + B*point[1] + C*point[2]); 34 35 return this.distance - d; 36 };