File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 39
39
* Update rstar to v0.12.0
40
40
* Implement ` CoordsIter ` for arrays and slices. This is useful when you'd like to use traits
41
41
implemented for ` CoordsIter ` without re-allocating (e.g., creating a ` MultiPoint ` ).
42
+ * Add ` compose_many ` method to ` AffineOps `
43
+ * < https://github.com/georust/geo/pull/1148 >
42
44
43
45
## 0.27.0
44
46
Original file line number Diff line number Diff line change @@ -169,6 +169,32 @@ impl<T: CoordNum> AffineTransform<T> {
169
169
] ,
170
170
] )
171
171
}
172
+
173
+ /// Create a new affine transformation by composing an arbitrary number of `AffineTransform`s.
174
+ ///
175
+ /// This is a **cumulative** operation; the new transform is *added* to the existing transform.
176
+ /// ```
177
+ /// use geo::AffineTransform;
178
+ /// let mut transform = AffineTransform::identity();
179
+ ///
180
+ /// // create two transforms that cancel each other
181
+ /// let transform1 = AffineTransform::translate(1.0, 2.0);
182
+ /// let transform2 = AffineTransform::translate(-1.0, -2.0);
183
+ /// let transforms = vec![transform1, transform2];
184
+ ///
185
+ /// // apply them
186
+ /// let outcome = transform.compose_many(&transforms);
187
+ /// // we should be back to square one
188
+ /// assert!(outcome.is_identity());
189
+ /// ```
190
+ #[ must_use]
191
+ pub fn compose_many ( & self , transforms : & [ Self ] ) -> Self {
192
+ self . compose ( & transforms. iter ( ) . fold (
193
+ AffineTransform :: default ( ) ,
194
+ |acc : AffineTransform < T > , transform| acc. compose ( transform) ,
195
+ ) )
196
+ }
197
+
172
198
/// Create the identity matrix
173
199
///
174
200
/// The matrix is:
You can’t perform that action at this time.
0 commit comments