MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / circle_norm

Method circle_norm

src/Geoscape/Globe.cpp:89–111  ·  view source on GitHub ↗

* Function returning normal vector of sphere surface * @param ox x cord of sphere center * @param oy y cord of sphere center * @param r radius of sphere * @param x cord of point where we getting this vector * @param y cord of point where we getting this vector * @return normal vector of sphere surface */

Source from the content-addressed store, hash-verified

87 * @return normal vector of sphere surface
88 */
89 inline Cord circle_norm(double ox, double oy, double r, double x, double y)
90 {
91 const double limit = r*r;
92 const double norm = 1./r;
93 Cord ret;
94 ret.x = (x-ox);
95 ret.y = (y-oy);
96 const double temp = (ret.x)*(ret.x) + (ret.y)*(ret.y);
97 if(limit > temp)
98 {
99 ret.x *= norm;
100 ret.y *= norm;
101 ret.z = sqrt(limit - temp)*norm;
102 return ret;
103 }
104 else
105 {
106 ret.x = 0.;
107 ret.y = 0.;
108 ret.z = 0.;
109 return ret;
110 }
111 }
112
113 //initialization
114 GlobeStaticData() : random_surf_size(60)

Callers 1

setupRadiiMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected