/********************************************************************** * Function_Name: RotAxis * Return : * Comments : **********************************************************************/ int Transformation::RotAxis( double(&Rw)[4][4], VectorSpace w ) { w.DoNormalization(); VectorSpace m; for( int i = 0; i < 3; i++ ) { m.vs[i] = (double)(rand() % 1000)/1000; } m.DoNormalization(); VectorSpace u; u = w; u.CrossProduct(m); u.DoNormalization(); VectorSpace v; v = w; v.CrossProduct(u); // Filling Up Rw FillUpRw( Rw, u.vs, v.vs, w.vs); CheckRotationMat(Rw); return EXIT_SUCCESS; }
/********************************************************************** * Function_Name: Intersection * Return : double * Comments : returns the dist_from_sphere, if the intersection * else it returns a -1 **********************************************************************/ double Ellipse::Intersection(const Vertex& RayOrigin, const VectorSpace& Ray) const { Vertex V_Point = GetInversection_v_Point(RayOrigin, Ray); VectorSpace RayOrig2EllipCenter( RayOrigin.arr, Center.arr ); VectorSpace RayOrig2Ellip_Norm; RayOrig2Ellip_Norm = RayOrig2EllipCenter; RayOrig2Ellip_Norm.DoNormalization(); VectorSpace RayNorm; RayNorm = Ray; RayNorm.DoNormalization(); double c_dot_v = RayOrig2Ellip_Norm.Dot( RayNorm ); if( c_dot_v > 0 || Ray.RayNVal != 1 ) // Sphere is not behind the ray origin { double r = mean_radius; double c = RayOrigin.Distance( Center ); double v = V_Point.Distance( RayOrigin ); double v2 = pow(v,2); double c2 = pow(c,2); double r2 = pow(r,2); double dSquare = r2 - c2 + v2; if( dSquare < 0 ) { return -1; } else { double d = sqrt( dSquare ); double t; if( Ray.RayNVal == 1) { t = v - d; return t; } else { t = v + d; return t; } } } return -1; }