setToReflectionBasic method
Explicitly computes the math for a reflection. May not work. @param x0 the X ordinate of one point on the reflection line @param y0 the Y ordinate of one point on the reflection line @param x1 the X ordinate of another point on the reflection line @param y1 the Y ordinate of another point on the reflection line @return this transformation, with an updated matrix
Implementation
AffineTransformation setToReflectionBasic(
double x0, double y0, double x1, double y1) {
if (x0 == x1 && y0 == y1) {
throw ArgumentError("Reflection line points must be distinct");
}
double dx = x1 - x0;
double dy = y1 - y0;
double d = math.sqrt(dx * dx + dy * dy);
double sin = dy / d;
double cos = dx / d;
double cs2 = 2 * sin * cos;
double c2s2 = cos * cos - sin * sin;
m00 = c2s2;
m01 = cs2;
m02 = 0.0;
m10 = cs2;
m11 = -c2s2;
m12 = 0.0;
return this;
}