23 #define between(A,X,B) (((A) <= (X) && (X) <= (B)) || ((A) >= (X) && (X) >= (B)))
24 #define sqr(X) ((X)*(X))
28 template<
typename T>
inline void order(T&
a, T&
b) {
42 inline numeric
getX()
const {
46 inline numeric
getY()
const {
51 return x == _.
x &&
y == _.
y;
55 return x != _.
x ||
y != _.
y;
96 inline CustomPoint<numeric>(numeric
x, numeric
y) :
x(
x),
y(
y) {}
103 return 0 <=
x &&
x <= scaleX && 0 <=
y &&
y <= scaleY;
142 return a == other.
a &&
b == other.
b;
146 return a != other.
a ||
b != other.
b;
150 return b.x <=
a.x ||
b.y <=
a.y;
169 inline numeric
getX1()
const {
return a.x; }
170 inline numeric
getY1()
const {
return a.y; }
171 inline numeric
getX2()
const {
return b.x; }
172 inline numeric
getY2()
const {
return b.y; }
186 return (
b.x -
a.x) * (
b.y -
a.y);
193 order<numeric>(
a.x,
b.x);
194 order<numeric>(
a.y,
b.y);
206 a.translate(pt.
x, pt.
y);
207 b.translate(pt.
x, pt.
y);
253 return (
a.x <= point.
x) && (point.
x <=
b.x) && (
a.y <= point.
y) && (point.
y <=
b.y);
260 return (
a.x <= point.
x) && (point.
x <
b.x) && (
a.y <= point.
y) && (point.
y <
b.y);
296 a.x,
a.y + (
b.y -
a.y) * part / totalParts,
297 b.x,
a.y + (
b.y -
a.y) * (part + 1) / totalParts
435 tx = tan(
x), ty = tan(
y),
436 _11 =
a11 * (1 + tx*ty) +
a12 * ty,
437 _21 =
a21 * (1 + tx*ty) +
a22 * ty,
491 const numeric
det =
det();
515 void rescaleUnits(numeric xIn, numeric yIn, numeric xOut, numeric yOut) {
527 if (
p < box.
a.x || box.
b.x <
p)
530 return (box.
a.y <=
p &&
p <= box.
b.y);
541 return (0 <=
p &&
p <=
h);
623 return lhs.
a == rhs.
a && lhs.
b == rhs.
b;
2x3 affine mapping containing a 2x2 matrix and a 2D point
void translate(const Point &shift)
Translates the mapping.
void invert()
Inverts the mapping.
void setCenterPosition(const Point &newPos)
Adjusts the mapping origin so that the center of the axes box matches a given point.
void scale(float factor, const Point &fixedPoint=Point::ZERO)
Scales the mapping around a given point in target domain.
void rotateDegrees(float angle, const Point &fixedPoint=Point::ZERO)
Rotates the mapping around a given point in target domain.
AffineMapping getInverse() const
Returns inverse mapping.
bool isPointInside(const Point &point) const
Tests whether a point from the output domain is inside the input axes span.
AffineMapping operator*(const AffineMapping &mapping) const
Composition of two mappings.
Point getPosition() const
static const AffineMapping IDENTITY
Point operator()(const Point &point) const
Maps a point.
Matrix2 getMatrix() const
2D affine transformation.
void rotateRadians(float angle)
CustomMatrix2 operator*(const numeric factor) const
Multiplies matrix by a scalar.
numeric a22
transformation matrix coefficients
void setElements(float a11, float a12, float a21, float a22)
Sets matrix element values.
void prescale(numeric x, numeric y)
CustomPoint< numeric > operator()(const CustomPoint< numeric > &point) const
Computes transformed point of a given one.
void getElements(float &a11, float &a12, float &a21, float &a22) const
Retrieves matrix element values.
void rescaleUnits(numeric xIn, numeric yIn, numeric xOut, numeric yOut)
Scales transformation input and output units If input/output axes change their scales,...
CustomMatrix2 getInverse() const
Computes inverse transformation.
CustomMatrix2 getTransposed() const
void rotateDegrees(float angle)
void scale(numeric x, numeric y)
static const CustomMatrix2 IDENTITY
void skewDegrees(float x, float y)
bool isPointInsideBox(num x, num y, CustomRectangle< num > box) const
Checks whether a given input point is inside a rectangular area when transformed.
CustomMatrix2(numeric _11, numeric _12, numeric _21, numeric _22)
CustomMatrix2 operator*(const CustomMatrix2 &matrix) const
Multiplies two matrices.
CustomPoint< numeric > operator()(numeric x, numeric y) const
Computes the corresponding transformed point of the point (x,y)
bool isInvertible() const
bool isPointInsideAxes(numeric x, numeric y) const
void scale(numeric factor)
CustomPoint< numeric > operator*(const CustomPoint< numeric > &point) const
Multiplies matrix by a vector.
float getOrientationDegrees()
Returns first axis orientation in degrees.
bool isPointInsideAxes(numeric x, numeric y, numeric w, numeric h) const
Checks whether a given input point is inside the unit square when transformed.
numeric det() const
Transformation determinant.
CustomMatrix2(numeric lambda1, numeric lambda2)
numeric getScalingX()
Computes X axis scaling factor.
CustomPoint< numeric > getInverse(const CustomPoint< numeric > &point) const
Computes inverse of a given point.
CustomPoint< numeric > operator()(int x, int y) const
Integer overloading of (x,y) operator to avoid warnings.
CustomPoint< numeric > getInverse(numeric x, numeric y) const
Computes inverse of a given point.
numeric getScalingY()
Computes Y axis scaling factor.
void skewRadians(float x, float y)
CustomPoint< numeric > operator-(numeric _) const
void translate(numeric x, numeric y)
static const CustomPoint ZERO
CustomPoint< numeric > operator*(const CustomPoint< numeric > &_) const
CustomPoint< numeric > operator-(const CustomPoint< numeric > &_) const
bool operator==(const CustomPoint< numeric > &_) const
CustomPoint< numeric > operator*(numeric _) const
CustomPoint< numeric > operator+(const CustomPoint< numeric > &_) const
CustomPoint< numeric > operator/(const CustomPoint< numeric > &_) const
bool operator!=(const CustomPoint< numeric > &_) const
bool isInsideAxesSpan(numeric scaleX, numeric scaleY) const
CustomPoint< numeric > operator+(numeric _) const
CustomPoint< numeric > operator/(numeric _) const
2D rectangle class All the utilities assume that the rectangle is normalized, e.g.
CustomRectangle translated(CustomPoint< numeric > by) const
void limit(const CustomRectangle &frame)
Truncates a rectangle to a limiting frame.
void getMapping(const CustomRectangle &target, CustomPoint< float > &scale, CustomPoint< float > &offset) const
Finds a linear mapping of the rectangle onto another rectangle.
short int horizontalPositioningTest(numeric x) const
Rectangle positioning test with respect to a given vertical line.
numeric getArea() const
Computes the rectangle area.
void translate(numeric x, numeric y)
Translates the box.
CustomRectangle translated(numeric x, numeric y) const
Returns a translated box.
CustomRectangle(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
void translate(const CustomPoint< numeric > pt)
bool operator!=(const CustomRectangle< numeric > &other) const
CustomRectangle operator*(const CustomPoint< numeric > &_) const
CustomRectangle(numeric x1, numeric y1, numeric x2, numeric y2)
short int verticalPositioningTest(numeric y) const
Rectangle positioning test with respect to a given horizontal line.
void scale(numeric x, numeric y)
Scales the box.
bool operator==(const CustomRectangle< numeric > &other) const
CustomRectangle< numeric > split(const int part, const int totalParts)
bool isInside(const CustomPoint< numeric > &point) const
Test if a point is inside the rectangle (or on its the border)
CustomRectangle operator/(numeric _) const
CustomRectangle operator*(numeric _) const
CustomRectangle operator/(const CustomPoint< numeric > &_) const
static const CustomRectangle UNIT_SQUARE
void normalize()
Flips corners coordinates guaranteeing that it has a non negative area, i.e.
bool isInsideHalfOpened(const CustomPoint< numeric > &point) const
Test if a point is inside the rectangle including left and top borders, but excluding right and botto...
bool operator&&(const CustomRectangle< numeric > &lhs, const CustomRectangle< numeric > &rhs)
Checks whether two rectangles are of the same size.
bool operator==(const CustomRectangle< numeric > &lhs, const CustomRectangle< numeric > &rhs)
Checks whether two rectangles are actually the same.
CustomPoint< numeric > operator-(const CustomPoint< numeric > &point)
Point with negative coordinates.
CustomPoint< numeric > operator*(numeric val, const CustomPoint< numeric > &point)
Product of a scalar and a point.
CustomPoint< numeric > min(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
CustomPoint< numeric > max(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
JNIEnv jlong jint jint jint jint y2
JNIEnv jlong jint jint jint x2
JNIEnv jlong jint jint jint y1
jobject jlong jint jint jint jint jint b
jobject jlong jint jint y
jlong jstring jint jint jint jint w
jobject jlong jint jint jint r
jobject jlong jint jint jint jint jint jint a
return(jlong) new Beatmup jlong jstring jint val
Beatmup::IntPoint p((int) x,(int) y)
JNIEnv jlong jfloat jfloat s
Beatmup::AffineMapping & mapping
layer getMapping().setCenterPosition(Beatmup jlong jfloat factor