vec2& vec2::Normalize() { float lenght = Lenght(); x = x / lenght; y = y / lenght; return *this; }
vec3& vec3::Normalize() { float lenght = Lenght(); x = x / lenght; y = y / lenght; z = z / lenght; return *this; }
MathUtils::Wvector MathUtils::Wvector::PerpendicularVec() { cv::Point2f newEnd; newEnd.x = end.x; if (begin.y != end.y) newEnd.y = begin.y - (end.x - begin.x)*(end.x - begin.x) / (end.y - begin.y); else newEnd.y = end.y + Lenght(); return Wvector(begin, newEnd); }
MathUtils::Wvector MathUtils::Wvector::ÑodirectionalVec(double lenght) { Wvector outVec; double oldLenght = Lenght(); double dx = lenght * (end.x - begin.x) / oldLenght; double dy = lenght * (end.y - begin.y) / oldLenght; outVec.begin = begin; outVec.end = begin + cv::Point2f(dx, dy); return outVec; }
Vector3d Vector3d::Normalize() const { return ( (*this) / Lenght() ); }
Vec4& Vec4::Normalize() { float scale = 1.0f / (Lenght()); (*this) *= scale; return *this; }