Post by stevenschronk on Sept 15, 2021 1:32:55 GMT
Confusion between intersect, intersects, intersection, and intersections.
Page 59 introduces a method named "intersect" that returns a collection of double t values.
<list> t intersect(sphere, ray)
On page 63 you mention an "intersection" method. I'm not really sure if this is a different method than "intersect", or a modified and renamed version of "intersect". This is what I imagined that would look like:
double intersection(double, struct sphere)
On page 64 there is a new method called "intersections" that does not seem to have a description at all.
My tests do not seem to pass because the algorithm in the lower part of page 62 is probably is not implemented correctly.
This is currently what I have for this method:
I have removed the parenthesis on the intersect1->t lines to make the equation get the same answer as Matlab (Octave).
One thing that would be tremendously helpful would be to have a couple of known inputs for this method, along with the answers for a, b, c, discriminant and the intersect->t values.
This way it would not be an all or nothing situation and I could narrow down where things start to break.
Thanks for your help.
Page 59 introduces a method named "intersect" that returns a collection of double t values.
<list> t intersect(sphere, ray)
On page 63 you mention an "intersection" method. I'm not really sure if this is a different method than "intersect", or a modified and renamed version of "intersect". This is what I imagined that would look like:
double intersection(double, struct sphere)
On page 64 there is a new method called "intersections" that does not seem to have a description at all.
My tests do not seem to pass because the algorithm in the lower part of page 62 is probably is not implemented correctly.
This is currently what I have for this method:
bool intersect(ray ray, sphere sphere, List_Head* intersection_list) {
tuple sphereToRay = tupleSub(ray.point, createPoint(0.0f, 0.0f, 0.0f));
double a = dot(ray.vector, ray.vector);
double b = 2 * dot(ray.vector, sphereToRay);
double c = dot(sphereToRay, sphereToRay) - 1;
double discriminant = pow(b, 2) - 4 * a * c;
if (discriminant < 0) {
return false;
}
intersection *intersect1 = generateIntersectWithSentinalValues();
intersection *intersect2 = generateIntersectWithSentinalValues();
intersect1->object_id = sphere.id;
intersect2->object_id = sphere.id;
intersect1->t = -b - sqrt(discriminant) / (2 * a);
intersect2->t = -b + sqrt(discriminant) / (2 * a);
if (intersect1->t < intersect2->t) {
addIntersectionToList(intersection_list, intersect1);
addIntersectionToList(intersection_list, intersect2);
}
else {
addIntersectionToList(intersection_list, intersect2);
addIntersectionToList(intersection_list, intersect1);
}
return true;
}
I have removed the parenthesis on the intersect1->t lines to make the equation get the same answer as Matlab (Octave).
One thing that would be tremendously helpful would be to have a couple of known inputs for this method, along with the answers for a, b, c, discriminant and the intersect->t values.
This way it would not be an all or nothing situation and I could narrow down where things start to break.
Thanks for your help.