Maintainer | diagrams-discuss@googlegroups.com |
---|---|
Safe Haskell | None |
Basic types for two-dimensional Euclidean space.
- data R2 = R2 !Double !Double
- r2 :: (Double, Double) -> R2
- unr2 :: R2 -> (Double, Double)
- mkR2 :: Double -> Double -> R2
- r2Iso :: Iso' R2 (Double, Double)
- type P2 = Point R2
- p2 :: (Double, Double) -> P2
- mkP2 :: Double -> Double -> P2
- unp2 :: P2 -> (Double, Double)
- p2Iso :: Iso' P2 (Double, Double)
- type T2 = Transformation R2
- data Angle
- rad :: Iso' Angle Double
- turn :: Iso' Angle Double
- deg :: Iso' Angle Double
- fullTurn :: Angle
- fullCircle :: Angle
- angleRatio :: Angle -> Angle -> Double
- (@@) :: b -> Iso' a b -> a
2D Euclidean space
The two-dimensional Euclidean vector space R^2. This type is intentionally abstract.
- To construct a vector, use
r2
, or^&
(from Diagrams.Coordinates):
r2 (3,4) :: R2 3 ^& 4 :: R2
Note that Diagrams.Coordinates is not re-exported by Diagrams.Prelude and must be explicitly imported.
- To construct the vector from the origin to a point
p
, usep
..-.
origin
- To convert a vector
v
into the point obtained by followingv
from the origin, use
.origin
.+^
v - To convert a vector back into a pair of components, use
unv2
orcoords
(from Diagrams.Coordinates). These are typically used in conjunction with theViewPatterns
extension:
foo (unr2 -> (x,y)) = ... foo (coords -> x :& y) = ...
Eq R2 | |
Fractional R2 | |
Num R2 | |
Ord R2 | |
Read R2 | |
Show R2 | |
Typeable R2 | |
Transformable R2 | |
Wrapped R2 | Lens wrapped isomorphisms for R2. |
HasBasis R2 | |
VectorSpace R2 | |
InnerSpace R2 | |
AdditiveGroup R2 | |
HasY P2 | |
HasY R2 | |
HasX P2 | |
HasX R2 | |
Coordinates R2 | |
Rewrapped R2 R2 | |
Traced (FixedSegment R2) | |
Traced (Trail R2) | |
Traced (Path R2) | |
Traced (Segment Closed R2) | |
Renderable (Path R2) b => TrailLike (QDiagram b R2 Any) |
unr2 :: R2 -> (Double, Double)Source
Convert a 2D vector back into a pair of components. See also coords
.
Points in R^2. This type is intentionally abstract.
- To construct a point, use
p2
, or^&
(see Diagrams.Coordinates):
p2 (3,4) :: P2 3 ^& 4 :: P2
- To construct a point from a vector
v
, use
.origin
.+^
v - To convert a point
p
into the vector from the origin top
, usep
..-.
origin
- To convert a point back into a pair of coordinates, use
unp2
, orcoords
(from Diagrams.Coordinates). It's common to use these in conjunction with theViewPatterns
extension:
foo (unp2 -> (x,y)) = ... foo (coords -> x :& y) = ...
unp2 :: P2 -> (Double, Double)Source
Convert a 2D point back into a pair of coordinates. See also coords
.
type T2 = Transformation R2Source
Transformations in R^2.
Angles
Angles can be expressed in a variety of units. Internally, they are represented in radians.
rad :: Iso' Angle DoubleSource
The radian measure of an Angle
a
can be accessed as a
^. rad
. A new Angle
can be defined in radians as pi @@ rad
.
turn :: Iso' Angle DoubleSource
The measure of an Angle
a
in full circles can be accessed as
a ^. turn
. A new Angle
of one-half circle can be defined in as
1/2 @@ turn
.
deg :: Iso' Angle DoubleSource
The degree measure of an Angle
a
can be accessed as a
^. deg
. A new Angle
can be defined in degrees as 180 @@
deg
.
Deprecated synonym for fullTurn
, retained for backwards compatibility.
angleRatio :: Angle -> Angle -> DoubleSource
Calculate ratio between two angles.