public class Utils2D
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Utils2D.AffineInfo
A class to hold information about an affine transform
|
Constructor and Description |
---|
Utils2D() |
Modifier and Type | Method and Description |
---|---|
static RealMatrix |
addToAllColumns(RealMatrix A,
RealMatrix colMatrix)
Adds colMatrix to each column of matrix A and returns the result
|
static Utils2D.AffineInfo |
affineInfo(java.awt.geom.AffineTransform tx)
Returns an AffineInfo object containing information about the affine transform tx.
|
static double |
angleNorm(double val) |
static double |
angleNorm(double val,
double lim) |
static Location |
calculateBoardLocation(BoardLocation boardLocation,
Placement placementA,
Placement placementB,
Location observedLocationA,
Location observedLocationB)
Given an existing BoardLocation, two Placements and the observed location of those
two Placements, calculate the actual Location of the BoardLocation.
|
static Location |
calculateBoardPlacementLocation(BoardLocation bl,
Location placementLocation) |
static Location |
calculateBoardPlacementLocationInverse(BoardLocation bl,
Location placementLocation) |
static RealMatrix |
computeCentroid(RealMatrix A)
Returns a column matrix whose entries are the arithmetic average of each
corresponding row of matrix A.
|
static java.awt.geom.AffineTransform |
deriveAffineTransform(double sourceX1,
double sourceY1,
double sourceX2,
double sourceY2,
double destX1,
double destY1,
double destX2,
double destY2) |
static java.awt.geom.AffineTransform |
deriveAffineTransform(double sourceX1,
double sourceY1,
double sourceX2,
double sourceY2,
double sourceX3,
double sourceY3,
double destX1,
double destY1,
double destX2,
double destY2,
double destX3,
double destY3) |
static java.awt.geom.AffineTransform |
deriveAffineTransform(java.util.List<Location> source,
java.util.List<Location> destination)
Returns the least squared error affine transform that transforms the list of source
locations to the corresponding list of destination locations, see the discussion at
https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/openpnp/Wok_-OyVdnA/Z2YnhNoYAwAJ
*
|
static java.awt.geom.AffineTransform |
deriveAffineTransform(Location source1,
Location source2,
Location dest1,
Location dest2) |
static java.awt.geom.AffineTransform |
deriveAffineTransform(Location source1,
Location source2,
Location source3,
Location dest1,
Location dest2,
Location dest3) |
static java.awt.geom.AffineTransform |
deriveAffineTransform(Utils2D.AffineInfo affineInfo)
Returns an affine transform based on the affineInfo parameter
Although there are many ways to decompose an affine transform, this implementation treats
the transform as consisting of, in order, an xy scaling, an x shear, a rotation, and finally
a translation, i.e., destinationPoint = translation * rotation * shear * scale * sourcePoint
|
static double |
distance(java.awt.geom.Point2D.Double a,
java.awt.geom.Point2D.Double b) |
static double |
getAngleFromPoint(Location firstPoint,
Location secondPoint) |
static Location |
getPointAlongLine(Location a,
Location b,
Length distance)
Calculate the Location along the line formed by a and b with distance from a.
|
static java.util.List<Placement> |
mostDistantPair(java.util.List<Placement> points) |
static double |
normalizeAngle(double angle)
Normalizes the angle to be greater than or equal to 0 and less than or equal to +360 degrees
|
static double |
normalizeAngle180(double angle)
Normalizes the angle to be greater than or equal to -180 and less than +180 degrees
|
static Point |
rotatePoint(Point point,
double c)
Rotation is counter-clockwise for positive angles.
|
static RotatedRect |
rotateToExpectedAngle(RotatedRect r,
double expectedAngle)
Rotate the given RotatedRect nearest to the expectedAngle in 90° steps, i.e., it will have the same shape
but be ±45° within expectedAngle.
|
static Point |
rotateTranslateCenterPoint(Point point,
double c,
double x,
double y,
Point center) |
static Point |
rotateTranslateScalePoint(Point point,
double c,
double x,
double y,
double scaleX,
double scaleY) |
static Point |
scalePoint(Point point,
double scaleX,
double scaleY) |
static RealMatrix |
subtractFromAllColumns(RealMatrix A,
RealMatrix colMatrix)
Subtracts colMatrix from each column of matrix A and returns the result
|
static Point |
translatePoint(Point point,
double x,
double y) |
static double |
triangleArea(Placement p1,
Placement p2,
Placement p3)
Calculate the area of a triangle.
|
public static Point rotateTranslateScalePoint(Point point, double c, double x, double y, double scaleX, double scaleY)
public static Point rotateTranslateCenterPoint(Point point, double c, double x, double y, Point center)
public static Point rotatePoint(Point point, double c)
point
- c
- public static Utils2D.AffineInfo affineInfo(java.awt.geom.AffineTransform tx)
tx
- public static java.awt.geom.AffineTransform deriveAffineTransform(Utils2D.AffineInfo affineInfo)
ai
- public static Location calculateBoardPlacementLocation(BoardLocation bl, Location placementLocation)
public static Location calculateBoardPlacementLocationInverse(BoardLocation bl, Location placementLocation)
public static Location calculateBoardLocation(BoardLocation boardLocation, Placement placementA, Placement placementB, Location observedLocationA, Location observedLocationB)
boardLocation
- placementA
- placementB
- observedLocationA
- observedLocationB
- public static double normalizeAngle(double angle)
angle
- public static double normalizeAngle180(double angle)
angle
- public static double angleNorm(double val, double lim)
public static double angleNorm(double val)
public static RotatedRect rotateToExpectedAngle(RotatedRect r, double expectedAngle)
r
- expectedAngle
- Note, the angle given here is right-handed, unlike the one
stored in the RotatedRect.public static Location getPointAlongLine(Location a, Location b, Length distance)
a
- b
- distance
- public static double getAngleFromPoint(Location firstPoint, Location secondPoint)
firstPoint
- secondPoint
- public static double distance(java.awt.geom.Point2D.Double a, java.awt.geom.Point2D.Double b)
public static java.awt.geom.AffineTransform deriveAffineTransform(Location source1, Location source2, Location source3, Location dest1, Location dest2, Location dest3)
public static java.awt.geom.AffineTransform deriveAffineTransform(Location source1, Location source2, Location dest1, Location dest2)
public static java.awt.geom.AffineTransform deriveAffineTransform(double sourceX1, double sourceY1, double sourceX2, double sourceY2, double sourceX3, double sourceY3, double destX1, double destY1, double destX2, double destY2, double destX3, double destY3)
public static java.awt.geom.AffineTransform deriveAffineTransform(double sourceX1, double sourceY1, double sourceX2, double sourceY2, double destX1, double destY1, double destX2, double destY2)
public static RealMatrix computeCentroid(RealMatrix A)
A
- public static RealMatrix addToAllColumns(RealMatrix A, RealMatrix colMatrix)
A
- colMatrix
- public static RealMatrix subtractFromAllColumns(RealMatrix A, RealMatrix colMatrix)
A
- colMatrix
- public static java.awt.geom.AffineTransform deriveAffineTransform(java.util.List<Location> source, java.util.List<Location> destination)
source
- destination
- public static double triangleArea(Placement p1, Placement p2, Placement p3)
p1
- p2
- p3
-