public void setTrajectory(Rectangle sling, Point releasePoint)
    {
        // don't update parameters if the ref point and release point are the same
        if (_trajSet &&
            _ref != null && _ref.equals(getReferencePoint(sling)) &&
            _release != null && _release.equals(releasePoint))
            return;
            
        // set the scene parameters
        _scale = sling.height + sling.width;
        _ref = getReferencePoint(sling);
        
        // set parameters for the trajectory
        _release = new Point(releasePoint.x, releasePoint.y);
        
        // find the launch angle
        _theta = Math.atan2(_release.y - _ref.y, _ref.x - _release.x);
        _theta = launchToActual(_theta);
        
        // work out initial velocities and coefficients of the parabola
        _velocity = getVelocity(_theta);
        _ux = _velocity * Math.cos(_theta);
        _uy = _velocity * Math.sin(_theta);
        _a = -0.5 / (_ux * _ux);
        _b = _uy / _ux;
        
        
        // work out points of the trajectory
	    _trajectory = new ArrayList<Point>();
        for (int x = 0; x < X_MAX; x++) {
            double xn = x / _scale;
            int y = _ref.y - (int)((_a * xn * xn + _b * xn) * _scale);
            _trajectory.add(new Point(x + _ref.x, y));
        }
        
        // turn on the setTraj flag
        _trajSet = true;
    }