diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-11-03 21:54:20 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-11-03 21:54:20 +0100 |
commit | 5770878427657e6317cb21c73666c9f2d36e0234 (patch) | |
tree | 5f19fa97326ac5bef38ec249539912e845856620 /crawl-ref/source/geom2d.cc | |
parent | 85ea7c827f4933d11527f5172748206654bafe9b (diff) | |
download | crawl-ref-5770878427657e6317cb21c73666c9f2d36e0234.tar.gz crawl-ref-5770878427657e6317cb21c73666c9f2d36e0234.zip |
Add get_degrees and set_degrees to ray_def; reenable chaos bolt munging.
Diffstat (limited to 'crawl-ref/source/geom2d.cc')
-rw-r--r-- | crawl-ref/source/geom2d.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crawl-ref/source/geom2d.cc b/crawl-ref/source/geom2d.cc index 720f334226..3fba76e2d3 100644 --- a/crawl-ref/source/geom2d.cc +++ b/crawl-ref/source/geom2d.cc @@ -154,5 +154,19 @@ double form::operator()(const vector& v) const return (a*v.x + b*v.y); } +double degrees(const vector &v) +{ + if (v.x == 0) + return (v.y > 0 ? 90.0 : -90.0); + double rad = v.x > 0 ? atan(v.y/v.x) : M_PI + atan(v.y/v.x); + return (180.0 / M_PI * rad); +} + +vector degree_to_vector(double d) +{ + double rad = d / 180.0 * M_PI; + return (vector(cos(rad), sin(rad))); +} + } |