Exemplo n.º 1
0
        protected Vector3 IntersectionSearch(Vector3 prevPoint, Vector3 velocity, SchwarzschildBlackHoleEquation equation)
        {
            float   stepLow = 0, stepHigh = equation.StepSize;
            Vector3 newPoint = prevPoint;
            Vector3 tempVelocity;

            while (true)
            {
                float stepMid = (stepLow + stepHigh) / 2;
                newPoint     = prevPoint;
                tempVelocity = velocity;
                equation.Function(ref newPoint, ref tempVelocity, stepMid);

                float distanceSqr = (newPoint - center).LengthSquared();
                if (Math.Abs(stepHigh - stepLow) < 0.00001)
                {
                    break;
                }
                if (distanceSqr < radiusSqr)
                {
                    stepHigh = stepMid;
                }
                else
                {
                    stepLow = stepMid;
                }
            }
            return(newPoint);
        }
Exemplo n.º 2
0
        protected Vector3 IntersectionSearch(int side, Vector3 prevPoint, Vector3 velocity, SchwarzschildBlackHoleEquation equation)
        {
            float   stepLow = 0, stepHigh = equation.StepSize;
            Vector3 newPoint = prevPoint;
            Vector3 tempVelocity;

            while (true)
            {
                float stepMid = (stepLow + stepHigh) / 2;
                newPoint     = prevPoint;
                tempVelocity = velocity;
                equation.Function(ref newPoint, ref tempVelocity, stepMid);

                if (Math.Abs(stepHigh - stepLow) < 0.00001)
                {
                    break;
                }
                if (side * newPoint.Y > 0)
                {
                    stepHigh = stepMid;
                }
                else
                {
                    stepLow = stepMid;
                }
            }
            return(newPoint);
        }