Skip to content

Commit 9d93999

Browse files
authored
Merge pull request #7 from FugroRoames/simplify_abstract
Simplified AbstractTransformation
2 parents 683a3cf + d4d9ef9 commit 9d93999

File tree

9 files changed

+247
-252
lines changed

9 files changed

+247
-252
lines changed

README.md

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ localization and mapping).
1414

1515
The package provide two main pieces of functionality
1616

17-
1. Primarily, an interface for defining `AbstractTransformation`s and applying
17+
1. Primarily, an interface for defining `Transformation`s and applying
1818
(`transform()`), inverting (`inv()`), composing (`` or `compose()`) and
1919
differentiating (`transform_deriv()` and `transform_deriv_params()`) them.
2020

2121
2. A small set of built-in, composable, primitive transformations for
22-
transforming 2D and 3D points (leveraging the *FixedSizeArrays* and
23-
*Rotations* packages).
22+
transforming 2D and 3D points (optionally leveraging the *FixedSizeArrays*
23+
and *Rotations* packages).
2424

2525
### Quick start
2626

@@ -66,16 +66,11 @@ rotation angle:
6666

6767
### The interface
6868

69-
Transformations are derived from `AbstractTransformation{OutType, InType}`.
70-
`InType` is a (possibly abstract or union) type describing which inputs
71-
`transform()` will accept with the given transformation, and `OutType` describes
72-
the (possible range of) outputs given. These parameters allow for a level of
73-
safety, so that transformations are only applied to appropriate data types and
74-
to catch early-on any problems with composing or chaining transformations.
75-
76-
As an example, we have `Translation{T} <: AbstractTransformation{FixedVector, FixedVector}`.
77-
A translation will expect data in the `FixedVector` format and will always return
78-
the same base type as given (of course, type promotion may occur for the element type itself).
69+
Transformations are derived from `Transformation`. As an example, we have
70+
`Translation{T} <: Transformation`. A translation will accept points in a
71+
variety of formats, such as `Vector`, `FixedVector`, `Tuple`, etc, and will try
72+
to return the same type as given (of course, type promotion may occur for the
73+
element type itself).
7974

8075
Transformations can be reversed using `inv(trans)`. They can be chained
8176
together using the `` operator (`trans1 ∘ trans2`) or `compose` function (`compose(trans1, trans2)`).
@@ -97,22 +92,22 @@ techniques, and can be parameterized by *DualNumbers*' `DualNumber` or *ForwardD
9792
### Built-in transformations
9893

9994
A small number of 2D and 3D coordinate systems and transformations are included.
100-
We also have `IdentityTransform{InOutType}` and `ComposedTransformation{InType,OutType}`,
101-
which allows us to nest together arbitrary transformations to create a
102-
complex yet efficient transformation chain.
95+
We also have `IdentityTransform` and `ComposedTransformation`, which allows us
96+
to nest together arbitrary transformations to create a complex yet efficient
97+
transformation chain.
10398

10499
#### Coordinate types
105100

106-
The canonical Cartesian coordinate data types are any type which inherited from
107-
*FixedSizeArrays*' `FixedVector{2}` and `FixedVector{3}` in 2D and 3D,
108-
respectively. The concrete datatypes `Point` and `Vec` are provided by
109-
*FixedSizeArrays*, and here we tend to favor `Point` for output where it is not
110-
specified. (Of course, users may define their own transformations and types, as
111-
they wish).
112-
113-
The `Polar(r, θ)` type is a 2D polar representation of a point, and similarly
114-
in 3D we have defined `Spherical(r, θ, ϕ)` and `Cylindrical(r, θ, z)`.
101+
The package does not assume any specific coordinate types for Cartesian
102+
coordinates, and aims to accept any indexable container (such as `Vector`,
103+
`Tuple`, *FixedSizeArrays*' `FixedSizeVector{N}` or any other duck-typed vector).
104+
For speed, we recommend using a statically-sized container such as `Point{N}` or
105+
`Vec{N}` from *FixedSizeArrays*, or even an `NTuple{N}`. However, it is
106+
attempted that the package will not change your data type.
115107

108+
We do provide a few specialist coordinate types. The `Polar(r, θ)` type is a 2D
109+
polar representation of a point, and similarly in 3D we have defined
110+
`Spherical(r, θ, ϕ)` and `Cylindrical(r, θ, z)`.
116111

117112
#### Coordinate system transformations
118113

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
julia 0.4
2-
FixedSizeArrays
2+
FixedSizeArrays 0.2.2
33
Rotations

src/CoordinateTransformations.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ export Point # Use Point{N, T} from FixedSizedArrays for Cartesian frames
66
# TODO: move these over to FixedSizeArrays at some point
77
function Base.vcat(v1::Vec, v2::Vec)
88
(v1p, v2p) = promote(v1, v2)
9-
Vec(v1p._..., v2p._...)
9+
Vec(Tuple(v1p)..., Tuple(v2p)...)
1010
end
1111
function Base.hcat{N,M,P}(m1::Mat{N,M}, m2::Mat{N,P})
1212
(m1p, m2p) = promote(m1, m2)
13-
Mat(m1p._..., m2p._...)
13+
Mat(Tuple(m1p)..., Tuple(m2p)...)
1414
end
1515
@generated function Base.vcat{N,M,P}(m1::Mat{M,N}, m2::Mat{P,N})
16-
exprs = ntuple(i -> :( (m1p._[$i]..., m2p._[$i]...) ) , N)
16+
exprs = ntuple(i -> :( (Tuple(m1p)[$i]..., Tuple(m2p)[$i]...) ) , N)
1717
expr = Expr(:tuple, exprs...)
1818
quote
1919
(m1p, m2p) = promote(m1, m2)
@@ -26,7 +26,7 @@ export RotMatrix, Quaternion, SpQuat, AngleAxis, EulerAngles, ProperEulerAngles
2626

2727
# Core methods
2828
export transform, compose, , transform_deriv, transform_deriv_params
29-
export AbstractTransformation, IdentityTransformation
29+
export Transformation, IdentityTransformation
3030

3131
# 2D coordinate systems and their transformations
3232
export Polar

0 commit comments

Comments
 (0)