testbed/src/Scene.cpp
bool Scene::mapMouseCoordinatesToSphere(double xMouse, double yMouse,
                                        Vector3& spherePoint) const {

    if ((xMouse >= 0) && (xMouse <= mWindowWidth) && (yMouse >= 0) && (yMouse <= mWindowHeight)) {
        float x = float(xMouse - 0.5f * mWindowWidth) / float(mWindowWidth);
        float y = float(0.5f * mWindowHeight - yMouse) / float(mWindowHeight);
        float sinx = std::sin(PI * x * 0.5f);
        float siny = std::sin(PI * y * 0.5f);
        float sinx2siny2 = sinx * sinx + siny * siny;

        // Compute the point on the sphere
        spherePoint.x = sinx;
        spherePoint.y = siny;
        spherePoint.z = (sinx2siny2 < 1.0f) ? std::sqrt(1.0f - sinx2siny2) : 0.0f;

        return true;
    }

    return false;
}
// Map the mouse x,y coordinates to a point on a sphere
Map the mouse x,y coordinates to a point on a sphere
Map the mouse x y coordinates to a point on a sphere
bool Scene::mapMouseCoordinatesToSphere(double xMouse, double yMouse,
                                        Vector3& spherePoint) const {
    if ((xMouse >= 0) && (xMouse <= mWindowWidth) && (yMouse >= 0) && (yMouse <= mWindowHeight)) {
        float x = float(xMouse - 0.5f * mWindowWidth) / float(mWindowWidth);
        float y = float(0.5f * mWindowHeight - yMouse) / float(mWindowHeight);
        float sinx = std::sin(PI * x * 0.5f);
        float siny = std::sin(PI * y * 0.5f);
        float sinx2siny2 = sinx * sinx + siny * siny;
        spherePoint.x = sinx;
        spherePoint.y = siny;
        spherePoint.z = (sinx2siny2 < 1.0f) ? std::sqrt(1.0f - sinx2siny2) : 0.0f;
        return true;
    }
    return false;
}
bool Scene :: mapMouseCoordinatesToSphere ( double xMouse , double yMouse , Vector3 & spherePoint ) const { if ( ( xMouse >= 0 ) && ( xMouse <= mWindowWidth ) && ( yMouse >= 0 ) && ( yMouse <= mWindowHeight ) ) { float x = float ( xMouse - 0.5f * mWindowWidth ) / float ( mWindowWidth ) ; float y = float ( 0.5f * mWindowHeight - yMouse ) / float ( mWindowHeight ) ; float sinx = std :: sin ( PI * x * 0.5f ) ; float siny = std :: sin ( PI * y * 0.5f ) ; float sinx2siny2 = sinx * sinx + siny * siny ; spherePoint . x = sinx ; spherePoint . y = siny ; spherePoint . z = ( sinx2siny2 < 1.0f ) ? std :: sqrt ( 1.0f - sinx2siny2 ) : 0.0f ; return true ; } return false ; }
Map the mouse x,y coordinates to a point on a sphere
Map the mouse x y coordinates to a point on a sphere
// Compute the point on the sphere