mirror of
https://github.com/vonhyou/ray-tracer-comp371.git
synced 2025-06-08 07:22:01 +00:00
add ray constructor
This commit is contained in:
parent
29c5fe91d9
commit
e4e2d26a16
2 changed files with 23 additions and 2 deletions
|
@ -4,6 +4,13 @@ void Geometry::setTransform(const Matrix4f &transform) {
|
|||
this->transform = transform;
|
||||
}
|
||||
|
||||
bool Sphere::intersect(const Ray &r) const { return false; }
|
||||
bool Sphere::intersect(const Ray &r) const {
|
||||
Vector3f originCenter = r.getOrigin() - center;
|
||||
int a = r.getDirection().dot(r.getDirection());
|
||||
int b = 2 * originCenter.dot(r.getDirection());
|
||||
int c = originCenter.dot(originCenter) - radius * radius;
|
||||
|
||||
return b * b - 4 * a * c >= 0;
|
||||
}
|
||||
|
||||
bool Rectangle::intersect(const Ray &r) const { return false; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue