| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.Triangle.Class
Contents
Description
A class of types representing Triangles
Synopsis
- class (Point_ point (Dimension point) (NumType point), HasVertices triangle triangle, Vertex triangle ~ point) => Triangle_ triangle point | triangle -> point where
- pattern Triangle_ :: Triangle_ triangle point => point -> point -> point -> triangle
- class Triangle_ triangle point => ConstructableTriangle_ triangle point where
- mkTriangle :: point -> point -> point -> triangle
- toCounterClockwiseTriangle :: (Num r, Eq r, Point_ point 2 r, Triangle_ triangle point) => triangle -> triangle
- triangleSignedArea2X :: (Num r, Point_ point 2 r, Triangle_ triangle point) => triangle -> r
- intersectingHalfPlanes :: (Triangle_ triangle point, Point_ point 2 r, Num r, Ord r) => triangle -> Vector 3 (HalfSpaceF (LinePV 2 r))
- toBarricentric :: (Fractional r, Point_ point 2 r, Triangle_ triangle point) => point -> triangle -> Vector 3 r
- fromBarricentric :: forall triangle point (d :: Nat) r. (Triangle_ triangle point, Point_ point d r, Num r) => Vector 3 r -> triangle -> Point d r
- class HasVertices' graph => HasVertices graph graph' where
- vertices :: IndexedTraversal1 (VertexIx graph) graph graph' (Vertex graph) (Vertex graph')
- class HasVertices' graph where
- type Vertex graph
- type VertexIx graph
- vertexAt :: VertexIx graph -> IndexedTraversal' (VertexIx graph) graph (Vertex graph)
- numVertices :: graph -> Int
Documentation
class (Point_ point (Dimension point) (NumType point), HasVertices triangle triangle, Vertex triangle ~ point) => Triangle_ triangle point | triangle -> point where Source #
Class representing triangles
Methods
corners :: Lens' triangle (Vector 3 point) Source #
Lens to access the corners of the triangle.
pattern Triangle_ :: Triangle_ triangle point => point -> point -> point -> triangle Source #
Pattern match on a triangle
class Triangle_ triangle point => ConstructableTriangle_ triangle point where Source #
Class representing constructable triangles
Methods
mkTriangle :: point -> point -> point -> triangle Source #
Construct a triangle from its three vertices.
Instances
| Point_ point (Dimension point) (NumType point) => ConstructableTriangle_ (Triangle point) point Source # | |
Defined in HGeometry.Triangle Methods mkTriangle :: point -> point -> point -> Triangle point Source # | |
| (ConstructableTriangle_ triangle point, Default extra) => ConstructableTriangle_ (triangle :+ extra) point Source # | |
Defined in HGeometry.Triangle.Class Methods mkTriangle :: point -> point -> point -> triangle :+ extra Source # | |
toCounterClockwiseTriangle :: (Num r, Eq r, Point_ point 2 r, Triangle_ triangle point) => triangle -> triangle Source #
Make sure that the triangles vertices are given in counter clockwise order
>>>let t = Triangle origin (Point2 0 (-1)) (Point2 (-1) 0) :: Triangle (Point 2 Int)>>>toCounterClockwiseTriangle tTriangle (Point2 0 0) (Point2 (-1) 0) (Point2 0 (-1))
triangleSignedArea2X :: (Num r, Point_ point 2 r, Triangle_ triangle point) => triangle -> r Source #
Computes the double-signed area of a triangle
intersectingHalfPlanes :: (Triangle_ triangle point, Point_ point 2 r, Num r, Ord r) => triangle -> Vector 3 (HalfSpaceF (LinePV 2 r)) Source #
Get the three halfplanes such that the triangle is the intersection of those halfspaces.
>>>let t = Triangle origin (Point2 0 (-1)) (Point2 (-1) 0) :: Triangle (Point 2 Int)>>>mapM_ print $ intersectingHalfPlanes tHalfSpace Positive (LinePV (Point2 0 0) (Vector2 (-1) 0)) HalfSpace Positive (LinePV (Point2 (-1) 0) (Vector2 1 (-1))) HalfSpace Positive (LinePV (Point2 0 (-1)) (Vector2 0 1))
toBarricentric :: (Fractional r, Point_ point 2 r, Triangle_ triangle point) => point -> triangle -> Vector 3 r Source #
Given a point q and a triangle, q inside the triangle, get the baricentric cordinates of q
fromBarricentric :: forall triangle point (d :: Nat) r. (Triangle_ triangle point, Point_ point d r, Num r) => Vector 3 r -> triangle -> Point d r Source #
Given a vector of barricentric coordinates and a triangle, get the corresponding point in the same coordinate sytsem as the vertices of the triangle.
Re-exports from Hiraffe
class HasVertices' graph => HasVertices graph graph' where Source #
Class that expresses that we have a non-empty type changing traversal of all vertices.
Methods
vertices :: IndexedTraversal1 (VertexIx graph) graph graph' (Vertex graph) (Vertex graph') Source #
Traversal of all vertices in the graph
Instances
| HasVertices Graph Graph Source # | |
| HasVertices (Triangle point) (Triangle point') Source # | |
| HasVertices graph graph' => HasVertices (graph :+ extra) (graph' :+ extra) Source # | |
| (Traversable1 endPoint, EndPoint_ (endPoint v), IxValue (endPoint v) ~ v) => HasVertices (LineSegment endPoint v) (LineSegment endPoint v') Source # | |
Defined in HGeometry.LineSegment.Internal Methods vertices :: IndexedTraversal1 (VertexIx (LineSegment endPoint v)) (LineSegment endPoint v) (LineSegment endPoint v') (Vertex (LineSegment endPoint v)) (Vertex (LineSegment endPoint v')) Source # | |
| HasVertices (GGraph f v e) (GGraph f v' e) Source # | |
| Ord i => HasVertices (GGraph f i v e) (GGraph f i v' e) Source # | |
| HasVertices (PlanarGraph w s v e f) (PlanarGraph w s v' e f) Source # | |
Defined in Hiraffe.PlanarGraph.Type Methods vertices :: IndexedTraversal1 (VertexIx (PlanarGraph w s v e f)) (PlanarGraph w s v e f) (PlanarGraph w s v' e f) (Vertex (PlanarGraph w s v e f)) (Vertex (PlanarGraph w s v' e f)) Source # | |
class HasVertices' graph where Source #
A class representing types that have vertices.
Minimal complete definition
Associated Types
Vertices of the graph are of this type
Vertices are indexed by elements of type VertexIx
Methods
vertexAt :: VertexIx graph -> IndexedTraversal' (VertexIx graph) graph (Vertex graph) Source #
Accessor to a given vertex.
numVertices :: graph -> Int Source #
Number of vertices in the graph.
running time: O(1)
default numVertices :: HasVertices graph graph => graph -> Int Source #