| Ray2d.java |
package graphics.draw2d;
public class Ray2d {
Vec2d p; // origin
Vec2d d; // direction
int count;
double t = 0;
Paintable object;
Vec2d vecOnLine(double _t) {
t = _t;
return d.linearComb(t, p);
}
public Ray2d(Line2d l) {
count = 0;
p = new Vec2d(l.x1, l.y1);
d = new Vec2d(l.x2 - l.x1, l.y2 - l.y1);
d.normalize();
}
public Ray2d(Vec2d _p, Vec2d _d) {
p = new Vec2d(_p);
d = new Vec2d(_d);
}
public String toString() {
return "Origin=" + p + "\ndirection=" + d;
}
}