Home

Download

Features

Screenshots

Handbook

Browse Source

Authors

SourceForge.net Logo
Hosted by SourceForge.net

OSI Certified


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages   Search  

rectcoord.cpp

00001 
00002 
00003 #include "rectcoord.h"
00004 #include "polarcoord.h"
00005 #include <cmath>
00006 
00007 RectCoord::RectCoord(double _x,double _y) : x(_x), y(_y)
00008 {
00009 }
00010 
00011 PolarCoord RectCoord::toPolar(int mode, bool bearing)
00012 {
00013     double angle;
00014 
00015     if (mode == DEGREES)
00016         angle = atan2(x,y)* (180 / PI);
00017     else
00018         angle = atan2(x,y);
00019                 
00020     if (bearing)
00021     {
00022         double toReturn = 90 + (360 - angle);
00023         if (toReturn >= 360)
00024         {
00025             angle = toReturn - 360;
00026         }
00027         else
00028         {
00029             angle = toReturn;
00030         }
00031     }
00032 
00033     return PolarCoord(sqrt((x * x) + (y * y)),angle,mode);
00034 }