-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
75 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package elements; | ||
|
||
import primitives.Color; | ||
import primitives.Point3D; | ||
import primitives.Vector; | ||
|
||
public class FlashLight extends PointLight implements LightSource { | ||
|
||
private Vector direction; | ||
private int exp; | ||
|
||
public FlashLight(Color intensity, Point3D position, Vector direction, int exp) { | ||
super(intensity, position); | ||
if(exp<1) | ||
throw new IllegalArgumentException("exp less then 1"); | ||
this.direction = direction.normalized(); | ||
this.exp = exp; | ||
|
||
} | ||
|
||
@Override | ||
public Color getIntensity(Point3D p) { | ||
double dirL = direction.dotProduct(super.getL(p)); | ||
if (dirL <= 0) | ||
return Color.BLACK; | ||
return super.getIntensity(p).scale(Math.pow(dirL, exp)); | ||
} | ||
|
||
@Override | ||
public Vector getL(Point3D p) { | ||
return super.getL(p); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters