hgeometry-kernel
Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellNone
LanguageGHC2024

HGeometry.Triangle.Class

Description

A class of types representing Triangles

Synopsis

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.

Instances

Instances details
Point_ point (Dimension point) (NumType point) => Triangle_ (Triangle point) point Source # 
Instance details

Defined in HGeometry.Triangle

Methods

corners :: Lens' (Triangle point) (Vector 3 point) Source #

Triangle_ triangle point => Triangle_ (triangle :+ extra) point Source # 
Instance details

Defined in HGeometry.Triangle.Class

Methods

corners :: Lens' (triangle :+ extra) (Vector 3 point) Source #

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

Instances details
Point_ point (Dimension point) (NumType point) => ConstructableTriangle_ (Triangle point) point Source # 
Instance details

Defined in HGeometry.Triangle

Methods

mkTriangle :: point -> point -> point -> Triangle point Source #

(ConstructableTriangle_ triangle point, Default extra) => ConstructableTriangle_ (triangle :+ extra) point Source # 
Instance details

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 t
Triangle (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 t
HalfSpace 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

Instances details
HasVertices Graph Graph Source # 
Instance details

Defined in Hiraffe.Graph.Class

HasVertices (Triangle point) (Triangle point') Source # 
Instance details

Defined in HGeometry.Triangle

Methods

vertices :: IndexedTraversal1 (VertexIx (Triangle point)) (Triangle point) (Triangle point') (Vertex (Triangle point)) (Vertex (Triangle point')) Source #

HasVertices graph graph' => HasVertices (graph :+ extra) (graph' :+ extra) Source # 
Instance details

Defined in Hiraffe.Graph.Class

Methods

vertices :: IndexedTraversal1 (VertexIx (graph :+ extra)) (graph :+ extra) (graph' :+ extra) (Vertex (graph :+ extra)) (Vertex (graph' :+ extra)) Source #

(Traversable1 endPoint, EndPoint_ (endPoint v), IxValue (endPoint v) ~ v) => HasVertices (LineSegment endPoint v) (LineSegment endPoint v') Source # 
Instance details

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 # 
Instance details

Defined in Hiraffe.AdjacencyListRep

Methods

vertices :: IndexedTraversal1 (VertexIx (GGraph f v e)) (GGraph f v e) (GGraph f v' e) (Vertex (GGraph f v e)) (Vertex (GGraph f v' e)) Source #

Ord i => HasVertices (GGraph f i v e) (GGraph f i v' e) Source # 
Instance details

Defined in Hiraffe.AdjacencyListRep.Map

Methods

vertices :: IndexedTraversal1 (VertexIx (GGraph f i v e)) (GGraph f i v e) (GGraph f i v' e) (Vertex (GGraph f i v e)) (Vertex (GGraph f i v' e)) Source #

