bool csReversibleTransform::LookAtGeneric ( const csVector3 &v, const csVector3 &upNeg, csVector3& w1, csVector3& w2, csVector3& w3) { csVector3 up = -upNeg; w3 = v; float sqr; sqr = v * v; if (sqr > SMALL_EPSILON) { w3 *= csQisqrt (sqr); w1 = w3 % up; sqr = w1 * w1; if (sqr < SMALL_EPSILON) { w1 = w3 % csVector3 (0, 0, -1); sqr = w1 * w1; if (sqr < SMALL_EPSILON) { w1 = w3 % csVector3 (0, -1, 0); sqr = w1 * w1; } } w1 *= csQisqrt (sqr); w2 = w3 % w1; return true; } return false; }
void PerspectiveImpl::ComputeDefaultAngle (float width) { float rview_fov = (float)GetDefaultFOV () * 0.5f; float disp_width = (float)width * 0.5f; float inv_disp_radius = csQisqrt ( rview_fov * rview_fov + disp_width * disp_width); default_fov_angle = 2.0f * (float)acos (disp_width * inv_disp_radius) * (360.0f / TWO_PI); }
void csSprite2DMeshObject::CheckBeam (const csVector3& /*start*/, const csVector3& pl, float sqr, csMatrix3& o2t) { // This method is an optimized version of LookAt() based on // the presumption that the up vector is always (0,1,0). // This is used to create a transform to move the intersection // to the sprites vector space, then it is tested against the 2d // coords, which are conveniently located at z=0. // The transformation matrix is stored and used again if the // start vector for the beam is in the same position. MHV. csVector3 pl2 = pl * csQisqrt (sqr); csVector3 v1( pl2.z, 0, -pl2.x); sqr = v1*v1; v1 *= csQisqrt(sqr); csVector3 v2(pl2.y * v1.z, pl2.z * v1.x - pl2.x * v1.z, -pl2.y * v1.x); o2t.Set (v1.x, v2.x, pl2.x, v1.y, v2.y, pl2.y, v1.z, v2.z, pl2.z); }