Related functions for Simd::Point structure. More...
Functions | |
| template<typename T > | |
| bool | operator== (const Point< T > &p1, const Point< T > &p2) |
| Compares two points on equality of both coordinates. More... | |
| template<typename T > | |
| bool | operator!= (const Point< T > &p1, const Point< T > &p2) |
| Compares two points on inequality of either coordinate. More... | |
| template<typename T > | |
| Point< T > | operator+ (const Point< T > &p1, const Point< T > &p2) |
| Adds two points component-wise. More... | |
| template<typename T > | |
| Point< T > | operator- (const Point< T > &p1, const Point< T > &p2) |
| Subtracts two points component-wise. More... | |
| template<typename T > | |
| Point< T > | operator* (const Point< T > &p1, const Point< T > &p2) |
| Multiplies two points component-wise. More... | |
| template<typename T > | |
| Point< T > | operator/ (const Point< T > &p1, const Point< T > &p2) |
| Divides two points component-wise. More... | |
| template<typename T > | |
| Point< T > | operator- (const Point< T > &p) |
| Returns the point with both coordinates negated. More... | |
| template<typename TP , typename TA > | |
| Point< TP > | operator/ (const Point< TP > &p, const TA &a) |
| Divides both coordinates by a scalar. More... | |
| template<typename TP , typename TA > | |
| Point< TP > | operator* (const Point< TP > &p, const TA &a) |
| Multiplies both coordinates by a scalar. More... | |
| template<typename TP , typename TA > | |
| Point< TP > | operator* (const TA &a, const Point< TP > &p) |
| Multiplies a scalar by both coordinates of a point. More... | |
| template<typename T > | |
| T | SquaredDistance (const Point< T > &p1, const Point< T > &p2) |
| Returns the squared Euclidean distance between two points. More... | |
| template<typename T > | |
| double | Distance (const Point< T > &p1, const Point< T > &p2) |
| Returns the Euclidean distance between two points. More... | |
| template<typename T > | |
| T | DotProduct (const Point< T > &p1, const Point< T > &p2) |
| Returns the dot product of two points. More... | |
| template<typename T > | |
| T | CrossProduct (const Point< T > &p1, const Point< T > &p2) |
| Returns the z component of the 2D cross product. More... | |
Detailed Description
Related functions for Simd::Point structure.
Function Documentation
◆ operator==()
Compares two points on equality of both coordinates.
x and y are compared independently. Pyramid::Recreate skips rebuilding when the requested size compares equal to the size of pyramid level 0. Motion::Calibrate keeps the current model when the new frame size compares equal to originalFrameSize.
- Parameters
-
[in] p1 - a first point. [in] p2 - a second point.
- Returns
- true when both coordinates are equal.
◆ operator!=()
Compares two points on inequality of either coordinate.
ShiftDetector::Estimate requires the initialized frame size to differ from Point() before it accepts a current image.
- Parameters
-
[in] p1 - a first point. [in] p2 - a second point.
- Returns
- true when x or y differs.
◆ operator+()
Adds two points component-wise.
The result is (p1.x + p2.x, p1.y + p2.y). Motion segmentation walks the 4-neighbourhood with current + Point(-1, 0), current + Point(0, -1), current + Point(1, 0) and current + Point(0, 1), then passes the sum to View::At.
- Parameters
-
[in] p1 - a first point. [in] p2 - a second point.
- Returns
- the component-wise sum.
◆ operator-() [1/2]
Subtracts two points component-wise.
The result is (p1.x - p2.x, p1.y - p2.y). ExpandRoi places the child top-left corner at parentTopLeft * 2 - Point(1, 1). SquaredDistance subtracts the two points before squaring the components.
- Parameters
-
[in] p1 - a first point. [in] p2 - a second point.
- Returns
- the component-wise difference.
◆ operator*() [1/3]
Multiplies two points component-wise.
The result is (p1.x * p2.x, p1.y * p2.y). This is not a dot product and not a scale of one point by a scalar. Use DotProduct for the sum of component products, and operator*(point, scalar) to scale both coordinates by one value.
- Parameters
-
[in] p1 - a first point. [in] p2 - a second point.
- Returns
- the component-wise product.
◆ operator/() [1/2]
Divides two points component-wise.
The result is (p1.x / p2.x, p1.y / p2.y). Integer coordinates use integer division and truncate toward zero. Use operator/(point, scalar) to divide both coordinates by one value.
- Parameters
-
[in] p1 - a first point. [in] p2 - a second point. Neither coordinate may be zero.
- Returns
- the component-wise quotient.
◆ operator-() [2/2]
Returns the point with both coordinates negated.
The result is (-p.x, -p.y). A one-pixel step toward the origin can be written as a negative point, for example Point(-1, 0), which the motion flood-fill stores in its neighbour table.
- Parameters
-
[in] p - an original point.
- Returns
- the negated point.
◆ operator/() [2/2]
Divides both coordinates by a scalar.
The result is Point<TP>(p.x / a, p.y / a). Construction converts the quotients back to TP, so Point<ptrdiff_t> divided by a floating value is rounded to the nearest integer. The member operator /= always divides by double and writes the rounded values into the same point.
- Parameters
-
[in] p - a point. [in] a - a non-zero scalar value.
- Returns
- the scaled point.
◆ operator*() [2/3]
Multiplies both coordinates by a scalar.
The result is Point<TP>(p.x * a, p.y * a). Motion::ExpandRoi maps a rectangle from a parent pyramid level to the child level with TopLeft() * 2 and BottomRight() * 2. A floating factor applied to Point<ptrdiff_t> is rounded by the Point constructor. The member operator *= writes the same products into the original point.
- Parameters
-
[in] p - a point. [in] a - a scalar value.
- Returns
- the scaled point.
◆ operator*() [3/3]
Multiplies a scalar by both coordinates of a point.
The result is the same as p * a: Point<TP>(p.x * a, p.y * a). Point<ptrdiff_t> constructed from a floating product is rounded.
- Parameters
-
[in] a - a scalar value. [in] p - a point.
- Returns
- the scaled point.
◆ SquaredDistance()
Returns the squared Euclidean distance between two points.
The value is (p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y) and has type T. Callers compare distances without computing a square root. Motion picks the tracked object nearest to a moving region by the smallest SquaredDistance between object->center and region.rect.Center(). An object becomes Moving when SquaredDistance(trajectory.back()->point, pointStart) reaches squareShiftMin. That threshold is SquaredDistance(frameSize, Point()) * shiftMin * shiftMin, the squared frame diagonal scaled by the relative shift. TestShift rejects a detection when SquaredDistance(FPoint(appliedShift), refinedShift) is greater than 1. For integer T the sum of squares can overflow.
- Parameters
-
[in] p1 - a first point. [in] p2 - a second point.
- Returns
- the squared distance. It is 0 when the points are equal.
◆ Distance()
Returns the Euclidean distance between two points.
The value is the square root of SquaredDistance, always as double. Motion tracking and the shift test compare SquaredDistance instead, so they avoid the square root and keep the comparison in the coordinate type.
- Parameters
-
[in] p1 - a first point. [in] p2 - a second point.
- Returns
- the distance. It is 0 when the points are equal.
◆ DotProduct()
Returns the dot product of two points.
The value is p1.x * p2.x + p1.y * p2.y and has type T. It is the sum of the component-wise products, not the point returned by operator*. For integer T the sum can overflow. This is unrelated to the depthwise-convolution dot product used by Synet.
- Parameters
-
[in] p1 - a first point. [in] p2 - a second point.
- Returns
- the dot product.
◆ CrossProduct()
Returns the z component of the 2D cross product.
The value is p1.x * p2.y - p1.y * p2.x and has type T. Its sign is the orientation of the two vectors and its magnitude is the area of the parallelogram they span. For integer T the products can overflow.
- Parameters
-
[in] p1 - a first point. [in] p2 - a second point.
- Returns
- the signed cross product.