On Sunday, 27 December 2015 at 16:00:34 UTC, jkpl wrote:
On Sunday, 27 December 2015 at 15:53:55 UTC, TheDGuy wrote:
Any idea what i am doing wrong?
https://www.youtube.com/watch?v=j_VCa-5VeP8

You could post the code also, personnaly I'm always almost at 2 meters from my screen, with zoom, so I can't read the code...

Sry:

                Vector3D v = ray.origin.sub(this.center).normalize();
                double a = ray.direction.dot(ray.direction);
                double b = 2.0 * ray.direction.dot(v);
                double c = v.dot(v) - (this.radius * this.radius);
                double discriminant = (b*b) - (4.0*a*c);
                if(discriminant > 0){
                        double x1 = (-b - sqrt(discriminant)) / (2.0*a);
                        double x2 = (-b + sqrt(discriminant)) / (2.0*a);
                        if((x1 >= 0) && (x2 >= 0)){
                                return x1;
                        }
                        if((x1 < 0) & (x2 >= 0)){
                                return x2;
                        }
                        return -1.0;
                }else{
                        return -1.0;
                }

Reply via email to