Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages   Search   
 polarcoord.cpp00001 
00002 #include "polarcoord.h"
00003 #include "rectcoord.h"
00004 #include <cmath>
00005 
00006 PolarCoord::PolarCoord(double _radius, double _angle, int _angleMode, bool _bearing) : radius(_radius), angle(_angle), angleMode(_angleMode), bearingMode(_bearing)
00007 {
00008 }
00009 
00010 RectCoord PolarCoord::toRectangular()
00011 {
00012     double alphaX;
00013     double alphaY;
00014     if (angleMode == RADIANS)
00015     {
00016         alphaX = cos(angle) * radius;
00017         alphaY = sin(angle) * radius;
00018     }
00019     else
00020     {
00021         alphaX = cos(angle / (180 / PI)) * radius;
00022         alphaY = sin(angle / (180 / PI)) * radius;
00023     }
00024     return RectCoord(alphaX,alphaY);
00025 }
00026 
00027 double PolarCoord::x() const
00028 {
00029     double alphaX;
00030     if (angleMode == RADIANS)
00031         alphaX = cos(angle) * radius;
00032     else
00033         alphaX = cos(angle / (180 / PI)) * radius;
00034     return alphaX;
00035 }
00036 
00037 double PolarCoord::y() const
00038 {
00039     double alphaY;
00040     if (angleMode == RADIANS)
00041         alphaY = sin(angle) * radius;
00042     else
00043         alphaY = sin(angle / (180 / PI)) * radius;
00044     return alphaY;
00045 }
00046 
        |