Data.Geometria
- Package
- purescript-geometria
- Repository
- Ebmtranceboy/purescript-geometria
Re-exports from Data.Geometria.Ellipse
#Ellipse Source
newtype Ellipse
-- --
| ;TLDR : |
| ------ |
| |
| e@ |
| ( |
| Ellipse |
| { center |
| , a |
| , b |
| , c |
| } |
| ) = ellipse center (radiusMax /\ radiusMin) alpha |
| |
| represents the set of points (x/\y) satisfying: |
| |
| a * (x - center.x)^2 |
| + b * (y - center.y)^2 |
| + c * (x - center.x) (y - center.y) - residualConstant(e) |
| = 0 |
| |
| |
-- --
ELLIPSES
Implicit ellipse representations: 5 degrees of freedom
Level-set representation:
f(x,y) = ax2 + by2 + cxy + dx + ey = 1
Matrix equation representation:
_ _ _ _
| a c/2 d/2 | | x |
_ _ | c/2 b e/2 | | y |
| x y 1| | d/2 e/2 -1 | | 1 | = X^TAX = 0
- - - - - -
Centering (abandonment of degree-1 terms):
Changes of variables: x = X+h
and y = Y+k
such that f(x,y) = g(X,Y) = aX2 + bY2 + cXY + L
=> [h; k] = [ec-2bd; cd-2ae] / (4ab-c2)
and L = L(a,b,c,d,e,h,k) = ah2 + bk2 + chk + dh + ek
.
Furthermore, f(x,y) = 1
=> aX2 + bY2 + cXY = l = 1-L
.
Then, ellipse representation can simply be:
_ _ _ _
_ _ | a c/2 | | x |
| x y | | c/2 b | | y | = X^TBX = l
- - - - - -
(cf. ellipseInternal
and residualConstant
functions)
Alinement (coupling term abandonment, after centering):
B
diagonalization, with B
symmetric matrix:
- one diagonal matrix
D =[D00, 0; 0, D11]
: 2 degrees of freedom - one angle
t
: 1 degree of freedom => thus 5 degree of freedom with the 2 ones from centering.
(cf. unCouple
function)
Ellipses explicit representations:
Every point (x,y)
of the unit circle is associated with
a point (X,Y)
from the (h,k)
-centered ellipse thanks to
the affine transformation:
_ _ _ _ _ _ _ _ _ _
| X | | h | | cos(t) -sin(t) || s0=sqrt(|l/D00|) 0 || x |
| Y |=| k |+| sin(t) cos(t) || 0 s1=sqrt(|l/D11|) || y |
- - - - - - - - - -
whose linear part is like an SVD decomposition
(if, as it has been done here, V
is chosen as the identity, meaning
that the four cardinal points from the unit circle correspond
to the extreme points of the ellipse).
This way, reciprocally, t
, s0
and s1
parameters
can be recovered, for every T = USV'
matrix, by
- diagonalizing
T'T
- orthonormalizing its eigen vectors
- taking the square root of its eigen values.
(cf. ellipseDimensions
and fromUnitCircle
functions)
Constructors
Instances
#unCouple Source
unCouple :: Ellipse -> Number /\ Number /\ Number
Equivalent to the diagonalization of the symmetric input matrix :
t
est l'angle de rotation autour de l'origine tel que c'=0
dans la nouvelle representation:
tan(2t) = c/(a-b)
vec
= matrice de rotation d'anglet
val = recip vec * m * vec = [d00, 0; 0, d11]
#turnEllipse Source
turnEllipse :: Number -> Ellipse -> Ellipse
Rotation adapted to the chosen representation of an ellipse.
#steiner Source
steiner :: Point 2 -> Point 2 -> Point 2 -> Ellipse
Biggest ellipse in a triangle. Could also be defined with 5 points :
- the 3 segment's middles,
- the intersection of a median and the symmetric of the opposite side with respect to isobarycenter and
- another intersection of a median and the symmetric of the opposite
side with respect to isobarycenter.
#residualConstant Source
residualConstant :: Ellipse -> Number
Value of the second member in the updated equation after centering.
#quadratic Source
quadratic :: Array (Point 2) -> Ellipse
Extracts the relevant parts of an ellipse defined by 5 points (all different from the origin): symmetric 2X2 matrix /\ position of the center
Computation of the parameters of an ellipse passing through the origin (point zero
) CANNOT be done with the quadratic
function even if the five points are different from the origin. See in the test file how to make two translations to use it anyway.
#moveEllipse Source
moveEllipse :: Vector 2 -> Ellipse -> Ellipse
Translation adapted to the chosen representation of an ellipse.
#fromUnitCircle Source
fromUnitCircle :: Ellipse -> Point 2 -> Point 2
Explicit construction of a point of the ellipse from a point of the unit circle such that the four cardinal circular points correspond to the extremities of the axes of the ellipse.
#ellipseInternal Source
ellipseInternal :: Ellipse -> Polynomial (Polynomial Number)
#ellipseCenter Source
ellipseCenter :: Ellipse -> Point 2
#cardinal Source
cardinal :: Point 2 -> Point 2 -> Number -> Ellipse
Computes the relevant parts of an ellipse defined by :
- its center
- one of its cardinal points, (this sets the first semi-axis), and
- the length of the other semi-axis. Could also be defined with 5 points :
- the 4 cardinal points,
- a fifth point defined as
the sum of two consecutive cardinal vectors, over
sqrt(2)
.
Re-exports from Data.Geometria.Space
#revolution Source
revolution :: Vector 3 -> Number -> Vector 3 -> Vector 3
revolution n a u
is the 3D-rotation of u
of angle a
around the normalized axis n
.
#land Source
land :: Vector 3 -> Vector 3 -> Vector 3
land n
is a 3D-rotation such that, for every 3D vector u
in the plane P
of normal vector n
, land n u
has a constant altitude
(z-coordinate). Thanks to land
, every computation on P
can be
performed in 2D. The rotation matrix is obtained by the landing
function, and, as it is orthogonal, the inverse transformation is simply
done by the transposed matrix.
Re-exports from Data.Geometria.Types
#System Source
type System :: Int -> Type
type System (n :: Int) = Polynomial (Polynomial Number)
#Segment Source
newtype Segment :: Int -> Type
newtype Segment n
Constructors
Instances
Show (Segment n)
(ToString n s, IsSymbol s) => Metric (Segment n)
Intersectable (Segment 2) (Line 2)
Intersectable (Line 2) (Segment 2)
Intersectable (Segment 2) (HalfLine 2)
Intersectable (HalfLine 2) (Segment 2)
Intersectable (Segment 2) Circle
Intersectable Circle (Segment 2)
Intersectable (Segment 2) (Segment 2)
#Line Source
newtype Line :: Int -> Type
newtype Line n
Constructors
Instances
Show (Line n)
Intersectable (Line 2) (Line 2)
Intersectable (Line 2) (HalfLine 2)
Intersectable (HalfLine 2) (Line 2)
Intersectable (Line 2) Circle
Intersectable Circle (Line 2)
Intersectable (Segment 2) (Line 2)
Intersectable (Line 2) (Segment 2)
#HalfLine Source
newtype HalfLine :: Int -> Type
newtype HalfLine n
Constructors
Instances
Show (HalfLine n)
Intersectable (Line 2) (HalfLine 2)
Intersectable (HalfLine 2) (Line 2)
Intersectable (HalfLine 2) Circle
Intersectable Circle (HalfLine 2)
Intersectable (HalfLine 2) (HalfLine 2)
Intersectable (Segment 2) (HalfLine 2)
Intersectable (HalfLine 2) (Segment 2)
#Analytic Source
class Analytic a where
Members
fromCoordinates :: Polynomial Number -> a
toCoordinates :: a -> Polynomial Number
index :: a -> Int -> Number
Instances
#EuclideanSpace Source
class EuclideanSpace a where
Members
dot :: a -> a -> Number
normalTo :: Array a -> a
Builds the n-dimensioned vector needed for the provided array of (n-1) n-dimensioned independant vectors to be a R^n basis.
Instances
(ToString n s, IsSymbol s) => EuclideanSpace (Vector n)
#Intersectable Source
class Intersectable a b where
Members
Instances
Intersectable (Line 2) (Line 2)
Intersectable (Line 2) (HalfLine 2)
Intersectable (HalfLine 2) (Line 2)
Intersectable (Line 2) Circle
Intersectable Circle (Line 2)
Intersectable (HalfLine 2) Circle
Intersectable Circle (HalfLine 2)
Intersectable Circle Circle
Intersectable (HalfLine 2) (HalfLine 2)
Intersectable (Segment 2) (Line 2)
Intersectable (Line 2) (Segment 2)
Intersectable (Segment 2) (HalfLine 2)
Intersectable (HalfLine 2) (Segment 2)
Intersectable (Segment 2) Circle
Intersectable Circle (Segment 2)
Intersectable (Segment 2) (Segment 2)
#freeVector Source
freeVector :: forall @n. Shape n Vector => Polynomial Number -> Vector n
Scalar product