mirror of
https://github.com/NASAWorldWind/WebWorldWind.git
synced 2026-01-25 15:23:04 +00:00
Factored surfaceNormalAtPoint into GeographicProjection and modified Globe accordingly.
This commit is contained in:
parent
b53d87cd61
commit
aede2a96c1
@ -388,6 +388,12 @@ define([
|
||||
"missingResult"));
|
||||
}
|
||||
|
||||
// For backwards compatibility, check whether the projection defines a surfaceNormalAtPoint function
|
||||
// before calling it. If it's not available, use the old code to compute the normal.
|
||||
if (this.projection.surfaceNormalAtPoint) {
|
||||
return this.projection.surfaceNormalAtPoint(this, x, y, z, result);
|
||||
}
|
||||
|
||||
if (this.is2D()) {
|
||||
result[0] = 0;
|
||||
result[1] = 0;
|
||||
|
||||
@ -199,5 +199,30 @@ define([
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Computes the Cartesian surface normal vector at a specified Cartesian point.
|
||||
*
|
||||
* @param {Globe} globe The globe this projection is applied to.
|
||||
* @param {number} x The X component of the Cartesian point.
|
||||
* @param {number} y The Y component of the Cartesian point.
|
||||
* @param {number} z The Z component of the Cartesian point.
|
||||
* @param {Vec3} result A variable in which to return the computed vector.
|
||||
*
|
||||
* @returns{Vec3} The specified result argument containing the computed vector.
|
||||
* @throws {ArgumentError} If either the specified globe or result argument is null or undefined.
|
||||
*/
|
||||
GeographicProjection.prototype.surfaceNormalAtPoint = function (globe, x, y, z, result) {
|
||||
if (!result) {
|
||||
throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "GeographicProjection", "surfaceNormalAtPoint",
|
||||
"missingResult"));
|
||||
}
|
||||
|
||||
result[0] = 0;
|
||||
result[1] = 0;
|
||||
result[2] = 1;
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
return GeographicProjection;
|
||||
});
|
||||
@ -272,5 +272,21 @@ define([
|
||||
return this.northTangentAtLocation(globe, this.scratchPosition.latitude, this.scratchPosition.longitude, result);
|
||||
};
|
||||
|
||||
ProjectionWgs84.prototype.surfaceNormalAtPoint = function (globe, x, y, z, result) {
|
||||
if (!globe) {
|
||||
throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "ProjectionWgs84",
|
||||
"surfaceNormalAtPoint", "missingGlobe"));
|
||||
}
|
||||
|
||||
var eSquared = globe.equatorialRadius * globe.equatorialRadius,
|
||||
polSquared = globe.polarRadius * globe.polarRadius;
|
||||
|
||||
result[0] = x / eSquared;
|
||||
result[1] = y / polSquared;
|
||||
result[2] = z / eSquared;
|
||||
|
||||
return result.normalize();
|
||||
};
|
||||
|
||||
return ProjectionWgs84;
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user