License | AGPL-3 |
---|---|
Maintainer | swiss-ephemeris@lfborjas.com |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Utility functions for chart drawing functionality. Uses the C code shared by the swiss ephemeris authors in the official mailing list: https://groups.io/g/swisseph/message/5568
Synopsis
- data GlyphInfo a = GlyphInfo {
- originalPosition :: Double
- glyphSize :: (Double, Double)
- placedPosition :: Double
- sectorNumber :: Int
- sequenceNumber :: Int
- levelNumber :: Int
- glyphScale :: Double
- extraData :: a
- type PlanetGlyphInfo = GlyphInfo Planet
- glyphPlanet :: PlanetGlyphInfo -> Planet
- cuspsToSectors :: [HouseCusp] -> [Double]
- gravGroup :: HasEclipticLongitude a => (Double, Double) -> [(Planet, a)] -> [Double] -> Either String [PlanetGlyphInfo]
- gravGroupEasy :: HasEclipticLongitude a => Double -> [(Planet, a)] -> [HouseCusp] -> Either String [PlanetGlyphInfo]
- gravGroup2 :: HasEclipticLongitude a => (Double, Double) -> [(Planet, a)] -> [Double] -> Bool -> Either String [PlanetGlyphInfo]
- gravGroup2Easy :: HasEclipticLongitude a => Double -> [(Planet, a)] -> [HouseCusp] -> Bool -> Either String [PlanetGlyphInfo]
Documentation
Information about a glyph
(planet or some other object
one intends to render within a circular chart) indicating
suggested position and scale as decided by gravGroup
or gravGroup2
to minimize collisions without affecting
the sequence of a list of objects, or the sectors
within which they may be grouped.
GlyphInfo | |
|
type PlanetGlyphInfo = GlyphInfo Planet Source #
GlyphInfo
specialized to carry Planet
names
as its extraData
.
glyphPlanet :: PlanetGlyphInfo -> Planet Source #
cuspsToSectors :: [HouseCusp] -> [Double] Source #
This function does a little bit of insider trading:
given N cusps, returns N+1 sectors; where the last
sector is an "impossible" position beyond 360, that
sets the end of the last sector as the first sector's beginning,
beyond one turn. That way, any body occurring in
the last sector will exist between sectors[N-1]
and
sectors[N]
. I've been using this as the "linearization"
approach for the sectors required by gravGroup
,
but one may choose something different.
:: HasEclipticLongitude a | |
=> (Double, Double) | lwidth, rwidth |
-> [(Planet, a)] | list of pre-calculated positions |
-> [Double] | list of "sectors" (e.g. house cusps + end of last cusp) |
-> Either String [PlanetGlyphInfo] |
Given dimensions, planet positions and "sectors" within which
the planets are meant to be drawn as glyphs, return a list
pairing each position with a PlanetGlyphInfo
that not only
remembers the position's planet, it's guaranteed to place it
in the same sector and sequence it started in, but moved as to
avoid colliding with other nearby planets or sector boundaries.
Note that "sectors" are usually cusps, but one must take that they're
sorted or "linearized": no sector should jump over 0/360, and the
last sector should mark the "end" of the circle. I use cuspsToSectors
on cusps obtained from the main module's cusp calculation functionality
and that seems to ensure that sectors are adequately monotonic and not
truncated, but one would be wise to take heed to the swiss ephemeris author's
notes, too:
https://groups.io/g/swisseph/message/5568
gravGroupEasy :: HasEclipticLongitude a => Double -> [(Planet, a)] -> [HouseCusp] -> Either String [PlanetGlyphInfo] Source #
Easy version of gravGroup
that assumes:
- Glyphs are square/symmetrical, so the left and right widths are just half of the provided width, each.
- The provided cusps can be "linearized" by the naïve approach of
cuspsToSectors
:: HasEclipticLongitude a | |
=> (Double, Double) | lwidth, rwidth |
-> [(Planet, a)] | list of pre-calculated positions |
-> [Double] | list of "sectors" (e.g. house cusps + end of last cusp) (can be empty, indicating that we're working in a non-subdivided circle.) |
-> Bool | allow planets to be moved up or down a level? |
-> Either String [PlanetGlyphInfo] |
Same semantics and warnings as gravGroup
, but allows a couple of things for
more advanced (or crowded) applications:
- Can send an empty list of sectors, to indicate that there's no subdivisions in the circle.
- Can specify if planets can be pushed to an "inner" level if they're too crowded in their assigned sector. Useful when drawing several objects in a chart with many/tight sectors.
With a non-empty list of sectors, and not allowing shifting, this is essentially
a slightly slower version of gravGroup
.
gravGroup2Easy :: HasEclipticLongitude a => Double -> [(Planet, a)] -> [HouseCusp] -> Bool -> Either String [PlanetGlyphInfo] Source #
Easy version of gravGroup2
, same provisions as gravGroupEasy