-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtlight.cpp
81 lines (59 loc) · 1.14 KB
/
rtlight.cpp
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "rtlight.h"
#include<cmath>
RTLight::RTLight()
{
}
RTLight::RTLight(const RTLight &cpy) : pos(cpy.getPos()), ia(cpy.getIa()), ip(cpy.getIp()),color(cpy.getColor())
{
}
RTLight::RTLight(RTPoint &pos, double ia, double ip, RTColor color) : pos(pos), ia(ia), ip(ip)
{
this->color=color;
}
RTPoint RTLight::getPos() const
{
return pos;
}
void RTLight::setPos(const RTPoint &value)
{
pos = value;
}
void RTLight::generateLightRay(RTPoint &orig,RTRay &ray)
{
ray.setPos(orig);
RTVector dir = pos - orig;
dir.normalize();
ray.setDir(dir);
}
void RTLight::getVectorToLight(RTPoint &orig, RTVector &vec)
{
vec = pos - orig;
}
double RTLight::distToLight(RTPoint ori)
{
return (double)(sqrt(pow(ori.getX()-pos.getX(),2)+pow(ori.getY()-pos.getY(),2)+pow(ori.getZ()-pos.getZ(),2)));
}
double RTLight::getIa() const
{
return ia;
}
void RTLight::setIa(double value)
{
ia = value;
}
double RTLight::getIp() const
{
return ip;
}
void RTLight::setIp(double value)
{
ip = value;
}
RTColor RTLight::getColor() const
{
return color;
}
void RTLight::setColor(const RTColor &value)
{
color = value;
}