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

HGeometry.Direction

Description

Compuations that have to do with directions

Synopsis

Documentation

class r ~ NumType geom => CanComputeNormalVector geom r | geom -> r where Source #

Minimal complete definition

normalVectorAt

Methods

normalUnitVectorAt :: forall point (d :: Nat). (Point_ point d r, Has_ Metric_ d r, d ~ Dimension geom, Radical r, Fractional r) => point -> geom -> Vector d r Source #

Given a point on the object, and the object. Compute the outward normal vector at the given point. The normal is returned as a unit vector.

pre: the query point lies on (the surface of) the object. (This is not checked)

normalVectorAt :: forall point (d :: Nat). (Point_ point d r, d ~ Dimension geom, Num r) => point -> geom -> Vector d r Source #

Given a point on the object, and the object. Compute the outward normal vector at the given point. No Guarantees are given about the length of the resulting vector.

pre: the query point lies on (the surface of) the object. (This is not checked)

Instances

Instances details
Point_ center d r => CanComputeNormalVector (Ball center) r Source # 
Instance details

Defined in HGeometry.Direction

Methods

normalUnitVectorAt :: forall point (d0 :: Nat). (Point_ point d0 r, Has_ Metric_ d0 r, d0 ~ Dimension (Ball center), Radical r, Fractional r) => point -> Ball center -> Vector d0 r Source #

normalVectorAt :: forall point (d0 :: Nat). (Point_ point d0 r, d0 ~ Dimension (Ball center), Num r) => point -> Ball center -> Vector d0 r Source #

Point_ vertex 3 r => CanComputeNormalVector (Triangle vertex) r Source # 
Instance details

Defined in HGeometry.Direction

Methods

normalUnitVectorAt :: forall point (d :: Nat). (Point_ point d r, Has_ Metric_ d r, d ~ Dimension (Triangle vertex), Radical r, Fractional r) => point -> Triangle vertex -> Vector d r Source #

normalVectorAt :: forall point (d :: Nat). (Point_ point d r, d ~ Dimension (Triangle vertex), Num r) => point -> Triangle vertex -> Vector d r Source #

uniformDirection :: forall gen m r (d :: Nat). (StatefulGen gen m, Fractional r, Ord r, Radical r, UniformRange r, Has_ Metric_ d r, Ord (Vector d r)) => gen -> m (Vector d r) Source #

Generates a unit vector corresponding to a direction.

The general idea is to generate a random vector in the [-1,1]^d, if it lies inside the unit ball, scale it to be length 1, otherwise, retry.

uniformUpwardDirectionWrt :: forall gen m r (d :: Nat). (StatefulGen gen m, Fractional r, Ord r, Radical r, UniformRange r, Has_ Metric_ d r, Ord (Vector d r)) => Vector d r -> gen -> m (Vector d r) Source #

Generates an upward direction (with respect to the given normal/up vector) uniformly at random.