标签:distance tar vector enc double fun a+b sqrt function
double getDistance(cv::Point pointO, cv::Point pointA) { double distance; distance = powf((pointO.x - pointA.x), 2) + powf((pointO.y - pointA.y), 2); distance = sqrt(distance); return distance; } /* @function 求四个点所围面积 */ double get4PointArea(std::vector<Point2f> points) { double d01, d12, d23, d30, d13; double k1, k2, s1, s2; d01 = getDistance(points[0], points[1]); d12 = getDistance(points[1], points[2]); d23 = getDistance(points[2], points[3]); d30 = getDistance(points[3], points[0]); d13 = getDistance(points[1], points[3]); k1 = (d01 + d30 + d13) / 2; k2 = (d12 + d23 + d13) / 2; s1 = sqrt(k1*(k1 - d01)*(k1 - d30)*(k1 - d13)); s2 = sqrt(k2*(k2 - d12)*(k2 - d23)*(k2 - d13)); return s1 + s2; }
将四边形分为两个三角形,根据海伦公式:s=(a+b+c)/2,则面积=√s(s-a)(s-b)(s-c)
标签:distance tar vector enc double fun a+b sqrt function
原文地址:https://www.cnblogs.com/yuexiachacha/p/13998503.html