assert
This commit is contained in:
@@ -203,10 +203,7 @@ double PIGeoPosition::height() const {
|
||||
|
||||
|
||||
PIGeoPosition &PIGeoPosition::setGeodetic(double lat, double lon, double ht, PIEllipsoidModel ell) {
|
||||
if(lat > 90 || lat < -90) {
|
||||
piCout << "[PIGeoPosition]" << "Achtung! Invalid latitude in setGeodetic:" << lat;
|
||||
assert(lat <= 90 && lat >= -90);
|
||||
}
|
||||
assertm(lat <= 90 && lat >= -90, "Achtung! Invalid latitude in setGeodetic");
|
||||
(*this)[0] = lat;
|
||||
(*this)[1] = lon;
|
||||
if((*this)[1] < 0) (*this)[1] += 360 * (1 + (unsigned long)((*this)[1]/360));
|
||||
@@ -219,14 +216,8 @@ PIGeoPosition &PIGeoPosition::setGeodetic(double lat, double lon, double ht, PIE
|
||||
|
||||
|
||||
PIGeoPosition &PIGeoPosition::setGeocentric(double lat, double lon, double rad) {
|
||||
if(lat > 90 || lat < -90) {
|
||||
piCout << "[PIGeoPosition]" << "Achtung! Invalid latitude in setGeocentric:" << lat;
|
||||
assert(lat <= 90 && lat >= -90);
|
||||
}
|
||||
if(rad < 0) {
|
||||
piCout << "[PIGeoPosition]" << "Achtung! Invalid radius in setGeocentric:" << rad;
|
||||
assert(rad >= 0);
|
||||
}
|
||||
assertm(lat <= 90 && lat >= -90, "Achtung! Invalid latitude in setGeocentric");
|
||||
assertm(rad >= 0, "Achtung! Invalid radius in setGeocentric");
|
||||
(*this)[0] = lat;
|
||||
(*this)[1] = lon;
|
||||
(*this)[2] = rad;
|
||||
@@ -238,14 +229,8 @@ PIGeoPosition &PIGeoPosition::setGeocentric(double lat, double lon, double rad)
|
||||
|
||||
|
||||
PIGeoPosition &PIGeoPosition::setSpherical(double theta, double phi, double rad) {
|
||||
if(theta < 0 || theta > 180) {
|
||||
piCout << "[PIGeoPosition]" << "Achtung! Invalid theta in setSpherical:" << theta;
|
||||
assert(theta <= 180 && theta >= 0);
|
||||
}
|
||||
if(rad < 0) {
|
||||
piCout << "[PIGeoPosition]" << "Achtung! Invalid radius in setSpherical:" << rad;
|
||||
assert(rad >= 0);
|
||||
}
|
||||
assertm(theta <= 180 && theta >= 0, "Achtung! Invalid theta in setSpherical");
|
||||
assertm(rad >= 0, "Achtung! Invalid radius in setSpherical");
|
||||
(*this)[0] = theta;
|
||||
(*this)[1] = phi;
|
||||
(*this)[2] = rad;
|
||||
@@ -439,24 +424,15 @@ bool PIGeoPosition::operator==(const PIGeoPosition &right) const {
|
||||
void PIGeoPosition::initialize(PIMathVectorT3d v, PIGeoPosition::CoordinateSystem sys, PIEllipsoidModel ell) {
|
||||
double a(v[0]), b(v[1]), c(v[2]);
|
||||
if(sys == Geodetic || sys==Geocentric) {
|
||||
if(a > 90 || a < -90) {
|
||||
piCout << "[PIGeoPosition]" << "Achtung! Invalid latitude in constructor:" << a;
|
||||
assert(a <= 90 && a >= -90);
|
||||
}
|
||||
assertm(a <= 90 && a >= -90, "Achtung! Invalid latitude in constructor");
|
||||
if(b < 0) b += 360*(1+(unsigned long)(b/360));
|
||||
else if(b >= 360) b -= 360*(unsigned long)(b/360);
|
||||
}
|
||||
if(sys==Geocentric || sys==Spherical) {
|
||||
if(c < 0) {
|
||||
piCout << "[PIGeoPosition]" << "Achtung! Invalid radius in constructor:" << c;
|
||||
assert(c >= 0);
|
||||
}
|
||||
assertm(c >= 0, "Achtung! Invalid radius in constructor");
|
||||
}
|
||||
if(sys==Spherical) {
|
||||
if(a < 0 || a > 180) {
|
||||
piCout << "[PIGeoPosition]" << "Achtung! Invalid theta in constructor:" << a;
|
||||
assert(a >= 0 && a <= 180);
|
||||
}
|
||||
assertm(a >= 0 && a <= 180, "Achtung! Invalid theta in constructor");
|
||||
if(b < 0) b += 360*(1+(unsigned long)(b/360));
|
||||
else if(b >= 360) b -= 360*(unsigned long)(b/360);
|
||||
}
|
||||
@@ -493,10 +469,7 @@ double PIGeoPosition::elevationGeodetic(const PIGeoPosition &p) const {
|
||||
r.transformTo(Cartesian);
|
||||
s.transformTo(Cartesian);
|
||||
PIMathVectorT3d z = s - r;
|
||||
if (z.length() <= 1e-4) { // if the positions are within .1 millimeter
|
||||
piCout << "[PIGeoPosition]" << "Positions are within .1 millimeter" << z;
|
||||
assert(z.length() > 1e-4);
|
||||
}
|
||||
assertm(z.length() > 1e-4, "Positions are within .1 millimeter");
|
||||
PIMathVectorT3d kv; // Compute k vector in local North-East-Up (NEU) system
|
||||
kv[0] = cos(lat) * cos(lng);
|
||||
kv[1] = cos(lat) * sin(lng);
|
||||
@@ -517,10 +490,7 @@ double PIGeoPosition::azimuth(const PIGeoPosition &p) const {
|
||||
xyz = xy + r[2] * r[2];
|
||||
xy = sqrt(xy);
|
||||
xyz = sqrt(xyz);
|
||||
if (xy <= 1e-14 || xyz <=1e-14) {
|
||||
piCout << "[PIGeoPosition]" << "Divide by Zero Error";
|
||||
assert(xy > 1e-14 && xyz > 1e-14);
|
||||
}
|
||||
assertm(xy > 1e-14 && xyz > 1e-14, "Divide by Zero Error");
|
||||
cosl = r[0] / xy;
|
||||
sinl = r[1] / xy;
|
||||
sint = r[2] / xyz;
|
||||
@@ -535,10 +505,7 @@ double PIGeoPosition::azimuth(const PIGeoPosition &p) const {
|
||||
p1 = (xn1 * z1) + (xn2 * z2) + (xn3 * z3) ;
|
||||
p2 = (xe1 * z1) + (xe2 * z2) ;
|
||||
test = piAbsd(p1) + piAbsd(p2);
|
||||
if (test < 1.0e-16) {
|
||||
piCout << "[PIGeoPosition]" << "azAngle(), failed p1+p2 test" << test;
|
||||
assert(test >= 1.0e-16);
|
||||
}
|
||||
assertm(test >= 1.0e-16, "azAngle(), failed p1+p2 test");
|
||||
alpha = 90 - atan2(p1, p2) * rad2deg;
|
||||
if (alpha < 0) return alpha + 360;
|
||||
else return alpha;
|
||||
@@ -553,10 +520,7 @@ double PIGeoPosition::azimuthGeodetic(const PIGeoPosition &p) const {
|
||||
s.transformTo(Cartesian);
|
||||
PIMathVectorT3d z;
|
||||
z = s - r;
|
||||
if (z.length() <= 1e-4) { // if the positions are within .1 millimeter
|
||||
piCout << "[PIGeoPosition]" << "Positions are within 0.1 millimeter" << z.length();
|
||||
assert(z.length() > 1e-4);
|
||||
}
|
||||
assertm(z.length() > 1e-4, "Positions are within 0.1 millimeter");
|
||||
PIMathVectorT3d iv; // Compute i vector in local North-East-Up (NEU) system
|
||||
iv[0] = -sin(lat) * cos(lng);
|
||||
iv[1] = -sin(lat) * sin(lng);
|
||||
|
||||
Reference in New Issue
Block a user