home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
pstn.zip
/
zip
/
HPosition.cpv
< prev
next >
Wrap
Text File
|
1995-09-07
|
3KB
|
124 lines
// Feature source code generation begins here...
INotificationId HPosition::longitudeId = "HPosition::longitude";
INotificationId HPosition::latitudeId = "HPosition::latitude";
INotificationId HPosition::radiusId = "HPosition::radius";
double HPosition::longitude() const
{
return iLongitude * RAD2DEG;
}
HPosition& HPosition::setLongitude(double aLongitude)
{
if (!(iLongitude == aLongitude * DEG2RAD))
{
iLongitude = aLongitude * DEG2RAD;
notifyObservers(INotificationEvent(HPosition::longitudeId, *this));
} // endif
return *this;
}
double HPosition::latitude() const
{
return iLatitude * RAD2DEG;
}
HPosition& HPosition::setLatitude(double aLatitude)
{
if (!(iLatitude == aLatitude * DEG2RAD))
{
iLatitude = aLatitude * DEG2RAD;
notifyObservers(INotificationEvent(HPosition::latitudeId, *this));
} // endif
return *this;
}
double HPosition::radius() const
{
return iRadius;
}
HPosition& HPosition::setRadius(double aRadius)
{
if (!(iRadius == aRadius))
{
iRadius = aRadius;
notifyObservers(INotificationEvent(HPosition::radiusId, *this));
} // endif
return *this;
}
double HPosition::distanceTo(const HPosition& pos)
{
double dist = distAngle( pos ) * iRadius;
return ( dist );
}
double HPosition::headingTo(const HPosition& pos)
{
if (pos.iLatitude >= iLatitude && pos.iLongitude >= iLongitude )
{
return alpha(pos) * RAD2DEG;
}
else
{
if (pos.iLatitude <= iLatitude && pos.iLongitude >= iLongitude )
{
return 180. - beta(pos) * RAD2DEG;
}
else
{
if (pos.iLatitude <= iLatitude && pos.iLongitude <= iLongitude )
{
return alpha(pos) * RAD2DEG + 180.;
}
else
{
return 360. - beta(pos) * RAD2DEG;
}
}
}
return 0.;
}
double HPosition::distAngle(const HPosition& pos)
{
double cos_e = sin(pos.iLatitude) * sin(iLatitude) +
cos(pos.iLatitude) * cos(iLatitude) *
cos(fabs(iLongitude - pos.iLongitude));
return acos(cos_e);
}
double HPosition::alpha(const HPosition& pos)
{
double e = distAngle( pos );
if ( e == 0 ) return 0;
return asin( sin(fabs(iLongitude - pos.iLongitude))
* cos(pos.iLatitude) / sin(e));
}
double HPosition::beta(const HPosition& pos)
{
double e = distAngle( pos );
if ( e == 0 ) return 0;
return asin(sin(fabs(iLongitude - pos.iLongitude))
* cos(iLatitude) / sin(e));
}
Boolean HPosition::isValid()
{
if (iLatitude >= -PI && iLatitude <= PI &&
iLongitude >= -PI/2. && iLongitude <= PI/2. )
{
return true;
} else {
return false;
}
return false;
}
// Feature source code generation ends here.