// Plane object. By John Haggerty (Slime).
// http://www.slimeland.com/
// Created January 21, 2003

// requires objects.js.

function Plane(normal,dist)
{
	this.norm = Vector.normalize(normal);
	this.dist = dist;
	this.setupdefaultmodifiers();
}
Plane.prototype = new Obj();
Plane.prototype.copy = function()
{
	return this.copymodifiers(new Plane(this.norm.copy(),this.dist.copy()));
}
Plane.prototype.initialize = function() {
	this.infinitebounds = true;
	this.negcenterpoint = Vector.scalar(this.norm,this.dist).neg();
	this.generalLowLevelObjectInitialization();
};
Plane.prototype.findIntersectionsUntransformed = function(ray)
{
	var a = Vector.dot(ray.dir,this.norm);
	if (a == 0) return [];
	var b = Vector.dot(this.norm,Vector.add(ray.start,this.negcenterpoint));
	return [new Intersection(-b/a,ray,this)];
}
Plane.prototype.isPointInsideUntransformed = function(pos) {
	return (Vector.dot(this.norm,Vector.add(pos,this.negcenterpoint)) <= 0);
}
Plane.prototype.getNormalAtUntransformed = function() {return this.norm;}
