WIP: Transformation2d#150
Conversation
|
Exciting, thanks for starting the discussion! A few random thoughts to start...I'm sure I'll have more as I think about this =) Type parametersFor a bit of consistency with other code, I'm wondering about something like type Transformation2d units coordinates restrictionswhere the translateBy :
Vector2d units coordinates
-> Transformation2d (units -> units) (coordinates -> coordinates) a
scaleAbout :
Point2d units coordinates
-> Float
-> Transformation2d (units -> units) (coordinates -> coordinates) { a | scale : Allowed }
relativeTo :
Frame2d units coordinates { defines : localCoordinates }
-> Transformation2d (units -> units) (coordinates -> localCoordinates) a
at :
Quantity Float (Rate units1 units2)
-> Transformation2d (units2 -> units1) (coordinates -> coordinates) { a | scale : Allowed }
-- transformation1 |> Transformation2d.followedBy transformation2
followedBy :
Transformation2d (units2 -> units3) (coordinates2 -> coordinates3) restrictions
-> Transformation2d (units1 -> units2) (coordinates1 -> coordinates2) restrictions
-> Transformation2d (units1 -> units3) (coordinates1 -> coordinates3) restrictionsThen the type parameters of { a | scale : Allowed, inputUnits : inputUnits, outputUnits : outputUnits, ... }which I think you'd end up needing with the current design. Internal representationI think I might be tempted to use type Transformation2d units coordinates restrictions
= Transformation2d { m11 : Float, m12 : Float, ..., m33 : Float }to be consistent with |
|
Regarding representation: elm-explorations/linear-algebra doesn't really have a Mat3 type. I agree that for Transformation3d using that record based representation makes sense, but using 16 Floats for 2d transforms seems wasteful when just 6 are enough. |
|
OK, I've changed the types to be as you suggested. I think it's a good improvement, as the function types intuitively communicate the idea of transformation better than the input/output prefixes. Also note that there is a failing test: Any idea why that might be? Is that just floating point arithmetic drift? |
|
I realize that |
|
For the failing test, I think the sign is incorrect in |
This is an API sketch for addressing #79.
Obviously a full implementation needs:
applyfunction in every 2d moduleThe point here is more to start a conversation around API design before I waste more time on building that stuff.
I've went with a fairly powerful design which allows both unit and coordinate system conversion, as well as tracking which kind of transforms are allowed. This is however at the cost of a fairly complex type signature.