Class Point
- java.lang.Object
-
- com.microblink.documentverification.geometry.Point
-
- All Implemented Interfaces:
android.os.Parcelable
public class Point extends java.lang.Object implements android.os.Parcelable
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Pointclamp(float length)Calculate and return point clamped to given norm (length).Pointclamp(float minLength, float maxLength)Calculate and return point clamped to given norm (lengths).intdescribeContents()floatdistance(Point other)Calculates and returns the distance to given point.voiddraw(android.graphics.Canvas canvas, android.graphics.Paint paint, int pointRadius)Draws the point to given canvas with given paint.booleanequals(java.lang.Object o)floatgetX()floatgetY()booleanisZero()Returns true if point has coordinates (0,0).voidlog()Logs the point coordinates to LOG_DEBUG log.PointmakeCopy()PointmirrorX(float maxXDimension)Return point mirrored around X axis.voidmirrorXInPlace(float maxXDimension)Mirrors point around X axis.PointmirrorXY(float maxXDimension, float maxYDimension)Return point mirrored around both X and Y axisvoidmirrorXYInPlace(float maxXDimension, float maxYDimension)Mirrors point around both X and Y axisPointmirrorY(float maxYDimension)Return point mirrored around Y axis.voidmirrorYInPlace(float maxYDimension)Mirrors point around Y axis.Pointnegative()PointnegativeClone()Calculate and return negative of current point.floatnorm()Calculate and return norm of the point.Pointnormalize()Calculate and return point that has same direction as this point, but norm 1.Pointnormalize(float length)Calculate and return point that has same direction as this point, but norm as given.PointoperatorMinus(Point other)- operator on the point.PointoperatorMinusEquals(Point other)PointoperatorMultiply(float factor)Multiplication of the point with scalar.PointoperatorMultiplyEquals(float factor)PointoperatorPlus(Point other)+ operator on the point.voidoperatorPlusEquals(Point other)+= operator on the point.voidsetX(float x)Sets the x coordinate of the point.voidsetY(float y)Sets the y coordinate of the point.java.lang.StringtoString()voidwriteToParcel(android.os.Parcel dest, int flags)
-
-
-
Field Detail
-
CREATOR
@NonNull public static final android.os.Parcelable.Creator<Point> CREATOR
-
-
Constructor Detail
-
Point
public Point()
Constructor that creates default point at position (0,0).
-
Point
public Point(float x, float y)Constructor that creates point at position (x,y).- Parameters:
x- x-coordinate of the pointy- y-coordinate of the poing
-
Point
protected Point(@NonNull android.os.Parcel in)
-
-
Method Detail
-
toString
@NonNull public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isZero
public boolean isZero()
Returns true if point has coordinates (0,0).- Returns:
- true if point has coordinates (0,0).
-
operatorPlus
@NonNull public Point operatorPlus(@NonNull Point other)
+ operator on the point. Returned point is a new point. For example: c = a + b <==> c = a.operatorPlus(b);- Parameters:
other- Point to be added to current point- Returns:
- new point that is the result of addition
-
operatorPlusEquals
public void operatorPlusEquals(@NonNull Point other)+= operator on the point. For example: b+=a <==> b.operatorPlusEquals(a);- Parameters:
other- Point to be added to current point
-
operatorMinus
@NonNull public Point operatorMinus(@NonNull Point other)
- operator on the point. Returned point is a new point. For example: c = a - b <==> c = a.operatorMinus(b);- Parameters:
other- Point to be substracted from current point- Returns:
- new point that is the result of substraction
-
operatorMultiply
@NonNull public Point operatorMultiply(float factor)
Multiplication of the point with scalar. Returned point is a new point. For example: pointC = pointA * scalarB <==> c = a.operatorMultiply(b)- Parameters:
factor- Scalar with which point should be multiplied- Returns:
- new point that is the result of multiplication
-
operatorMultiplyEquals
@NonNull public Point operatorMultiplyEquals(float factor)
-
negativeClone
@NonNull public Point negativeClone()
Calculate and return negative of current point. Negative point is point mirrored to current point over (0,0) pivot.- Returns:
- Negative point.
-
negative
@NonNull public Point negative()
-
norm
public float norm()
Calculate and return norm of the point. Norm is the distance of the point and point (0,0).- Returns:
- Norm of the point.
-
normalize
@NonNull public Point normalize()
Calculate and return point that has same direction as this point, but norm 1.- Returns:
- Unit point.
-
normalize
@NonNull public Point normalize(float length)
Calculate and return point that has same direction as this point, but norm as given.- Parameters:
length- Desired norm of the point.- Returns:
- Point with norm "length".
-
clamp
@NonNull public Point clamp(float length)
Calculate and return point clamped to given norm (length). If norm of the point is larger than desired length, returns the point that has the same direction as this point, but norm "length". If norm of the point is smaller or equal to desired length, returns the clone of this point.- Parameters:
length- Desired norm to which point should be clamped.- Returns:
- Clamped point.
-
clamp
@NonNull public Point clamp(float minLength, float maxLength)
Calculate and return point clamped to given norm (lengths). If norm of the point is larger than maxLength, returns the point that has the same direction as this point, but norm "maxLength". If norm of the point is smaller than minLength, returns the point that has the same direction as this point, but norm "minLength". If norm of the point is smaller than maxLength and larger than minLength, returns the clone of this point.- Parameters:
minLength- Minimum desired norm of the point.maxLength- Maximum desired norm of the point.- Returns:
- Clamped point.
-
mirrorX
@NonNull public Point mirrorX(float maxXDimension)
Return point mirrored around X axis.- Parameters:
maxXDimension- Maximum dimension of X axis.- Returns:
- Mirrored point
-
mirrorXInPlace
public void mirrorXInPlace(float maxXDimension)
Mirrors point around X axis.- Parameters:
maxXDimension- Maximum dimension of X axis.
-
mirrorY
@NonNull public Point mirrorY(float maxYDimension)
Return point mirrored around Y axis.- Parameters:
maxYDimension- Maximum dimension of Y axis.- Returns:
- Mirrored point
-
mirrorYInPlace
public void mirrorYInPlace(float maxYDimension)
Mirrors point around Y axis.- Parameters:
maxYDimension- Maximum dimension of Y axis.
-
mirrorXY
@NonNull public Point mirrorXY(float maxXDimension, float maxYDimension)
Return point mirrored around both X and Y axis- Parameters:
maxXDimension- Maximum dimension of X axis.maxYDimension- Maximum dimension of Y axis.- Returns:
- Mirrored point.
-
mirrorXYInPlace
public void mirrorXYInPlace(float maxXDimension, float maxYDimension)Mirrors point around both X and Y axis- Parameters:
maxXDimension- Maximum dimension of X axis.maxYDimension- Maximum dimension of Y axis.
-
makeCopy
@NonNull public Point makeCopy()
-
equals
public boolean equals(@Nullable java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
distance
public float distance(@NonNull Point other)Calculates and returns the distance to given point.- Parameters:
other- Point to which distance is calculated.- Returns:
- distance to given point
-
log
public void log()
Logs the point coordinates to LOG_DEBUG log.
-
draw
public void draw(@NonNull android.graphics.Canvas canvas, @NonNull android.graphics.Paint paint, int pointRadius)Draws the point to given canvas with given paint. Point is drawn as circle of given radius.- Parameters:
canvas- Canvas to which point should be drawn.paint- Paint used to draw point.pointRadius- Radius of the circle that represents the point.
-
getX
public float getX()
- Returns:
- the x coordinate of the point
-
setX
public void setX(float x)
Sets the x coordinate of the point.- Parameters:
x- x coordinate of the point
-
getY
public float getY()
- Returns:
- the y coordinate of the point
-
setY
public void setY(float y)
Sets the y coordinate of the point.- Parameters:
y- y coordinate of the point
-
describeContents
public int describeContents()
- Specified by:
describeContentsin interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(@NonNull android.os.Parcel dest, int flags)- Specified by:
writeToParcelin interfaceandroid.os.Parcelable
-
-