HasVertices (PlanarGraph w s v e f) (PlanarGraph w s v' e f) Source # 
Instance details

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

vertexAt

Associated Types

type Vertex graph Source #

Vertices of the graph are of this type

type VertexIx graph Source #

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 #

Instances

Instances details
HasVertices' Graph Source # 
Instance details

Defined in Hiraffe.Graph.Class

Associated Types

type Vertex Graph 
Instance details

Defined in Hiraffe.Graph.Class

type Vertex Graph = ()
type VertexIx Graph 
Instance details

Defined in Hiraffe.Graph.Class

HasVertices' (Triangle point) Source # 
Instance details

Defined in HGeometry.Triangle

Associated Types

type Vertex (Triangle point) 
Instance details

Defined in HGeometry.Triangle

type Vertex (Triangle point) = point
type VertexIx (Triangle point) 
Instance details

Defined in HGeometry.Triangle

type VertexIx (Triangle point) = Int
HasVertices' graph => HasVertices' (graph :+ extra) Source # 
Instance details

Defined in Hiraffe.Graph.Class

Associated Types

type Vertex (graph :+ extra) 
Instance details

Defined in Hiraffe.Graph.Class

type Vertex (graph :+ extra) = Vertex graph
type VertexIx (graph :+ extra) 
Instance details

Defined in Hiraffe.Graph.Class

type VertexIx (graph :+ extra) = VertexIx graph

Methods

vertexAt :: VertexIx (graph :+ extra) -> IndexedTraversal' (VertexIx (graph :+ extra)) (graph :+ extra) (Vertex (graph :+ extra)) Source #

numVertices :: (graph :+ extra) -> Int Source #

(IxValue (endPoint vertex) ~ vertex, EndPoint_ (endPoint vertex)) => HasVertices' (LineSegment endPoint vertex) Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

Associated Types

type Vertex (LineSegment endPoint vertex) 
Instance details

Defined in HGeometry.LineSegment.Internal

type Vertex (LineSegment endPoint vertex) = vertex
type VertexIx (LineSegment endPoint vertex) 
Instance details

Defined in HGeometry.LineSegment.Internal

type VertexIx (LineSegment endPoint vertex)

Methods

vertexAt :: VertexIx (LineSegment endPoint vertex) -> IndexedTraversal' (VertexIx (LineSegment endPoint vertex)) (LineSegment endPoint vertex) (Vertex (LineSegment endPoint vertex)) Source #

numVertices :: LineSegment endPoint vertex -> Int Source #

HasVertices' (GGraph f v e) Source # 
Instance details

Defined in Hiraffe.AdjacencyListRep

Associated Types

type Vertex (GGraph f v e) 
Instance details

Defined in Hiraffe.AdjacencyListRep

type Vertex (GGraph f v e) = v
type VertexIx (GGraph f v e) 
Instance details

Defined in Hiraffe.AdjacencyListRep

type VertexIx (GGraph f v e) = Int

Methods

vertexAt :: VertexIx (GGraph f v e) -> IndexedTraversal' (VertexIx (GGraph f v e)) (GGraph f v e) (Vertex (GGraph f v e)) Source #

numVertices :: GGraph f v e -> Int Source #

Ord i => HasVertices' (GGraph f i v e) Source # 
Instance details

Defined in Hiraffe.AdjacencyListRep.Map

Associated Types

type Vertex (GGraph f i v e) 
Instance details

Defined in Hiraffe.AdjacencyListRep.Map

type Vertex (GGraph f i v e) = v
type VertexIx (GGraph f i v e) 
Instance details

Defined in Hiraffe.AdjacencyListRep.Map

type VertexIx (GGraph f i v e) = i

Methods

vertexAt :: VertexIx (GGraph f i v e) -> IndexedTraversal' (VertexIx (GGraph f i v e)) (GGraph f i v e) (Vertex (GGraph f i v e)) Source #

numVertices :: GGraph f i v e -> Int Source #

HasVertices' (DualGraph w s v e f) Source # 
Instance details

Defined in Hiraffe.PlanarGraph.Type

Associated Types

type Vertex (DualGraph w s v e f) 
Instance details

Defined in Hiraffe.PlanarGraph.Type

type Vertex (DualGraph w s v e f) = Face (PlanarGraph w s v e f)
type VertexIx (DualGraph w s v e f) 
Instance details

Defined in Hiraffe.PlanarGraph.Type

type VertexIx (DualGraph w s v e f) = FaceIx (PlanarGraph w s v e f)

Methods

vertexAt :: VertexIx (DualGraph w s v e f) -> IndexedTraversal' (VertexIx (DualGraph w s v e f)) (DualGraph w s v e f) (Vertex (DualGraph w s v e f)) Source #

numVertices :: DualGraph w s v e f -> Int Source #

HasVertices' (PlanarGraph w s v e f) Source # 
Instance details

Defined in Hiraffe.PlanarGraph.Type

Associated Types

type Vertex (PlanarGraph w s v e f) 
Instance details

Defined in Hiraffe.PlanarGraph.Type

type Vertex (PlanarGraph w s v e f) = v
type VertexIx (PlanarGraph w s v e f) 
Instance details

Defined in Hiraffe.PlanarGraph.Type

type VertexIx (PlanarGraph w s v e f) = VertexId s

Methods

vertexAt :: VertexIx (PlanarGraph w s v e f) -> IndexedTraversal' (VertexIx (PlanarGraph w s v e f)) (PlanarGraph w s v e f) (Vertex (PlanarGraph w s v e f)) Source #

numVertices :: PlanarGraph w s v e f -> Int Source #