32#ifndef RCSC_GEOM_MATRIX2D_H
33#define RCSC_GEOM_MATRIX2D_H
85 const double m21,
const double m22,
86 const double dx,
const double dy )
87 : M_11(
m11 ), M_12(
m12 ),
89 M_dx(
dx ), M_dy(
dy )
99 M_12 = M_21 = M_dx = M_dy = 0.0;
114 const double m21,
const double m22,
115 const double dx,
const double dy )
119 M_dx =
dx; M_dy =
dy;
161 double cosa = angle.
cos();
162 double sina = angle.
sin();
228 return M_11*M_22 - M_12*M_21;
237 return ! ( std::fabs(
det() ) < 0.00000000001 );
304 M_11 *= sx; M_12 *= sx; M_dx *= sx;
305 M_21 *= sy; M_22 *= sy; M_dy *= sy;
340 double tm11 = M_11*m.M_11 + M_12*m.M_21;
341 double tm12 = M_11*m.M_12 + M_12*m.M_22;
342 double tm21 = M_21*m.M_11 + M_22*m.M_21;
343 double tm22 = M_21*m.M_12 + M_22*m.M_22;
345 double tdx = M_11*m.M_dx + M_12*m.M_dy + M_dx;
346 double tdy = M_21*m.M_dx + M_22*m.M_dy + M_dy;
348 M_11 = tm11; M_12 = tm12;
349 M_21 = tm21; M_22 = tm22;
350 M_dx = tdx; M_dy = tdy;
362 M_21*v.
x + M_22*v.
y + M_dy );
372 const double y )
const
374 return Vector2D( M_11*x + M_12*y + M_dx,
375 M_21*x + M_22*y + M_dy );
384 double tx = M_11*v->
x + M_12*v->
y + M_dx;
385 double ty = M_21*v->
x + M_22*v->
y + M_dy;
408 Circle2D
transform(
const Circle2D & c )
const
410 return Circle2D(
transform( c.center() ),
421 Triangle2D
transform(
const Triangle2D & t )
const
434 std::ostream &
print( std::ostream & os )
const
489 return m.
print( os );
degree wrapper class Header File.
degree wrapper class
Definition: angle_deg.h:45
double cos() const
calculate cosine
Definition: angle_deg.h:292
double sin() const
calculate sine
Definition: angle_deg.h:301
2D translation matrix class
Definition: matrix_2d.h:51
Matrix2D & rotate(const AngleDeg &angle)
rotates the coordinate system
double m21() const
get the horizontal shearing factor.
Definition: matrix_2d.h:190
const Matrix2D & assign(const double m11, const double m12, const double m21, const double m22, const double dx, const double dy)
set a matrix element with the specified values.
Definition: matrix_2d.h:113
double m11() const
get the horizontal scaling factor.
Definition: matrix_2d.h:172
std::ostream & print(std::ostream &os) const
put all elemtns to the output stream
Definition: matrix_2d.h:434
static Matrix2D make_scaling(const double sx, const double sy)
create the scaling matrix.
Definition: matrix_2d.h:145
Matrix2D & translate(const double dx, const double dy)
moves the coordinate system.
Definition: matrix_2d.h:255
double det() const
get the matrix's determinant.
Definition: matrix_2d.h:226
bool invertible() const
check if this matrix is invertible (is not isingular).
Definition: matrix_2d.h:235
Matrix2D inverted() const
get the inverted matrix.
double dx() const
get the horizontal translation factor.
Definition: matrix_2d.h:208
const Matrix2D & operator*=(const Matrix2D &m)
multiplied by other matrix
Definition: matrix_2d.h:338
double m22() const
get the vertical scaling factor.
Definition: matrix_2d.h:199
double dy() const
get the vertical translation factor.
Definition: matrix_2d.h:217
static Matrix2D make_translation(const double dx, const double dy)
create the translation matrix.
Definition: matrix_2d.h:130
double m12() const
get the vertical shearing factor.
Definition: matrix_2d.h:181
void transform(Vector2D *v) const
transform input vector with this matrix
Definition: matrix_2d.h:382
Vector2D transform(const double x, const double y) const
create transformed vector from input coordinates with this matrix
Definition: matrix_2d.h:371
Matrix2D & scale(const double sx, const double sy)
scales the coordinate system.
Definition: matrix_2d.h:286
Vector2D transform(const Vector2D &v) const
create transformed vector from input vector with this matrix
Definition: matrix_2d.h:359
Matrix2D()
create an identity matrix
Definition: matrix_2d.h:66
Matrix2D(const double m11, const double m12, const double m21, const double m22, const double dx, const double dy)
create a matrix with all elements.
Definition: matrix_2d.h:84
static Matrix2D make_rotation(const AngleDeg &angle)
create the rotation matrix.
Definition: matrix_2d.h:159
const Matrix2D & reset()
reset to the identity matrix
Definition: matrix_2d.h:96
2d segment line class
Definition: segment_2d.h:46
2D point vector class
Definition: vector_2d.h:46
Vector2D & assign(const double xx, const double yy)
assign XY value directly.
Definition: vector_2d.h:100
static Vector2D polar2vector(const double mag, const AngleDeg &theta)
get new Vector created by POLAR value.
Definition: vector_2d.h:580
double y
Y coordinate.
Definition: vector_2d.h:64
double x
X coordinate.
Definition: vector_2d.h:63
std::ostream & operator<<(std::ostream &os, const rcsc::Matrix2D &m)
output stream operator.
Definition: matrix_2d.h:486
const rcsc::Matrix2D operator*(const rcsc::Matrix2D &lhs, const rcsc::Matrix2D &rhs)
multiplication operator of Matrix x Matrix.
Definition: matrix_2d.h:458
2d vector class Header File.