transform.py
#
Custom Affine transformation class.
Affine
#
Affine transformation.
Source code in pseudo_3D_interpolation\functions\transform.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
__init__(scaling=1, translation=0, rotation=0, shear=0, matrix=None)
#
Initialize Affine transform.
Using either user-specified parameters or numpy.ndarray
of shape (3, 3)
holding affine transform (matrix
parameter).
References#
Source code in pseudo_3D_interpolation\functions\transform.py
get_scalar(param)
staticmethod
#
Return (unpacked) scalars from input tuple or duplicated input scalar.
fix_floating_point_error(value)
staticmethod
#
identity()
classmethod
#
scaling(scale, overwrite=False)
#
Return self
with updated matrix using given scaling.
Source code in pseudo_3D_interpolation\functions\transform.py
translation(offset, overwrite=False)
#
Return self
with updated matrix using given translation.
Source code in pseudo_3D_interpolation\functions\transform.py
rotation(angle, overwrite=False)
#
Return self
with updated matrix using given rotation.
Source code in pseudo_3D_interpolation\functions\transform.py
rotate_around(angle, origin=(0, 0))
#
Return self
rotated around provided point (default: (0, 0)
).
Source code in pseudo_3D_interpolation\functions\transform.py
rotate(points, angle=None, origin=(0, 0), fix_float=False)
#
Return rotated input points (N, 2) or (N, 3). Positive angles indicate a counter-clockwise roation, negative angles a clockwiseroation.
Parameters:
-
points
(ndarray
) –Input point coordinates with shape (N, 2) for 2D or (N, 3) for 3D.
-
angle
(float
, default:None
) –Rotation angle (will overwrite previously set rotation) (default:
None
). -
origin
(tuple
, default:(0, 0)
) –Rotation around given point (default:
(0, 0)
). -
fix_float
(bool
, default:False
) –Fix floating point precision error (default:
False
).
Returns:
-
ndarray
–Rotated input points.
Source code in pseudo_3D_interpolation\functions\transform.py
skew(shear, overwrite=False)
#
Return self
with updated matrix using given shear angle (deg).
Source code in pseudo_3D_interpolation\functions\transform.py
transform(points, fix_float=False)
#
Return transformed input points (based on parameters set on initiation).
Parameters:
-
points
(ndarray
) –2D array of coordinates with shape
(npts, 2)
. -
fix_float
(bool
, default:False
) –Fix floating point precision error (default:
False
).
Returns:
-
ndarray
–Transformed input points.
Source code in pseudo_3D_interpolation\functions\transform.py
__matmul__(other)
#
Matrix multiplication using @ operator (order-dependent!).
Source code in pseudo_3D_interpolation\functions\transform.py
__mul__(other)
#
Matrix multiplication (order-dependent!).
Source code in pseudo_3D_interpolation\functions\transform.py
__add__(other)
#
Combine Affine transformations so that C = A + B
equals
C.transform(x) = B.transform(A.transform(x))
.
Source code in pseudo_3D_interpolation\functions\transform.py
inverse(inplace=False)
#
Apply inverse transform.
Parameters:
-
inplace
(bool
, default:False
) –Assigns to
self.matrix
if True (default:False
).
Returns:
-
Affine
–Inverse Affine matrix.