| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.Transformation
Description
Synopsis
- newtype Transformation (d :: Natural) r = Transformation (Matrix (d + 1) (d + 1) r)
- transformationMatrix :: forall (d :: Natural) r s p f. (Profunctor p, Functor f) => p (Matrix (d + 1) (d + 1) r) (f (Matrix (d + 1) (d + 1) s)) -> p (Transformation d r) (f (Transformation d s))
- (|.|) :: forall r (d :: Natural). (Num r, OptMatrix_ (d + 1) r) => Transformation d r -> Transformation d r -> Transformation d r
- identity :: forall r (d :: Natural). (Num r, OptMatrix_ (d + 1) r) => Transformation d r
- inverseOf :: forall r (d :: Natural). (Fractional r, OptMatrix_ (d + 1) r, Invertible (d + 1)) => Transformation d r -> Transformation d r
- class IsTransformable g where
- transformBy :: Transformation (Dimension g) (NumType g) -> g -> g
- type TransformationConstraints (d :: Nat) r = (KnownNat d, Has_ Vector_ d r, OptMatrix_ (d + 1) r, HasComponents (Vector (d + 1) r) (Vector (d + 1) (Vector (d + 1) r)), Has_ Additive_ (d + 1) r)
- type DefaultTransformByConstraints g (d :: Nat) r = (d ~ Dimension g, r ~ NumType g, OptMatrix_ (d + 1) r, Fractional r, Has_ Additive_ d r, HasComponents (Vector (d + 1) (Vector (d + 1) r)) (Vector (d + 1) r), d <= (d + 1), d <= ((d + 1) - 1))
- type OptMatrix_ (d :: Nat) r = (Has_ Additive_ d r, Has_ Vector_ d (Vector d r), Ixed (Vector d r), Ixed (Vector d (Vector d r)))
- translation :: forall (d :: Nat) r vector. (Num r, Vector_ vector d r, TransformationConstraints d r, d <= ((d + 1) - 1)) => vector -> Transformation d r
- scaling :: forall (d :: Nat) r vector. (Num r, Vector_ vector d r, TransformationConstraints d r) => vector -> Transformation d r
- uniformScaling :: forall (d :: Nat) r. (Num r, TransformationConstraints d r) => r -> Transformation d r
- translateBy :: forall g vector (d :: Nat). (IsTransformable g, Num (NumType g), Vector_ vector d (NumType g), TransformationConstraints d (NumType g), Dimension g ~ d, d <= ((d + 1) - 1)) => vector -> g -> g
- scaleBy :: forall g vector (d :: Nat). (IsTransformable g, Num (NumType g), Vector_ vector d (NumType g), TransformationConstraints d (NumType g), Dimension g ~ d, d <= ((d + 1) - 1)) => vector -> g -> g
- scaleUniformlyBy :: forall g (d :: Nat). (IsTransformable g, Num (NumType g), TransformationConstraints d (NumType g), Dimension g ~ d, d <= ((d + 1) - 1)) => NumType g -> g -> g
- rotateTo :: Num r => Vector 3 (Vector 3 r) -> Transformation 3 r
- rotateXYZ :: Floating r => Vector 3 r -> Transformation 3 r
- rotateX :: Floating r => r -> Transformation 3 r
- rotateY :: Floating r => r -> Transformation 3 r
- rotateZ :: Floating r => r -> Transformation 3 r
- skewX :: Num r => r -> Transformation 2 r
- rotation :: Floating r => r -> Transformation 2 r
- reflection :: Floating r => r -> Transformation 2 r
- reflectionV :: Num r => Transformation 2 r
- reflectionH :: Num r => Transformation 2 r
- fitToBox :: forall box (d :: Nat) g point r. (NumType g ~ r, Dimension g ~ d, IsTransformable g, IsBoxable g, Box_ box point, Point_ point d r, Ord r, Fractional r, TransformationConstraints d r, Functor (Vector d), Zip (Vector d), d <= ((d + 1) - 1)) => box -> g -> g
- fitToBoxTransform :: forall box (d :: Nat) g point r. (NumType g ~ r, Dimension g ~ d, IsTransformable g, IsBoxable g, Box_ box point, Point_ point d r, Ord r, Fractional r, TransformationConstraints d r, Functor (Vector d), Zip (Vector d), d <= ((d + 1) - 1)) => box -> g -> Transformation d r
Documentation
newtype Transformation (d :: Natural) r Source #
A type representing a Transformation for d dimensional objects
Constructors
| Transformation (Matrix (d + 1) (d + 1) r) |
Instances
transformationMatrix :: forall (d :: Natural) r s p f. (Profunctor p, Functor f) => p (Matrix (d + 1) (d + 1) r) (f (Matrix (d + 1) (d + 1) s)) -> p (Transformation d r) (f (Transformation d s)) Source #
Transformations and Matrices are isomorphic.
(|.|) :: forall r (d :: Natural). (Num r, OptMatrix_ (d + 1) r) => Transformation d r -> Transformation d r -> Transformation d r Source #
Compose transformations (right to left)
identity :: forall r (d :: Natural). (Num r, OptMatrix_ (d + 1) r) => Transformation d r Source #
Identity transformation; i.e. the transformation which does not change anything.
inverseOf :: forall r (d :: Natural). (Fractional r, OptMatrix_ (d + 1) r, Invertible (d + 1)) => Transformation d r -> Transformation d r Source #
Compute the inverse transformation
>>>inverseOf $ translation (Vector2 (10.0) (5.0))Transformation {_transformationMatrix = Matrix (Vector3 (Vector3 1.0 0.0 (-10.0)) (Vector3 0.0 1.0 (-5.0)) (Vector3 0.0 0.0 1.0))}
class IsTransformable g where Source #
A class representing types that can be transformed using a transformation
Minimal complete definition
Nothing
Methods
transformBy :: Transformation (Dimension g) (NumType g) -> g -> g Source #
default transformBy :: forall (d :: Nat) r point. (DefaultTransformByConstraints g d r, Point_ point d r, HasPoints g g point point) => Transformation (Dimension g) (NumType g) -> g -> g Source #
Instances
type TransformationConstraints (d :: Nat) r = (KnownNat d, Has_ Vector_ d r, OptMatrix_ (d + 1) r, HasComponents (Vector (d + 1) r) (Vector (d + 1) (Vector (d + 1) r)), Has_ Additive_ (d + 1) r) Source #
Some constraints that we will pretty much need to transform a d dimensional object whose numtype is r
type DefaultTransformByConstraints g (d :: Nat) r = (d ~ Dimension g, r ~ NumType g, OptMatrix_ (d + 1) r, Fractional r, Has_ Additive_ d r, HasComponents (Vector (d + 1) (Vector (d + 1) r)) (Vector (d + 1) r), d <= (d + 1), d <= ((d + 1) - 1)) Source #
Bunch of constraints we need for the default implementation of transformBy
type OptMatrix_ (d :: Nat) r = (Has_ Additive_ d r, Has_ Vector_ d (Vector d r), Ixed (Vector d r), Ixed (Vector d (Vector d r))) Source #
shorthand for square matrixecs
translation :: forall (d :: Nat) r vector. (Num r, Vector_ vector d r, TransformationConstraints d r, d <= ((d + 1) - 1)) => vector -> Transformation d r Source #
Create translation transformation from a vector.
>>>transformBy (translation $ Vector2 1 2) $ Point2 2 3Point2 3.0 5.0
scaling :: forall (d :: Nat) r vector. (Num r, Vector_ vector d r, TransformationConstraints d r) => vector -> Transformation d r Source #
Create scaling transformation from a vector.
>>>transformBy (scaling $ Vector2 2 (-1)) $ Point2 2 3Point2 4.0 (-3.0)
uniformScaling :: forall (d :: Nat) r. (Num r, TransformationConstraints d r) => r -> Transformation d r Source #
Create scaling transformation from a scalar that is applied to all dimensions.
>>>transformBy (uniformScaling 5) $ Point2 2 3Point2 10.0 15.0>>>uniformScaling 5 == scaling (Vector2 5 5)True>>>uniformScaling 5 == scaling (Vector3 5 5 5)True
translateBy :: forall g vector (d :: Nat). (IsTransformable g, Num (NumType g), Vector_ vector d (NumType g), TransformationConstraints d (NumType g), Dimension g ~ d, d <= ((d + 1) - 1)) => vector -> g -> g Source #
Translate a given point.
>>>translateBy (Vector2 1 2) $ Point2 2 3Point2 3.0 5.0
scaleBy :: forall g vector (d :: Nat). (IsTransformable g, Num (NumType g), Vector_ vector d (NumType g), TransformationConstraints d (NumType g), Dimension g ~ d, d <= ((d + 1) - 1)) => vector -> g -> g Source #
Scale a given point.
>>>scaleBy (Vector2 2 (-1)) $ Point2 2 3Point2 4.0 (-3.0)
scaleUniformlyBy :: forall g (d :: Nat). (IsTransformable g, Num (NumType g), TransformationConstraints d (NumType g), Dimension g ~ d, d <= ((d + 1) - 1)) => NumType g -> g -> g Source #
Scale a given point uniformly in all dimensions.
>>>scaleUniformlyBy 5 $ Point2 2 3Point2 10.0 15.0
rotateTo :: Num r => Vector 3 (Vector 3 r) -> Transformation 3 r Source #
Given three new unit-length basis vectors (u,v,w) that map to (x,y,z), construct the appropriate rotation that does this.
rotateXYZ :: Floating r => Vector 3 r -> Transformation 3 r Source #
Euler angle rotation; in order XYZ (from bottom to top in the gimbal hierarchy)
the angles CCW and given in radians.
rotateX :: Floating r => r -> Transformation 3 r Source #
Rotate $alpha$-radians CCW around the x-axis
rotateY :: Floating r => r -> Transformation 3 r Source #
Rotate $beta$-radians CCW around the y-axis
rotateZ :: Floating r => r -> Transformation 3 r Source #
Rotate $gamma$-radians CCW around the z-axis
skewX :: Num r => r -> Transformation 2 r Source #
Skew transformation that keeps the y-coordinates fixed and shifts the x coordinates.
rotation :: Floating r => r -> Transformation 2 r Source #
Create a matrix that corresponds to a rotation by a radians counter-clockwise
around the origin.
reflection :: Floating r => r -> Transformation 2 r Source #
Create a matrix that corresponds to a reflection in a line through the origin
which makes an angle of a radians with the positive x-asis, in counter-clockwise
orientation.
reflectionV :: Num r => Transformation 2 r Source #
Vertical reflection
reflectionH :: Num r => Transformation 2 r Source #
Horizontal reflection
fitToBox :: forall box (d :: Nat) g point r. (NumType g ~ r, Dimension g ~ d, IsTransformable g, IsBoxable g, Box_ box point, Point_ point d r, Ord r, Fractional r, TransformationConstraints d r, Functor (Vector d), Zip (Vector d), d <= ((d + 1) - 1)) => box -> g -> g Source #
Given a box r and a geometry g with its boundingbox, transform the g to fit r.
fitToBoxTransform :: forall box (d :: Nat) g point r. (NumType g ~ r, Dimension g ~ d, IsTransformable g, IsBoxable g, Box_ box point, Point_ point d r, Ord r, Fractional r, TransformationConstraints d r, Functor (Vector d), Zip (Vector d), d <= ((d + 1) - 1)) => box -> g -> Transformation d r Source #
Given a box r and a geometry g with its boundingbox, compute a transformation can fit g to r.