vector-space-points-0.2.1.2: A type for points, as distinct from vectors.

Data.AffineSpace.Point

Contents

Description

A type for points (as distinct from vectors), with an appropriate AffineSpace instance.

Synopsis

# Points

newtype Point v Source

`Point` is a newtype wrapper around vectors used to represent points, so we don't get them mixed up. The distinction between vectors and points is important: translations affect points, but leave vectors unchanged. Points are instances of the `AffineSpace` class from Data.AffineSpace.

Constructors

 P v

Instances

 Source Eq v => Eq (Point v) Source Data v => Data (Point v) Source Ord v => Ord (Point v) Source Read v => Read (Point v) Source Show v => Show (Point v) Source Source type Diff (Point v) = v Source

unPoint :: Point v -> v Source

Convert a point `p` into the vector from the origin to `p`. This should be considered a "semantically unsafe" operation; think carefully about whether and why you need to use it. The recommended way to do this conversion would be to write ```(p .-. origin)```.

The origin of the vector space `v`.

(*.) :: VectorSpace v => Scalar v -> Point v -> Point v Source

Scale a point by a scalar.

mirror :: AdditiveGroup v => Point v -> Point v Source

Reflect a point through the `origin`.

# Reflection through a point

relative :: AffineSpace p => p -> (Diff p -> Diff p) -> p -> p Source

Apply a transformation relative to the given point.

relative2 :: AffineSpace p => p -> (Diff p -> Diff p -> Diff p) -> p -> p -> p Source

Apply a transformation relative to the given point.

relative3 :: AffineSpace p => p -> (Diff p -> Diff p -> Diff p -> Diff p) -> p -> p -> p -> p Source

Apply a transformation relative to the given point.

reflectThrough :: AffineSpace p => p -> p -> p Source

Mirror a point through a given point.