I am attempting to create a quantized mesh terrain tile, but am having difficulty correctly computing the horizon occlusion point. I have read through https://cesiumjs.org/2013/05/09/Computing-the-horizon-occlusion-point/, http://cesiumjs.org/2013/04/25/Horizon-culling/, and http://blogs.agi.com/insight3d/index.php/2009/03/25/horizon-culling-2/ and believe I understand the basic idea, but cannot seem to comprehend the implementations offered.
For the example:
function computeMagnitude(ellipsoid, position, scaledSpaceDirectionToPoint) {
var scaledSpacePosition = ellipsoid.transformPositionToScaledSpace(position);
var magnitudeSquared = scaledSpacePosition.magnitudeSquared();
var magnitude = Math.sqrt(magnitudeSquared);
var direction = scaledSpacePosition.divideByScalar(magnitude);
// For the purpose of this computation, points below the ellipsoid
// are considered to be on it instead.
magnitudeSquared = Math.max(1.0, magnitudeSquared);
magnitude = Math.max(1.0, magnitude);
var cosAlpha = direction.dot(scaledSpaceDirectionToPoint);
var sinAlpha = direction.cross(scaledSpaceDirectionToPoint).magnitude();
var cosBeta = 1.0 / magnitude;
var sinBeta = Math.sqrt(magnitudeSquared - 1.0) * cosBeta;
return 1.0 / (cosAlpha * cosBeta - sinAlpha * sinBeta);
}
what is scaledSpaceDirectionToPoint? if it is a unit vector pointing to position, then isn't it the same as direction?