Dear all,
I have an algorithm for 2D ray tracing but I don’t know how to convert them into codes:-
color Ray(point S, vector D, int depth)
{
point I; /* intersection point /
vector R; / reflected direction /
vector T; / transmitted direction /
color Lc; / local illumination /
color Rc; / reflected color /
color Tc; / transmitted color /
color Ac; / accumulated color */
if (depth > MAXDEPTH) {
Ac := BLACK;
}
else
{ I := nerestIntersectionPoint (S,D);
if (noIntersection(I)) {
Ac := BLACK;
} else {
Lc := LocalIllumination (I);
R := ReflectedDirection (I,D);
Rc := Ray (I,R,depth+1);
T := TransmittedDirection (I,D);
Tc := Ray (I,T, depth+1);
Ac := Combine (Lc, Rc, Tc);
}
} return Ac; }