-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointLight.java
More file actions
49 lines (37 loc) · 1.05 KB
/
Copy pathPointLight.java
File metadata and controls
49 lines (37 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package elements;
import primitives.Color;
import primitives.Point_3D;
import primitives.Vector;
public class PointLight extends Light implements LightSource {
protected Point_3D _position;
protected double _Kc;
protected double _Kl;
protected double _Kq;
// ***************** Constructors ********************** //
public PointLight(Color color, Point_3D position, double kc, double kl, double kq) {
super(color);
_position = position;
_Kc = kc;
_Kl = kl;
_Kq = kq;
}
// ***************** Getters/Setters ********************** //
public Color color() {
return _color;
}
// ***************** Operations ******************** //
@Override
public Color getIntensity(Point_3D point) {
double d = point.distance(_position);
double m = _Kc + (_Kl * d) + (_Kq * d * d);
return new Color(_color).reduce(m);
}
@Override
public Vector getL(Point_3D point) {
return point.subtract(_position).normalize();
}
@Override
public Vector getD(Point_3D point) {
return getL(point);
}
}