diff --git a/geotypes.cpp b/geotypes.cpp index 4b91334..8afda26 100644 --- a/geotypes.cpp +++ b/geotypes.cpp @@ -62,6 +62,51 @@ Punkt3D Sphere::getPos() const { return pos; } +int Sphere::getIntersectionParam(const Ray &ray, float *param1, float *param2) { + int numerg; + // ax^2 + bx + c = 0 + segl::Punkt3D ehv(1.0f, 1.0f, 1.0f); + float a = ray.dir*ehv; + float b = 2*(ray.pos*ehv + pos*ehv); + float c = ray.pos*ray.pos + pos*pos - 2*(ray.pos*pos) - radius*radius; + + float p = b/a; + float q = c/a; + + if((p*p)/4.0f