every thing is correct except the C corner x, that should = 0 |
It is zero, just that the representation of double is not exact. If you print the value with
std::fixed
, and a
std::precision
less than 12 it will print appropriately.
Some other improvements:
constexpr
is stronger than
const
; PI / 180.0 is also a constant value:
1 2
|
constexpr double PI = 3.1415926535897;
constexpr DTR = PI /180.0; // DTR is Degrees To Radians
|
Avoid declaring more than 1 variable per line of code, it will save you problems later.
Instead of 6 variables in your struct, consider having a struct Point, then have a std::vector<Point>.
Pass this std::vector to the function by reference, thus avoiding a raw pointer.
In C++, a struct is almost the same as a class - the only difference being the default access is
public
with struct, and
private
with class. So alternatively, your struct could be a
class
with a constructor and an interface of functions.
Edit: This will be better than having your data public.
Good Luck !!
Edit: I have to go out for awhile, I may not be able to reply to any questions.