Skip to content

Commit c533925

Browse files
committed
Add docs
1 parent 58ea7d8 commit c533925

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,19 @@ julia> from_points = [[0, 0], [1, 0], [0, 1]];
178178
julia> to_points = [[1, 1], [3, 1], [1.5, 3]];
179179

180180
julia> AffineMap(from_points => to_points)
181-
AffineMap([1.9999999999999996 0.4999999999999999; -5.551115123125783e-16 2.0], [0.9999999999999999, 1.0000000000000002])
181+
AffineMap([2.0 0.5; 0.0 2.0], [1.0, 1.0])
182182
```
183183

184184
The points can be supplied as a collection of vectors or as a matrix with points as columns.
185185

186+
If you want to restrict the transformation to be rigid (rotation + translation)
187+
or similar (rotation, translation, and scaling), use `kabsch` instead:
188+
189+
```julia
190+
julia> rigid = kabsch(from_points => to_points)
191+
AffineMap([0.9912279006826346 0.132163720091018; -0.1321637200910178 0.9912279006826348], [1.4588694597421157, 1.380311939802794])
192+
```
193+
186194
#### Perspective transformations
187195

188196
The perspective transformation maps real-space coordinates to those on a virtual

docs/src/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ AffineMap(::Transformation, ::Any)
2222
AffineMap(::Pair)
2323
LinearMap
2424
Translation
25+
kabsch
2526
```
2627

2728
## 2D Coordinates

docs/src/index.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ and a translation, e.g. `Translation(v) ∘ LinearMap(v)` (or any combination of
179179

180180
`AffineMap`s can be constructed to fit point pairs `from_points => to_points`:
181181

182-
```jldoctest; filter=[r"(2\.0|1\.9999\d+)" => "2.0", r"(0\.5|0\.49999\d+)" => "0.5", r"(0\.0|[ -]\d\.\d+e-\d\d)" => "0.0", r"(1\.0(?!0)|1\.0000\d+|0\.9999\d+)" => "1.0"]
182+
```jldoctest lsq; filter=[r"(2\.0|1\.9999\d+)" => "2.0", r"(0\.5|0\.49999\d+)" => "0.5", r"(0\.0|[ -]\d\.\d+e-\d\d)" => "0.0", r"(1\.0(?!0)|1\.0000\d+|0\.9999\d+)" => "1.0"]
183183
julia> from_points = [[0, 0], [1, 0], [0, 1]];
184184
185185
julia> to_points = [[1, 1], [3, 1], [1.5, 3]];
@@ -190,6 +190,15 @@ AffineMap([2.0 0.5; 0.0 2.0], [1.0, 1.0])
190190

191191
(You may get slightly different numerical values due to roundoff errors.) The points can be supplied as a collection of vectors or as a matrix with points as columns.
192192

193+
If you want to restrict the transformation to be rigid (rotation + translation)
194+
or similar (rotation, translation, and scaling), use `kabsch` instead:
195+
196+
```jldoctest lsq; filter=[r"0\.9912\d+" => "0.9912", r"0\.1321\d+" => "0.1321", r"1\.4588\d+" => "1.4588", r"1\.3803" => "1.3803"]
197+
julia> rigid = kabsch(from_points => to_points)
198+
AffineMap([0.9912279006826346 0.132163720091018; -0.1321637200910178 0.9912279006826348], [1.4588694597421157, 1.380311939802794])
199+
```
200+
201+
193202
### Perspective transformations
194203

195204
The perspective transformation maps real-space coordinates to those on a virtual

0 commit comments

Comments
 (0)