MCPcopy Create free account
hub / github.com/davidrmiller/biosim4 / raySameness

Method raySameness

src/basicTypes.cpp:162–170  ·  view source on GitHub ↗

returns -1.0 (opposite directions) .. +1.0 (same direction) returns 1.0 if either vector is (0,0)

Source from the content-addressed store, hash-verified

160// returns -1.0 (opposite directions) .. +1.0 (same direction)
161// returns 1.0 if either vector is (0,0)
162float Coord::raySameness(Coord other) const
163{
164 int64_t mag = ((int64_t)x * x + y * y) * (other.x * other.x + other.y * other.y);
165 if (mag == 0) {
166 return 1.0; // anything is "same" as zero vector
167 }
168
169 return (x * other.x + y * other.y) / std::sqrt(mag);
170}
171
172
173// returns -1.0 (opposite directions) .. +1.0 (same direction)

Callers 1

unitTestBasicTypesFunction · 0.80

Calls 1

asNormalizedCoordMethod · 0.80

Tested by 1

unitTestBasicTypesFunction · 0.64