
public class Plane extends Shape
{
	public Vector Normal ; 
	public Point3D P ; 
	
	float t ; 
	private float EPS = 0.00001f ; 
	
	
	public Plane(){} ; 
	
	public Plane ( Vector Normal , Point3D P , Material material )
	{
		this.Normal = Normal ; 
		this.P = P ;  
		this.material = material ; 
	};

	@Override
	public boolean Intersect(Ray ray) 
	{
		Vector v = new Vector (  ray.getPos() , this.P  ) ;
		ray.normalize();
		//v.norm() ; 
		this.Normal.normalize();
		
		float den = ray.getDir().dot(this.Normal) ; 
		
		// Check if crossing the plane
		if ( den < EPS ) 
		{
			this.t = v.dot(this.Normal ) / den ;
			return ( this.t >= 0 ) ; 
		}
		
		return false ;
	};

	@Override
	public Vector getNormal(Point3D p)
	{
		 return this.Normal ; 
	};

	@Override
	public float getInter() 
	{
		return this.t ; 
	};

	@Override
	public Material getMaterial() 
	{
		return this.material;
	};
	
}


public class Plane extends Shape
{
	public Vector Normal ; 
	public Point3D P ; 
	
	float t ; 
	private float EPS = 0.00001f ; 
	
	
	public Plane(){} ; 
	
	public Plane ( Vector Normal , Point3D P , Material material )
	{
		this.Normal = Normal ; 
		this.P = P ;  
		this.material = material ; 
	};

	@Override
	public boolean Intersect(Ray ray) 
	{
		ray.normalize();
		Vector v = new Vector ( this.P  , ray.getPos() ) ;
		
		// Check if parallel
		if ( ray.getDir().dot(Normal)  < EPS ) return false ;
		
		t = v.dot( Normal ) / ray.getDir().dot( Normal ) ;
		
		return true ;
		
		/*
		Vector v = new Vector ( this.P  , ray.getPos() ) ;
		t = v.dot( Normal ) / ray.getDir().dot( Normal ) ;
		//System.out.println( t );
		return ( ray.getDir().dot(this.Normal) < EPS ) ; 
		*/	
	};

	@Override
	public Vector getNormal(Point3D p)
	{
		 return this.Normal ; 
	};

	@Override
	public float getInter() 
	{
		return this.t ; 
	};

	@Override
	public Material getMaterial() 
	{
		return this.material;
	};
	
}

--- 
+++ 
@@ -20,22 +20,21 @@
 	@Override
 	public boolean Intersect(Ray ray) 
 	{
+		Vector v = new Vector (  ray.getPos() , this.P  ) ;
 		ray.normalize();
-		Vector v = new Vector ( this.P  , ray.getPos() ) ;
+		//v.norm() ; 
+		this.Normal.normalize();
 		
-		// Check if parallel
-		if ( ray.getDir().dot(Normal)  < EPS ) return false ;
+		float den = ray.getDir().dot(this.Normal) ; 
 		
-		t = v.dot( Normal ) / ray.getDir().dot( Normal ) ;
+		// Check if crossing the plane
+		if ( den < EPS ) 
+		{
+			this.t = v.dot(this.Normal ) / den ;
+			return ( this.t >= 0 ) ; 
+		}
 		
-		return true ;
-		
-		/*
-		Vector v = new Vector ( this.P  , ray.getPos() ) ;
-		t = v.dot( Normal ) / ray.getDir().dot( Normal ) ;
-		//System.out.println( t );
-		return ( ray.getDir().dot(this.Normal) < EPS ) ; 
-		*/	
+		return false ;
 	};
 
 	@Override
Change the ray - plane intersection function