Package com.microblink.blinkid.geometry
Class Point
java.lang.Object
com.microblink.blinkid.geometry.Point
- All Implemented Interfaces:
android.os.Parcelable
-
Nested Class Summary
-
Field Summary
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclamp
(float length) Calculate and return point clamped to given norm (length).clamp
(float minLength, float maxLength) Calculate and return point clamped to given norm (lengths).int
float
Calculates and returns the distance to given point.void
draw
(android.graphics.Canvas canvas, android.graphics.Paint paint, int pointRadius) Draws the point to given canvas with given paint.boolean
float
getX()
float
getY()
boolean
isZero()
Returns true if point has coordinates (0,0).void
log()
Logs the point coordinates to LOG_DEBUG log.makeCopy()
mirrorX
(float maxXDimension) Return point mirrored around X axis.void
mirrorXInPlace
(float maxXDimension) Mirrors point around X axis.mirrorXY
(float maxXDimension, float maxYDimension) Return point mirrored around both X and Y axisvoid
mirrorXYInPlace
(float maxXDimension, float maxYDimension) Mirrors point around both X and Y axismirrorY
(float maxYDimension) Return point mirrored around Y axis.void
mirrorYInPlace
(float maxYDimension) Mirrors point around Y axis.negative()
Calculate and return negative of current point.float
norm()
Calculate and return norm of the point.Calculate and return point that has same direction as this point, but norm 1.normalize
(float length) Calculate and return point that has same direction as this point, but norm as given.operatorMinus
(Point other) - operator on the point.operatorMinusEquals
(Point other) operatorMultiply
(float factor) Multiplication of the point with scalar.operatorMultiplyEquals
(float factor) operatorPlus
(Point other) + operator on the point.void
operatorPlusEquals
(Point other) += operator on the point.void
setX
(float x) Sets the x coordinate of the point.void
setY
(float y) Sets the y coordinate of the point.toString()
void
writeToParcel
(android.os.Parcel dest, int flags)
-
Field Details
-
CREATOR
-
-
Constructor Details
-
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 Details
-
toString
-
isZero
public boolean isZero()Returns true if point has coordinates (0,0).- Returns:
- true if point has coordinates (0,0).
-
operatorPlus
+ 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
+= operator on the point. For example: b+=a <==> b.operatorPlusEquals(a);- Parameters:
other
- Point to be added to current point
-
operatorMinus
- 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
-
operatorMinusEquals
-
operatorMultiply
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
-
negativeClone
Calculate and return negative of current point. Negative point is point mirrored to current point over (0,0) pivot.- Returns:
- Negative 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
Calculate and return point that has same direction as this point, but norm 1.- Returns:
- Unit point.
-
normalize
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
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
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
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
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
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
-
equals
-
distance
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:
describeContents
in interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(@NonNull android.os.Parcel dest, int flags) - Specified by:
writeToParcel
in interfaceandroid.os.Parcelable
-